Inheritance: extends EqualExpectation
 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));
 }
 /**
  *    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);
 }
 function testIdenticalComparisonOfMocksDoesNotCrash()
 {
     $expectation = new IdenticalExpectation(new MockDummy());
     $this->assertTrue($expectation->test(new MockDummy()));
 }
示例#4
0
 /**
  *    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
0
 /**
  *    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));
 }
示例#6
0
 function _testReallyHorribleRecursiveStructure()
 {
     $hopeful = new IdenticalExpectation(new RecursiveNasty());
     $this->assertTrue($hopeful->test(new RecursiveNasty()));
 }
 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
0
 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
0
 public function testMessage($compare)
 {
     $compare->_message = '';
     return parent::testMessage($compare);
 }
示例#10
0
 /**
  *    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);
 }