Changeset 20500
- Timestamp:
- 07/26/09 01:44:30 (4 years ago)
- Files:
-
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterArrayTest.php (modified) (3 diffs)
- tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterObjectTest.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php
r20499 r20500 27 27 public function assertEquals($expected, $strict = false) 28 28 { 29 if ( get_class($expected) !== 'LimeTesterArray')29 if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) 30 30 { 31 31 throw new LimeNotEqualException($this, $expected); … … 61 61 public function assertNotEquals($expected, $strict = false) 62 62 { 63 if ( get_class($expected) !== 'LimeTesterArray')63 if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()) 64 64 { 65 65 return; tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php
r20499 r20500 12 12 class LimeTesterObject extends LimeTesterArray 13 13 { 14 private 15 $object = null; 16 14 17 public function __construct($object) 15 18 { 19 $this->object = $object; 16 20 $this->type = get_class($object); 17 21 … … 45 49 return 'object('.$this->type.')'; 46 50 } 51 52 public function assertEquals($expected, $strict = false) 53 { 54 parent::assertEquals($expected, $strict); 55 56 // still no exceptions, so properties are the same 57 if ($strict && $this->object !== $expected->object) 58 { 59 throw new LimeNotEqualException($this, $expected); 60 } 61 } 62 63 public function assertNotEquals($expected, $strict = false) 64 { 65 try 66 { 67 parent::assertNotEquals($expected, $strict); 68 } 69 catch (LimeNotEqualException $e) 70 { 71 if (!$strict || $this->object === $expected->object) 72 { 73 throw $e; 74 } 75 } 76 } 47 77 } tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterArrayTest.php
r20499 r20500 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 5);16 $t = new LimeTest(6); 17 17 18 18 … … 22 22 $actual = new LimeTesterArray(array()); 23 23 $expected = new LimeTesterScalar(false); 24 // test 25 $t->expect('LimeNotEqualException'); 26 $actual->assertEquals($expected); 27 28 29 // @Test: assertEquals() throws an exception if the other tester is a LimeTesterObject 30 31 // fixtures 32 $actual = new LimeTesterArray(array()); 33 $expected = new LimeTesterObject(new stdClass()); 24 34 // test 25 35 $t->expect('LimeNotEqualException'); … … 75 85 76 86 87 // @Test: assertNotEquals() throws no exception if the other tester is a LimeTesterObject 88 89 // fixtures 90 $actual = new LimeTesterArray(array()); 91 $expected = new LimeTesterObject(new stdClass()); 92 // test 93 $actual->assertNotEquals($expected); 94 95 77 96 // @Test: assertNotEquals() throws an exception if the arrays are equal 78 97