lithium\tests\integration\data\DocumentTest::testUpdateWithNewArray PHP Method

testUpdateWithNewArray() public method

    public function testUpdateWithNewArray()
    {
        $new = Galleries::create(array('name' => 'Poneys', 'active' => true));
        $expected = array('name' => 'Poneys', 'active' => true);
        $result = $new->data();
        $this->assertEqual($expected, $result);
        $new->foo = array('bar');
        $expected = array('name' => 'Poneys', 'active' => true, 'foo' => array('bar'));
        $result = $new->data();
        $this->assertEqual($expected, $result);
        $this->assertTrue($new->save());
        $updated = Galleries::find((string) $new->_id);
        $expected = 'bar';
        $result = $updated->foo[0];
        $this->assertEqual($expected, $result);
        $updated->foo[1] = 'baz';
        $this->assertTrue($updated->save());
        $updated = Galleries::find((string) $updated->_id);
        $expected = 'baz';
        $result = $updated->foo[1];
        $this->assertEqual($expected, $result);
    }