/**
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::getKey
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::__construct
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testGetKeyForExistsValue()
 {
     $value = '0';
     $this->dummyType->isValid($value)->willReturn(true);
     $this->set->add($value);
     $result = $this->set->getKey($value);
     $this->assertEquals(0, $result);
 }
Beispiel #2
0
 /**
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::set
  * @covers       CollectionType\Collection\CollectionSet\LinkedSet::__construct
  * @covers       CollectionType\Collection\CollectionAbstract::contains
  * @covers       CollectionType\Common\Sequential\SequentialTrait::setValueIntoIndex
  * @covers       CollectionType\Common\Sequential\SequentialTrait::validateIndex
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testSetForBigIndexValue()
 {
     $value0 = '0';
     $this->dummyType->isValid($value0)->willReturn(true);
     $this->set->add($value0);
     $value1 = '1';
     $this->dummyType->isValid($value1)->willReturn(true);
     $this->set->add($value1);
     $value2 = '2';
     $this->dummyType->isValid($value2)->willReturn(true);
     $this->set->add($value2);
     $value3 = '3';
     $this->dummyType->isValid($value3)->willReturn(true);
     $this->set->add($value3);
     $index = 100;
     $value = 'last';
     $this->dummyType->isValid($value)->willReturn(true);
     $this->set->set($index, $value);
     $result = $this->set->getAll();
     $this->assertEquals([$value0, $value1, $value2, $value3, $value], $result);
 }
 /**
  * @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);
 }