本文整理汇总了PHP中PHPUnit_Framework_Assert::equalTo方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::equalTo方法的具体用法?PHP PHPUnit_Framework_Assert::equalTo怎么用?PHP PHPUnit_Framework_Assert::equalTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::equalTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($status)
{
parent::__construct();
if (!$status instanceof Constraint) {
$status = Assert::equalTo($status);
}
$this->status = $status;
}
示例2: assertEqualAggregatedRoot
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);
});
}
示例3: expects
/**
* 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));
}
示例4: __construct
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;
}
示例5: equalTo
/**
* 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);
}
示例6: testConstraintIsNotEqual2
/**
* @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();
}
示例7: testConstraintIsNotEqual2
/**
* @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();
}
示例8: iShouldSeeAVailidThumbnailForImageWithAlternativeText
/**
* 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());
}
示例9: testBodyMatchesCanFail
/**
* @expectedException \PHPUnit_Framework_AssertionFailedError
*/
public function testBodyMatchesCanFail()
{
$request = new Request('GET', '/', [], 'foobar');
$this->assertMessageBodyMatches($request, Assert::equalTo('barbaz'));
}