Ejemplo n.º 1
0
 /**
  * test cloning, change the original and check the clone	<br><br>
  * <code>
  * $a = new QColor(100,200,255);				<br>
  * $b = clone $a;						<br>
  * $a->setBlue(123);						<br>
  * $b->blue();	// 255						<br>
  * </code>
  */
 function testClone()
 {
     $a = new QColor(100, 200, 255);
     $b = clone $a;
     $a->setBlue(123);
     echo "\ntesting clone";
     $this->assertEquals($b->blue(), 255, "Cloning an object does not work!");
     echo " passed (check clone)";
 }
Ejemplo n.º 2
0
 /**
  * copy an object using the copy constructor and check with them changing 
  * values of the original and the copy
  */
 function testCopyConstructor()
 {
     echo "testing copy constructor ";
     $color_a = new QColor(5, 3, 7);
     $color_b = new QColor($color_a);
     $this->assertEquals(7, $color_a->blue());
     $this->assertEquals(7, $color_b->blue());
     echo "passed\n";
     echo "testing changing the value at the copy ";
     $color_b->setBlue(24);
     $this->assertEquals(7, $color_a->blue());
     $this->assertEquals(24, $color_b->blue());
     echo "passed\n";
     echo "testing destroying the original ";
     $color_a->__destruct();
     unset($color_a);
     $this->assertEquals(24, $color_b->blue());
     echo "passed\n";
 }