dox Executable Documentation

Memory store

Create

$entity1 = new lib\TestEntity(true, 42, 1.6, 'Hi', new \DateTime());
$this->store->create($entity1);
$entity2 = new lib\TestEntity(true, 42, 1.6, 'Hi', new \DateTime());
$this->store->create($entity2);
$this->assertSame($entity1, $this->store->read($entity1->id));
$this->assertSame($entity2, $this->store->read($entity2->id));
$this->assertNotEquals($entity1->id, $entity2->id);

Read wrong id

$this->store->create(new lib\TestEntity(true, 42, 1.6, 'Hi', new \DateTime()));
try {
    $this->store->read(12);
    $this->fail('No Exception thrown');
} catch (\Exception $e) {
    $this->assertEquals('Entity with ID [12] does not exist.', $e->getMessage());
}