lithium\tests\cases\data\source\DatabaseTest::testWithOptionAndConstraintInRelation PHP Method

testWithOptionAndConstraintInRelation() public method

    public function testWithOptionAndConstraintInRelation()
    {
        $model = 'lithium\\tests\\mocks\\data\\model\\MockGallery';
        $to = 'lithium\\tests\\mocks\\data\\model\\MockImage';
        $model::bind('hasMany', 'Image', array('to' => $to, 'constraints' => array('Image.title' => (object) "'MyImage'")));
        $result = $this->_db->read(new Query(array('type' => 'read', 'model' => $model, 'with' => array('Image.ImageTag.Tag' => array('constraints' => array('Tag.name' => (object) "'MyTag'"))))));
        $expected = 'SELECT * FROM {mock_gallery} AS {Gallery} ';
        $expected .= 'LEFT JOIN {mock_image} AS {Image} ON {Image}.{title} = \'MyImage\' AND ';
        $expected .= '{Gallery}.{id} = {Image}.{gallery_id} LEFT JOIN {mock_image_tag} AS ';
        $expected .= '{ImageTag} ON {Image}.{id} = {ImageTag}.{image_id} LEFT JOIN {mock_tag} AS ';
        $expected .= '{Tag} ON {Tag}.{name} = \'MyTag\' AND {ImageTag}.{tag_id} = {Tag}.{id};';
        $this->assertEqual($expected, $this->_db->sql);
        $model::reset();
    }
DatabaseTest