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

testRenderArrayJoinConstraintComplexArray() public method

Tests that complex model constraints with custom operators render correct constraint strings.
    public function testRenderArrayJoinConstraintComplexArray()
    {
        $model = 'lithium\\tests\\mocks\\data\\model\\MockQueryComment';
        $query = new Query(compact('model') + array('type' => 'read', 'source' => 'comments', 'alias' => 'Comments', 'conditions' => array('Comment.id' => 1), 'joins' => array(array('mode' => 'LEFT', 'source' => 'posts', 'alias' => 'Post', 'constraints' => array("Comment.post_id" => array('<=' => 'Post.id', '>=' => 'Post.id'))))));
        $expected = "SELECT * FROM {comments} AS {Comments} LEFT JOIN {posts} AS {Post} ON ";
        $expected .= "({Comment}.{post_id} <= {Post}.{id} AND {Comment}.{post_id} >= {Post}.{id}) ";
        $expected .= "WHERE {Comment}.{id} = 1;";
        $result = $this->_db->renderCommand($query);
        $this->assertEqual($expected, $result);
        $query = new Query(compact('model') + array('type' => 'read', 'source' => 'comments', 'alias' => 'Comments', 'joins' => array(array('mode' => 'LEFT', 'source' => 'posts', 'alias' => 'Post', 'constraints' => array('Comment.post_id' => array('=>' => 'Post.id'))))));
        $db = $this->_db;
        $this->assertException("Unsupported operator `=>`.", function () use($db, $query) {
            $db->renderCommand($query);
        });
    }
DatabaseTest