parse(); return $q; } function testFilterBasic() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' ', '' ); $q = $this->parse($xml); $this->assertEquals( array('{DAV:}foo'), $q->requestedProperties ); $this->assertEquals( array( array( 'name' => 'NICKNAME', 'test' => 'anyof', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array(), ), ), $q->filters ); $this->assertNull($q->limit); $this->assertEquals('anyof', $q->test); } function testNoFilter() { // This is non-standard, but helps working around a KDE bug $xml = array( '', '', ' ', ' ', ' ', '' ); $q = $this->parse($xml); $this->assertEquals( array('{DAV:}foo'), $q->requestedProperties ); $this->assertEquals( array(), $q->filters ); $this->assertNull($q->limit); $this->assertEquals('anyof', $q->test); } /** * @expectedException Sabre_DAV_Exception_BadRequest */ function testFilterDoubleFilter() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' ); $q = $this->parse($xml); } /** * @expectedException Sabre_DAV_Exception_BadRequest */ function testFilterCorruptTest() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' ', '' ); $q = $this->parse($xml); } function testPropFilter() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' 4', '' ); $q = $this->parse($xml); $this->assertEquals( array( array( 'name' => 'NICKNAME', 'test' => 'anyof', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array(), ), array( 'name' => 'EMAIL', 'test' => 'allof', 'is-not-defined' => false, 'param-filters' => array(), 'text-matches' => array(), ), array( 'name' => 'FN', 'test' => 'anyof', 'is-not-defined' => true, 'param-filters' => array(), 'text-matches' => array(), ), ), $q->filters ); $this->assertEquals(4,$q->limit); $this->assertEquals('allof', $q->test); } function testParamFilter() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' ); $q = $this->parse($xml); $this->assertEquals( array( array( 'name' => 'NICKNAME', 'test' => 'anyof', 'is-not-defined' => false, 'param-filters' => array( array( 'name' => 'BLA', 'is-not-defined' => false, 'text-match' => null ), array( 'name' => 'BLA2', 'is-not-defined' => true, 'text-match' => null ), ), 'text-matches' => array(), ), ), $q->filters ); } function testTextMatch() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' evert', ' evert', ' rene', ' e', ' ', ' foo', ' ', ' ', ' ', '' ); $q = $this->parse($xml); $this->assertEquals( array( array( 'name' => 'NICKNAME', 'test' => 'anyof', 'is-not-defined' => false, 'param-filters' => array( array( 'name' => 'BLA', 'is-not-defined' => false, 'text-match' => array( 'negate-condition' => false, 'collation' => 'i;unicode-casemap', 'match-type' => 'contains', 'value' => 'foo', ), ), ), 'text-matches' => array( array( 'negate-condition' => false, 'collation' => 'i;unicode-casemap', 'match-type' => 'contains', 'value' => 'evert', ), array( 'negate-condition' => false, 'collation' => 'i;octet', 'match-type' => 'contains', 'value' => 'evert', ), array( 'negate-condition' => true, 'collation' => 'i;unicode-casemap', 'match-type' => 'contains', 'value' => 'rene', ), array( 'negate-condition' => false, 'collation' => 'i;unicode-casemap', 'match-type' => 'starts-with', 'value' => 'e', ), ), ), ), $q->filters ); } /** * @expectedException Sabre_DAV_Exception_BadRequest */ function testBadTextMatch() { $xml = array( '', '', ' ', ' ', ' ', ' ', ' ', ' evert', ' ', ' ', '' ); $q = $this->parse($xml); } }