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