lithium\tests\cases\data\ModelTest::testKeyGeneration PHP Method

testKeyGeneration() public method

public testKeyGeneration ( )
    public function testKeyGeneration()
    {
        $this->assertEqual('comment_id', MockComment::key());
        $this->assertEqual(array('post_id', 'tag_id'), MockTagging::key());
        $result = MockComment::key(array('comment_id' => 5, 'body' => 'This is a comment'));
        $this->assertEqual(array('comment_id' => 5), $result);
        $result = MockTagging::key(array('post_id' => 2, 'tag_id' => 5, 'created' => '2009-06-16 10:00:00'));
        $this->assertEqual('id', MockPost::key());
        $this->assertEqual(array('id' => 5), MockPost::key(5));
        $this->assertEqual(array('post_id' => 2, 'tag_id' => 5), $result);
        $key = new stdClass();
        $key->foo = 'bar';
        $this->assertEqual(array('id' => $key), MockPost::key($key));
        $this->assertNull(MockPost::key(array()));
        $model = 'lithium\\tests\\mocks\\data\\MockModelCompositePk';
        $this->assertNull($model::key(array('client_id' => 3)));
        $result = $model::key(array('invoice_id' => 5, 'payment' => '100'));
        $this->assertNull($result);
        $expected = array('client_id' => 3, 'invoice_id' => 5);
        $result = $model::key(array('client_id' => 3, 'invoice_id' => 5, 'payment' => '100'));
        $this->assertEqual($expected, $result);
    }
ModelTest