callback() public static method

Returns a PHPUnit_Framework_Constraint_Callback matcher object.
public static callback ( callable $callback ) : PHPUnit_Framework_Constraint_Callback
$callback callable
return PHPUnit_Framework_Constraint_Callback
Ejemplo n.º 1
0
 /**
  * @covers PHPUnit_Framework_Constraint_Callback
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Specified callback <Framework_ConstraintTest::invalid callback> is not callable.
  */
 public function testConstraintCallbackInvalidArrayArgumentWithClassname()
 {
     PHPUnit_Framework_Assert::callback(array('Framework_ConstraintTest', 'invalid callback'));
 }
 /**
  * @covers PHPUnit_Framework_Constraint_Callback
  * @expectedException PHPUnit_Framework_ExpectationFailedException
  * @expectedExceptionMessage Failed asserting that 'This fails' is accepted by specified callback.
  */
 public function testConstraintCallbackFailure()
 {
     $constraint = PHPUnit_Framework_Assert::callback(function () {
         return false;
     });
     $constraint->evaluate('This fails');
 }
Ejemplo n.º 3
0
/**
 * Returns a PHPUnit_Framework_Constraint_Callback matcher object.
 *
 * @param callable $callback
 * @return PHPUnit_Framework_Constraint_Callback
 */
function callback($callback)
{
    return PHPUnit_Framework_Assert::callback($callback);
}