public function testGetValueHash()
 {
     $list = new HashableObjectStorage();
     $originalList = clone $list;
     $hash = $list->getValueHash();
     $this->assertInternalType('string', $hash);
     $one = new HashableObject(1);
     $two = new HashableObject(1);
     $list->attach($one);
     $list->attach($two);
     $newHash = $list->getValueHash();
     $this->assertNotEquals($hash, $newHash, 'The hash of HashableObjectStorage with different content should be different');
     $this->assertFalse($list->equals($originalList));
     $originalList = clone $list;
     $list->detach($one);
     $list->detach($two);
     $list->attach($two);
     $list->attach($one);
     $this->assertEquals($newHash, $list->getValueHash(), 'The hash of HashableObjectStorage with the same elements in different order should be the same');
     $this->assertTrue($list->equals($originalList));
     $list->detach($one);
     $list->detach($two);
     $list->attach(new HashableObject(1));
     $list->attach(new HashableObject(1));
     $this->assertEquals($newHash, $list->getValueHash(), 'The hash of HashableObjectStorage with different instances of the same elemnets should be the same');
     $this->assertTrue($list->equals($originalList));
 }
Exemplo n.º 2
0
 /**
  * @see SplObjectStorage::attach
  *
  * @param Reference $reference
  * @param mixed $data Unused in the ReferenceList class.
  */
 public function attach($reference, $data = null)
 {
     if (!$reference->isEmpty()) {
         parent::attach($reference, $data);
     }
 }