本文整理匯總了PHP中IdenticalExpectation::test方法的典型用法代碼示例。如果您正苦於以下問題:PHP IdenticalExpectation::test方法的具體用法?PHP IdenticalExpectation::test怎麽用?PHP IdenticalExpectation::test使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IdenticalExpectation
的用法示例。
在下文中一共展示了IdenticalExpectation::test方法的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: 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);
}
示例3: IdenticalExpectation
function testIdenticalComparisonOfMocksDoesNotCrash()
{
$expectation = new IdenticalExpectation(new MockDummy());
$this->assertTrue($expectation->test(new MockDummy()));
}
示例4: 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);
}
示例5: test
/**
* Tests the expectation. True if the property value is identical.
* @param object $actual Comparison object.
* @return boolean True if identical.
*/
function test($actual)
{
if (!is_object($actual)) {
return false;
}
return parent::test($this->getProperty($this->name, $actual));
}
示例6: IdenticalExpectation
function _testReallyHorribleRecursiveStructure()
{
$hopeful = new IdenticalExpectation(new RecursiveNasty());
$this->assertTrue($hopeful->test(new RecursiveNasty()));
}
示例7: IdenticalExpectation
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))));
}
示例8: SimpleDumper
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);
}
示例9: test
public function test($compare)
{
$compare->_message = '';
return parent::test($compare);
}
示例10: 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);
}