示例#1
0
 /**
  * @covers  CollectionType\Collection\CollectionSet\TreeSet::addAll
  * @covers  CollectionType\Collection\CollectionSet\TreeSet::sort
  * @covers  CollectionType\Collection\CollectionSet\TreeSet::__construct
  * @covers  CollectionType\Collection\CollectionSet\SetAbstract::addAll
  * @covers  CollectionType\Collection\CollectionSet\SetAbstract::contains
  * @covers  CollectionType\Collection\CollectionSet\SetAbstract::validateValueForValueType
  */
 public function testAddAllForFilledBaseSet()
 {
     $value8 = '8';
     $this->dummyType->isValid($value8)->willReturn(true);
     $this->set->add($value8);
     $value7 = '7';
     $this->dummyType->isValid($value7)->willReturn(true);
     $this->set->add($value7);
     $otherSet = new HashSet($this->dummyType->reveal());
     $value3 = '3';
     $this->dummyType->isValid($value3)->willReturn(true);
     $otherSet->add($value3);
     $value2 = '2';
     $this->dummyType->isValid($value2)->willReturn(true);
     $otherSet->add($value2);
     $value4 = '4';
     $this->dummyType->isValid($value4)->willReturn(true);
     $otherSet->add($value4);
     $value1 = '1';
     $this->dummyType->isValid($value1)->willReturn(true);
     $otherSet->add($value1);
     $this->set->addAll($otherSet);
     $result = $this->set->getAll();
     $this->assertEquals([$value1, $value2, $value3, $value4, $value7, $value8], $result);
 }
示例#2
0
 /**
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::setAll
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::__construct
  * @covers       CollectionType\Common\Sequential\SequentialTrait::setCollectionIntoIndex
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueType
  * @covers       CollectionType\Common\ValueTypeTrait::equalValueType
  */
 public function testSetForFilledSetForRepeatValues()
 {
     $value0 = '0';
     $this->dummyType->isValid($value0)->willReturn(true);
     $this->set->add($value0);
     $value1 = 'old value index: 1 -> 2';
     $this->dummyType->isValid($value1)->willReturn(true);
     $this->set->add($value1);
     $value2 = 'old value index: 2 -> 3';
     $this->dummyType->isValid($value2)->willReturn(true);
     $this->set->add($value2);
     $value3 = 'old value index: 3 -> 4';
     $this->dummyType->isValid($value3)->willReturn(true);
     $this->set->add($value3);
     $otherSet = new HashSet($this->dummyType->reveal());
     $valueN1 = 'new value index: 1 -> 1';
     $this->dummyType->isValid($valueN1)->willReturn(true);
     $otherSet->add($valueN1);
     $otherSet->add($value2);
     $this->set->setAll(1, $otherSet);
     $result = $this->set->getAll();
     $this->assertEquals([$value0, $valueN1, $value1, $value2, $value3], $result);
 }