1<?php 2 3class Horde_Kolab_Server_Constraint_Searchuid 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() == 'uid') { 18 return true; 19 } else { 20 return false; 21 } 22 } 23 } else { 24 return false; 25 } 26 } 27 28 public function fail($other, $description, \SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) 29 { 30 throw new PHPUnit_Framework_ExpectationFailedException( 31 sprintf( 32 '%sFailed asserting that %s contains a query element that is searching by uid', 33 34 !empty($description) ? $description . "\n" : '', 35 PHPUnit_Util_Type::toString($other, TRUE) 36 ), 37 NULL 38 ); 39 } 40 41 public function toString() 42 { 43 return 'contains a query element that is searching by uid'; 44 } 45} 46