Returns a PHPUnit_Framework_Constraint_IsEqual matcher object.
public static equalTo ( mixed $value, float $delta, integer $maxDepth = 10, boolean $canonicalize = false, boolean $ignoreCase = false ) : PHPUnit_Framework_Constraint_IsEqual | ||
$value | mixed | |
$delta | float | |
$maxDepth | integer | |
$canonicalize | boolean | |
$ignoreCase | boolean | |
return | PHPUnit_Framework_Constraint_IsEqual |
public function __construct($status) { parent::__construct(); if (!$status instanceof Constraint) { $status = Assert::equalTo($status); } $this->status = $status; }
protected function assertEqualAggregatedRoot(RecordsMessages $expected) { return m::on(function (RecordsMessages $actual) use($expected) { $actual = clone $actual; $actual->eraseMessages(); return Assertions::equalTo($expected)->evaluate($actual, '', true); }); }
/** * Generates a mock object on the singleton Someclass util object. * * @param array $name * @return void */ public static function expects($name, $replace) { // Mock the object $mock = \PHPUnit_Framework_MockObject_Generator::getMock('Someclass', array('hello'), array(), '', false); // Replace protected self reference with mock object $ref = new \ReflectionProperty('Someclass', 'self'); $ref->setAccessible(true); $ref->setValue(null, $mock); // Set expectations and return values $mock->expects(new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(1))->method('hello')->with(\PHPUnit_Framework_Assert::equalTo($name))->will(new \PHPUnit_Framework_MockObject_Stub_Return($replace)); }
public function __construct($name, $constraint = null) { parent::__construct(); if ($constraint === null) { $constraint = Assert::logicalNot(Assert::isEmpty()); } elseif (!$constraint instanceof Constraint) { $constraint = Assert::equalTo($constraint); } $this->name = strtolower($name); $this->constraint = $constraint; }
/** * Returns a PHPUnit_Framework_Constraint_IsEqual matcher object. * * @param mixed $value * @param float $delta * @param integer $maxDepth * @param boolean $canonicalize * @param boolean $ignoreCase * @return PHPUnit_Framework_Constraint_IsEqual * @since Method available since Release 3.0.0 */ function equalTo($value, $delta = 0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE) { return PHPUnit_Framework_Assert::equalTo($value, $delta, $maxDepth, $canonicalize, $ignoreCase); }
/** * @covers PHPUnit_Framework_Constraint_IsEqual * @covers PHPUnit_Framework_Constraint_Not * @covers PHPUnit_Framework_Assert::equalTo * @covers PHPUnit_Framework_Assert::logicalNot */ public function testConstraintIsNotEqual2() { $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::equalTo(1)); try { $constraint->fail(1, 'custom message', TRUE); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals("custom message\nFailed asserting that <integer:1> is not equal to <integer:1>.", $e->getDescription()); return; } $this->fail(); }
/** * @covers PHPUnit_Framework_Constraint_IsEqual * @covers PHPUnit_Framework_Constraint_Not * @covers PHPUnit_Framework_Assert::equalTo * @covers PHPUnit_Framework_Assert::logicalNot * @covers PHPUnit_Framework_TestFailure::exceptionToString */ public function testConstraintIsNotEqual2() { $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::equalTo(1)); try { $constraint->evaluate(1, 'custom message'); } catch (PHPUnit_Framework_ExpectationFailedException $e) { $this->assertEquals(<<<EOF custom message Failed asserting that 1 is not equal to 1. EOF , PHPUnit_Framework_TestFailure::exceptionToString($e)); return; } $this->fail(); }
/** * Test if image is present on page and is downloadable (`img` tag must contain `alt` attribute). * @Then I (should) see a valid thumbnail for image with alternative text :imageAlternativeText */ public function iShouldSeeAVailidThumbnailForImageWithAlternativeText($imageAlternativeText) { $image = $this->getXpath()->findXpath("//img[contains(@alt, '" . $imageAlternativeText . "')]"); if (count($image) == 0) { throw new \Exception(sprintf('Image with an alternative text `%s` was not found', $imageAlternativeText)); } $file = $image[0]->getAttribute('src'); $client = new \Guzzle\Http\Client(); $request = $client->get($this->locatePath($file)); $response = $request->send(); Assertion::equalTo($response->getStatusCode(), 200); Assertion::assertRegexp('/image\\/(.*)/', $response->getHeader('content-type')->__toString()); }
/** * @expectedException \PHPUnit_Framework_AssertionFailedError */ public function testBodyMatchesCanFail() { $request = new Request('GET', '/', [], 'foobar'); $this->assertMessageBodyMatches($request, Assert::equalTo('barbaz')); }