You are here

public function Framework_ConstraintTest::testConstraintCallback in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php \Framework_ConstraintTest::testConstraintCallback()

@covers PHPUnit_Framework_Constraint_Callback

File

vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php, line 1742

Class

Framework_ConstraintTest
@since Class available since Release 3.0.0

Code

public function testConstraintCallback() {
  $closureReflect = function ($parameter) {
    return $parameter;
  };
  $closureWithoutParameter = function () {
    return true;
  };
  $constraint = PHPUnit_Framework_Assert::callback($closureWithoutParameter);
  $this
    ->assertTrue($constraint
    ->evaluate('', '', true));
  $constraint = PHPUnit_Framework_Assert::callback($closureReflect);
  $this
    ->assertTrue($constraint
    ->evaluate(true, '', true));
  $this
    ->assertFalse($constraint
    ->evaluate(false, '', true));
  $callback = array(
    $this,
    'callbackReturningTrue',
  );
  $constraint = PHPUnit_Framework_Assert::callback($callback);
  $this
    ->assertTrue($constraint
    ->evaluate(false, '', true));
  $callback = array(
    'Framework_ConstraintTest',
    'staticCallbackReturningTrue',
  );
  $constraint = PHPUnit_Framework_Assert::callback($callback);
  $this
    ->assertTrue($constraint
    ->evaluate(null, '', true));
  $this
    ->assertEquals('is accepted by specified callback', $constraint
    ->toString());
}