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)); }
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)); } }
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)); }
/** * 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); }
/** * 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); }
/** * 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); }
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); }