Development

Changeset 20500

You must first sign up to be able to contribute.

Changeset 20500

Show
Ignore:
Timestamp:
07/26/09 01:44:30 (5 years ago)
Author:
bschussek
Message:

Fixed bugs in LimeTesterObject? and LimeTesterArray?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterArray.php

    r20499 r20500  
    2727  public function assertEquals($expected, $strict = false) 
    2828  { 
    29     if (get_class($expected) !== 'LimeTesterArray'
     29    if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()
    3030    { 
    3131      throw new LimeNotEqualException($this, $expected); 
     
    6161  public function assertNotEquals($expected, $strict = false) 
    6262  { 
    63     if (get_class($expected) !== 'LimeTesterArray'
     63    if (!$expected instanceof LimeTesterArray || $this->getType() !== $expected->getType()
    6464    { 
    6565      return; 
  • tools/lime/branches/2.0-experimental/lib/tester/LimeTesterObject.php

    r20499 r20500  
    1212class LimeTesterObject extends LimeTesterArray 
    1313{ 
     14  private 
     15    $object = null; 
     16 
    1417  public function __construct($object) 
    1518  { 
     19    $this->object = $object; 
    1620    $this->type = get_class($object); 
    1721 
     
    4549    return 'object('.$this->type.')'; 
    4650  } 
     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  } 
    4777} 
  • tools/lime/branches/2.0-experimental/test/unit/tester/LimeTesterArrayTest.php

    r20499 r20500  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(5); 
     16$t = new LimeTest(6); 
    1717 
    1818 
     
    2222  $actual = new LimeTesterArray(array()); 
    2323  $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()); 
    2434  // test 
    2535  $t->expect('LimeNotEqualException'); 
     
    7585 
    7686 
     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 
    7796// @Test: assertNotEquals() throws an exception if the arrays are equal 
    7897