anything() public static method

Returns a PHPUnit_Framework_Constraint_IsAnything matcher object.
public static anything ( ) : PHPUnit_Framework_Constraint_IsAnything
return PHPUnit_Framework_Constraint_IsAnything
 /**
  * A test for argument swapping.
  */
 public function testArgumentSwappingOrder()
 {
     $message = '%3$swap %2$swap %1$swap';
     $formatter = $this->createMock(FormatterInterface::class);
     $formatter->expects($this->atLeastOnce())->method('has')->with('swap')->willReturn(true);
     $formatter->expects($this->atLeastOnce())->method('formatValue')->with('swap', \PHPUnit_Framework_Assert::anything())->willReturnOnConsecutiveCalls('value3', 'value2', 'value1');
     $intlFormat = new IntlFormat([$formatter]);
     $expected = 'value3 value2 value1';
     $this->assertSame($expected, $intlFormat->format($message, 'value1', 'value2', 'value3'));
 }
Esempio n. 2
0
/**
 * Returns a PHPUnit_Framework_Constraint_IsAnything matcher object.
 *
 * @return PHPUnit_Framework_Constraint_IsAnything
 * @since  Method available since Release 3.0.0
 */
function anything()
{
    return PHPUnit_Framework_Assert::anything();
}
 /**
  * @covers PHPUnit_Framework_Constraint_IsAnything
  * @covers PHPUnit_Framework_Constraint_Not
  * @covers PHPUnit_Framework_Assert::anything
  * @covers PHPUnit_Framework_Assert::logicalNot
  */
 public function testConstraintNotIsAnything()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::anything());
     $this->assertFalse($constraint->evaluate(NULL));
     $this->assertNull($constraint->fail(NULL, ''));
     $this->assertEquals('is not anything', $constraint->toString());
     $this->assertEquals(2, count($constraint));
 }
    /**
     * @covers PHPUnit_Framework_Constraint_IsAnything
     * @covers PHPUnit_Framework_Constraint_Not
     * @covers PHPUnit_Framework_Assert::anything
     * @covers PHPUnit_Framework_Assert::logicalNot
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintNotIsAnything()
    {
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::anything());
        $this->assertFalse($constraint->evaluate(null, '', true));
        $this->assertEquals('is not anything', $constraint->toString());
        $this->assertEquals(0, count($constraint));
        try {
            $constraint->evaluate(null);
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
Failed asserting that null is not anything.

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }