public function testStatements()
 {
     //simple query, should be sql
     $this->qb->from($this->qf->selector('nt:base', "nt:base"));
     $this->assertSame('sql', $this->qb->getQuery()->getLanguage());
     $this->assertSame("SELECT s FROM nt:base", $this->qb->getQuery()->getStatement());
     //localname is not supported by sql1
     $this->qb->where($this->qf->comparison($this->qf->nodeLocalName('nt:base'), Constants::JCR_OPERATOR_EQUAL_TO, $this->qf->literal('foo')));
     $this->assertSame('JCR-SQL2', $this->qb->getQuery()->getLanguage());
     $this->assertSame("SELECT * FROM [nt:base] WHERE LOCALNAME(nt:base) = 'foo'", $this->qb->getQuery()->getStatement());
     //descendantNode is supported by sql1
     $this->qb->where($this->qf->descendantNode('nt:base', "/foo"));
     //$this->assertSame('sql', $this->qb->getQuery()->getLanguage());
     $this->assertSame("SELECT s FROM nt:base WHERE jcr:path LIKE '/foo[%]/%'", $this->qb->getQuery()->getStatement());
     //joins are not supported by sql1
     $this->qb->join($this->qf->selector('nt:unstructured', "nt:unstructured"), $this->qf->equiJoinCondition("nt:base", "data", "nt:unstructured", "data"));
     $this->assertSame('JCR-SQL2', $this->qb->getQuery()->getLanguage());
     $this->assertSame("SELECT * FROM [nt:base] INNER JOIN [nt:unstructured] ON [nt:base].data=[nt:unstructured].data WHERE ISDESCENDANTNODE([nt:base], [/foo])", $this->qb->getQuery()->getStatement());
 }
 public function testJoin()
 {
     $source1 = $this->getMock('PHPCR\\Query\\QOM\\SourceInterface', array(), array());
     $source2 = $this->getMock('PHPCR\\Query\\QOM\\SourceInterface', array(), array());
     $joinCondition = $this->getMock('PHPCR\\Query\\QOM\\SameNodeJoinConditionInterface', array(), array());
     $this->qf->expects($this->once())->method('join')->with($source1, $source2, $this->equalTo(\PHPCR\Query\QOM\QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_INNER), $joinCondition);
     $qb = new QueryBuilder($this->qf);
     $qb->from($source1);
     $qb->join($source2, $joinCondition);
 }
示例#3
0
 public function testJoin()
 {
     $source1 = $this->getMock('PHPCR\\Query\\QOM\\SourceInterface', array(), array());
     $source2 = $this->getMock('PHPCR\\Query\\QOM\\SourceInterface', array(), array());
     $joinCondition = $this->getMock('PHPCR\\Query\\QOM\\SameNodeJoinConditionInterface', array(), array());
     $qb = new QueryBuilder($this->qf);
     $qb->from($source1);
     $qb->join($source2, $joinCondition);
 }