dox Executable Documentation

File store

Create

$this->store->create(new TestEntity(true, 42, 1.6, 'Hello', new \DateTime('2001-01-01'), array('some' => array(42, 73))), 'there/here');
$this->assertExists('there/here');
$this->assertContent('there/here', '{
            "boolean": true,
            "integer": 42,
            "float": 1.6,
            "string": "Hello",
            "dateTime": "2001-01-01T00:00:00+00:00",
            "null": null,
            "nullDateTime": null,
            "array":{"some":[42, 73]}
        }');

Create raw file

$this->store = new RawFileStore(new SerializerRepository(), $this->tmpDir);
$this->store->create(new File('Some text'), 'here');
$this->assertRawContent('here', 'Some text');

Read

$dateTime = new \DateTime('2001-01-01');
$this->store->create(new lib\TestEntity(true, 42, 1.6, 'Hello', $dateTime), 'that/file');

* @var TestEntity $entity

$entity = $this->store->read('that/file');
$this->assertSame(true, $entity->getBoolean());
$this->assertSame(42, $entity->getInteger());
$this->assertSame(1.6, $entity->getFloat());
$this->assertSame('Hello', $entity->getString());
$this->assertEquals($dateTime->format('c'), $entity->getDateTime()->format('c'));
$this->assertNull($entity->getNull());
$this->assertEquals('that/file', $entity->id);

Update

$entity = new lib\TestEntity(true, 42, 1.6, 'Hello', new \DateTime('2001-01-01'));
$this->store->create($entity, 'here');
$entity->setString('Hello back');
$entity->setArray(array('foo' => 'bar', array(42, 73)));
$this->store->update($entity);
$this->assertContent('here', '{
            "boolean": true,
            "integer": 42,
            "float": 1.6,
            "string": "Hello back",
            "dateTime": "2001-01-01T00:00:00+00:00",
            "null": null,
            "nullDateTime": null,
            "array":{"foo":"bar","0":[42,73]}
        }');

Delete

$entity = new TestEntity(true, 42, 1.6, 'Hello', new \DateTime('2001-01-01'));
$this->store->create($entity, 'here');
$this->store->delete($entity);
$this->assertNotExists('here');

Keys

$entity = new TestEntity(true, 42, 1.6, 'Hello', new \DateTime('2001-01-01'));
$this->store->create($entity, 'file');
$this->store->create($entity, 'some/file');
$this->store->create($entity, 'some/bar');
$this->store->create($entity, 'some/deeper/file');
$keys = $this->store->keys();
$this->assertEquals(array('file', 'some/bar', 'some/deeper/file', 'some/file'), $keys);