|
@@ 37-54 (lines=18) @@
|
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
/** @test */ |
| 37 |
|
public function it_should_create_a_table_on_first_insert() |
| 38 |
|
{ |
| 39 |
|
$meta = new ReadModelConfiguration( |
| 40 |
|
'test', |
| 41 |
|
new ReadModelId(new Integer()), |
| 42 |
|
[ |
| 43 |
|
new ReadModelField('f1', new Boolean()), |
| 44 |
|
new ReadModelField('f2', new TextString(10)), |
| 45 |
|
], |
| 46 |
|
function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
| 47 |
|
function () {} |
| 48 |
|
); |
| 49 |
|
|
| 50 |
|
$this->writer->writeRecord($meta, ['id' => 1, 'f1' => true, 'f2' => 'test']); |
| 51 |
|
|
| 52 |
|
$this->assertCount(1, $this->connection->createQueryBuilder()->select('*')->from('test_test')->execute()->fetchAll()); |
| 53 |
|
$this->assertCount(3, $this->connection->createQueryBuilder()->select('*')->from('test_test')->execute()->fetch()); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
/** @test */ |
| 57 |
|
public function it_should_update_the_table_on_record_change() |
|
@@ 78-95 (lines=18) @@
|
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
/** @test */ |
| 78 |
|
public function it_should_update_a_record() |
| 79 |
|
{ |
| 80 |
|
$meta = new ReadModelConfiguration( |
| 81 |
|
'test', |
| 82 |
|
new ReadModelId(new Integer()), |
| 83 |
|
[ |
| 84 |
|
new ReadModelField('f1', new Boolean()), |
| 85 |
|
new ReadModelField('f2', new TextString(10)) |
| 86 |
|
], |
| 87 |
|
function ($data) { return new Record($data['id'], ['f1' => $data['f1'], 'f2' => $data['f2']]); }, |
| 88 |
|
function () {} |
| 89 |
|
); |
| 90 |
|
|
| 91 |
|
$this->writer->writeRecord($meta, ['id' => 2, 'f1' => true, 'f2' => 'test2']); |
| 92 |
|
|
| 93 |
|
$this->assertEquals('test2', $this->connection->createQueryBuilder()->select('f2')->from('test_test')->where('identifier = 2')->execute()->fetchColumn(0)); |
| 94 |
|
$this->assertCount(3, $this->connection->createQueryBuilder()->select('*')->from('test_test')->execute()->fetch()); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
|