lithium\tests\integration\data\SourceTest::testSingleReadWriteWithKey PHP Метод

testSingleReadWriteWithKey() публичный Метод

Tests that a single record with a manually specified primary key can be created, persisted to an arbitrary data store, re-read and updated.
    public function testSingleReadWriteWithKey()
    {
        $key = Galleries::meta('key');
        $new = Galleries::create(array($key => 12345, 'name' => 'Acme, Inc.'));
        $result = $new->data();
        $expected = array($key => 12345, 'name' => 'Acme, Inc.');
        $this->assertEqual($expected[$key], $result[$key]);
        $this->assertEqual($expected['name'], $result['name']);
        $this->assertFalse($new->exists());
        $this->assertTrue($new->save());
        $this->assertTrue($new->exists());
        $existing = Galleries::find(12345);
        $result = $existing->data();
        $this->assertEqual($expected[$key], $result[$key]);
        $this->assertEqual($expected['name'], $result['name']);
        $this->assertTrue($existing->exists());
        $existing->name = 'Big Brother and the Holding Galleries';
        $result = $existing->save();
        $this->assertTrue($result);
        $existing = Galleries::find(12345);
        $result = $existing->data();
        $expected['name'] = 'Big Brother and the Holding Galleries';
        $this->assertEqual($expected[$key], $result[$key]);
        $this->assertEqual($expected['name'], $result['name']);
        $this->assertTrue($existing->delete());
    }