本文整理匯總了PHP中IdenticalExpectation類的典型用法代碼示例。如果您正苦於以下問題:PHP IdenticalExpectation類的具體用法?PHP IdenticalExpectation怎麽用?PHP IdenticalExpectation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IdenticalExpectation類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assertEltByIdHasAttrOfValue
function assertEltByIdHasAttrOfValue($eltId, $attrName, $attrValueExpected = true)
{
$matches = array();
$haystack = $this->getBrowser()->getContent();
// preg_match('/(\<[^\>]\s+id\s*=\s*"'.$eltId.'"\s+[^\>]*\>)/',$this->getBrowser()->getContent(),$matches);
preg_match('/(\\<[^\\>]*\\s+id\\s*=\\s*"' . $eltId . '"\\s*[^\\>]*\\>)/', $haystack, $matches);
// echo $matches[1];
if (!$this->assertTrue(isset($matches[1]), "Element with id [{$eltId}] should exist")) {
return false;
}
$haystack = $matches[1];
$matches = array();
preg_match('/\\s+(' . $attrName . ')\\s*=\\s*"([^"]*)"/', $haystack, $matches);
if (!$this->assertTrue(isset($matches[1]) && isset($matches[2]), "Element with id [{$eltId}] should have attribute of [{$attrName}]")) {
return false;
}
if ($attrValueExpected === true) {
return true;
}
if (!SimpleExpectation::isExpectation($attrValueExpected)) {
$attrValueExpected = new IdenticalExpectation($attrValueExpected);
}
$haystack = $matches[2];
if ($attrValueExpected->test($haystack)) {
return true;
}
return $this->assert($attrValueExpected, $haystack, "Element with id [{$eltId}] attribute [{$attrName}] value does not match- " . $attrValueExpected->testMessage($haystack));
}
示例2: testIdenticalComparisonOfMocksDoesNotCrash
function testIdenticalComparisonOfMocksDoesNotCrash()
{
$expectation = new IdenticalExpectation(new MockDummy());
$this->assertTrue($expectation->test(new MockDummy()));
}
示例3: assertClone
/**
* Will trigger a pass if both parameters refer
* to different objects. Fail otherwise. The objects
* have to be identical though.
* @param mixed $first Object reference to check.
* @param mixed $second Hopefully not the same object.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assertClone($first, $second, $message = '%s')
{
$dumper = new SimpleDumper();
$message = sprintf($message, '[' . $dumper->describeValue($first) . '] and [' . $dumper->describeValue($second) . '] should not be the same object');
$identical = new IdenticalExpectation($first);
return $this->assertTrue($identical->test($second) && !($first === $second), $message);
}
示例4: _testReallyHorribleRecursiveStructure
function _testReallyHorribleRecursiveStructure()
{
$hopeful = new IdenticalExpectation(new RecursiveNasty());
$this->assertTrue($hopeful->test(new RecursiveNasty()));
}
示例5: testCanComparePrivateMembersOfObjectsWherePrivateMemberOfBaseClassIsObscured
function testCanComparePrivateMembersOfObjectsWherePrivateMemberOfBaseClassIsObscured()
{
$expectFive = new IdenticalExpectation(array(new DerivedOpaqueContainer(1, 2)));
$this->assertTrue($expectFive->test(array(new DerivedOpaqueContainer(1, 2))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0, 2))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(0, 9))));
$this->assertFalse($expectFive->test(array(new DerivedOpaqueContainer(1, 0))));
}
示例6: be_clone_of
function be_clone_of(&$first, &$second, $message = '%s')
{
$dumper = new SimpleDumper();
$message = sprintf($message, '[' . $dumper->describeValue($first) . '] and [' . $dumper->describeValue($second) . '] should not be the same object');
$identical = new IdenticalExpectation($first);
return $this->runtime->assert(new TrueExpectation(), $identical->test($second) && !SimpleTestCompatibility::isReference($first, $second), $message);
}
示例7: assertClone
/**
* Will trigger a pass if both parameters refer
* to different objects. Fail otherwise. The objects
* have to be identical though.
* @param mixed $first Object reference to check.
* @param mixed $second Hopefully not the same object.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assertClone(&$first, &$second, $message = "%s")
{
$dumper = new SimpleDumper();
$message = sprintf($message, "[" . $dumper->describeValue($first) . "] and [" . $dumper->describeValue($second) . "] should not be the same object");
$identical = new IdenticalExpectation($first);
return $this->assertTrue($identical->test($second) && !SimpleTestCompatibility::isReference($first, $second), $message);
}
示例8: test
/**
* Tests the expectation. True if it differs from the
* held value.
* @param mixed $compare Comparison value.
* @return boolean True if correct.
* @access public
*/
function test($compare)
{
return !parent::test($compare);
}
示例9: testMessage
/**
* Returns a human readable test message.
* @param mixed $compare Comparison value.
* @return string Description of success
* or failure.
*/
function testMessage($actual)
{
return parent::testMessage($this->getProperty($this->name, $actual));
}
示例10: testMessage
public function testMessage($compare)
{
$compare->_message = '';
return parent::testMessage($compare);
}