コード例 #1
0
 public function testObjectReferences()
 {
     $object = new ComparisonClass();
     $object_reference = $object;
     $object_copy = new ComparisonClass();
     $object_assignment = $object;
     $this->assertTrue(SimpleTestCompatibility::isReference($object, $object));
     $this->assertTrue(SimpleTestCompatibility::isReference($object, $object_reference));
     $this->assertFalse(SimpleTestCompatibility::isReference($object, $object_copy));
     $this->assertTrue(SimpleTestCompatibility::isReference($object, $object_assignment));
 }
コード例 #2
0
ファイル: options_test.php プロジェクト: radicaldesigns/amp
 function testObjectReferences()
 {
     $object = new ComparisonClass();
     $object_reference =& $object;
     $object_copy = new ComparisonClass();
     $object_assignment = $object;
     $this->assertTrue(SimpleTestCompatibility::isReference($object, $object));
     $this->assertTrue(SimpleTestCompatibility::isReference($object, $object_reference));
     $this->assertFalse(SimpleTestCompatibility::isReference($object, $object_copy));
     if (version_compare(phpversion(), '5', '>=')) {
         $this->assertTrue(SimpleTestCompatibility::isReference($object, $object_assignment));
     } else {
         $this->assertFalse(SimpleTestCompatibility::isReference($object, $object_assignment));
     }
 }
コード例 #3
0
 function testAddTwice()
 {
     $parent = $this->generateSection(0);
     $section1 = $this->generateSection(0);
     $fakeSection1 = $this->generateSection(0);
     //will generate with the
     //same data as the section above
     $this->assertFalse(SimpleTestCompatibility::isReference($section1, $fakeSection1));
     //add once
     $parent->add($section1);
     $resultSection =& $parent->get($section1->getId());
     $this->assertNotNull($resultSection);
     $this->assertSectionsEqual($section1, $resultSection);
     //add again
     $result = $parent->add($section1);
     $this->assertTrue(PEAR::isError($result));
     $this->assertNotNull($parent->get($section1->getId()));
     //add other
     $result = $parent->add($fakeSection1);
     $this->assertTrue(PEAR::isError($result));
 }
コード例 #4
0
ファイル: pear_test_case.php プロジェクト: nsystem1/ZeeJong
 /**
  *    In PHP5 the identity test tests for the same
  *    object. This is a reference test in PHP4.
  *    @param $first          First object handle.
  *    @param $second         Hopefully a different handle.
  *    @param $message        Message to display.
  *    @public
  */
 function assertNotSame(&$first, &$second, $message = "%s")
 {
     $dumper =& new SimpleDumper();
     $message = sprintf($message, "[" . $dumper->describeValue($first) . "] and [" . $dumper->describeValue($second) . "] should not be the same object");
     return $this->assert(new falseExpectation(), SimpleTestCompatibility::isReference($first, $second), $message);
 }
コード例 #5
0
 /**
  *    Tests the expectation. True if it exactly
  *    references the held value.
  *    @param mixed $compare        Comparison reference.
  *    @return boolean              True if correct.
  *    @access public
  */
 function test(&$compare)
 {
     return SimpleTestCompatibility::isReference($this->_value, $compare);
 }
コード例 #6
0
ファイル: pear_test_case.php プロジェクト: guicara/simpletest
 /**
  * Inverted identity test.
  *
  * @param $first          First object handle.
  * @param $second         Hopefully a different handle.
  * @param $message        Message to display.
  */
 public function assertNotSame($first, $second, $message = '%s')
 {
     $dumper = new SimpleDumper();
     $message = sprintf($message, '[' . $dumper->describeValue($first) . '] and [' . $dumper->describeValue($second) . '] should not be the same object');
     return $this->assert(new falseExpectation(), SimpleTestCompatibility::isReference($first, $second), $message);
 }
コード例 #7
0
ファイル: spec.php プロジェクト: herlambang/h2o-php
 function be_copy_of(&$first, &$second, $message = '%s')
 {
     $dumper = new SimpleDumper();
     $message = sprintf($message, "[" . $dumper->describeValue($first) . "] and [" . $dumper->describeValue($second) . "] should not be the same object");
     return $this->runtime->assert(new FaseExpectation(), SimpleTestCompatibility::isReference($first, $second), $message);
 }