1<?php 2 3class Horde_Kolab_Server_Constraint_Restrictedkolabusers extends PHPUnit_Framework_Constraint 4{ 5 public function evaluate($other, $description = '', $returnResult = FALSE) 6 { 7 if ($other instanceof Horde_Kolab_Server_Query_Element_Interface) { 8 if ($other instanceof Horde_Kolab_Server_Query_Element_Group) { 9 $elements = $other->getElements(); 10 foreach ($elements as $element) { 11 if ($this->evaluate($element)) { 12 return true; 13 } 14 } 15 return true; 16 } else { 17 if ($other->getName() == 'objectClass' 18 && $other->getValue() == Horde_Kolab_Server_Object_Kolabinetorgperson::OBJECTCLASS_KOLABINETORGPERSON) { 19 return true; 20 } else { 21 return false; 22 } 23 } 24 } else { 25 return false; 26 } 27 } 28 29 public function fail($other, $description, \SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) 30 { 31 throw new PHPUnit_Framework_ExpectationFailedException( 32 sprintf( 33 '%sFailed asserting that %s contains a query element that restricts the search to Kolab users', 34 35 !empty($description) ? $description . "\n" : '', 36 PHPUnit_Util_Type::toString($other, TRUE) 37 ), 38 NULL 39 ); 40 } 41 42 public function toString() 43 { 44 return 'contains a query element that restricts the search to Kolab users'; 45 } 46} 47