Jackalope\Query\QOM\QueryObjectModelFactory::andConstraint PHP Method

andConstraint() public method

{@inheritDoc}
public andConstraint ( PHPCR\Query\QOM\ConstraintInterface $constraint1, PHPCR\Query\QOM\ConstraintInterface $constraint2 )
$constraint1 PHPCR\Query\QOM\ConstraintInterface
$constraint2 PHPCR\Query\QOM\ConstraintInterface
    public function andConstraint(ConstraintInterface $constraint1, ConstraintInterface $constraint2)
    {
        return new AndConstraint($constraint1, $constraint2);
    }

Usage Example

 public function testQueryWithAndConstraint()
 {
     $this->nodeTypeManager->expects($this->once())->method('getSubtypes')->will($this->returnValue(array()));
     $query = $this->factory->createQuery($this->factory->selector('nt:unstructured', 'nt:unstructured'), $this->factory->andConstraint($this->factory->comparison($this->factory->propertyValue('nt:unstructured', 'jcr:path'), '=', $this->factory->literal('/')), $this->factory->comparison($this->factory->propertyValue('nt:unstructured', 'jcr:path'), '=', $this->factory->literal('/'))), array(), array());
     list($selectors, $selectorAliases, $sql) = $this->walker->walkQOMQuery($query);
     $this->assertEquals(sprintf("SELECT %s FROM phpcr_nodes n0 WHERE n0.workspace_name = ? AND n0.type IN ('nt:unstructured') AND (n0.path = '/' AND n0.path = '/')", $this->defaultColumns), $sql);
 }