lithium\tests\cases\data\entity\DocumentTest::testSetAndCoerceArray PHP Method

testSetAndCoerceArray() public method

    public function testSetAndCoerceArray()
    {
        $schema = new DocumentSchema(array('fields' => array('forceArray' => array('type' => 'string', 'array' => true), 'array' => array('type' => 'string', 'array' => true), 'dictionary' => array('type' => 'string', 'array' => true), 'numbers' => array('type' => 'integer', 'array' => true), 'objects' => array('type' => 'object', 'array' => true), 'deeply' => array('type' => 'object', 'array' => true), 'foo' => array('type' => 'string'))));
        $exists = true;
        $doc = new Document(compact('schema', 'exists'));
        $doc->array = array(1, 2, 3);
        $doc->forceArray = 'foo';
        $result = $doc->export();
        $obj = $result['update']['forceArray'];
        $this->assertInstanceOf('lithium\\data\\collection\\DocumentSet', $obj);
        $obj = $result['update']['array'];
        $this->assertInstanceOf('lithium\\data\\collection\\DocumentSet', $obj);
        $this->assertIdentical(array('foo'), $result['update']['forceArray']->data());
        $doc->forceArray = false;
        $result = $doc->export();
        $this->assertIdentical(array(false), $result['update']['forceArray']->data());
        $doc->forceArray = array();
        $result = $doc->export();
        $this->assertIdentical(array(), $result['update']['forceArray']->data());
    }