コード例 #1
0
 /**
  * @covers       CollectionType\Map\MapAbstract::removeValueAll
  * @covers       CollectionType\Map\MapAbstract::containsAll
  * @covers       CollectionType\Map\MapAbstract::validateKeyType
  * @covers       CollectionType\Map\MapAbstract::validateValueType
  * @covers       CollectionType\Map\MapAbstract::__construct
  */
 public function testRemoveValueAllWhenMapContainsAllElementsForReturnedValues()
 {
     $otherMap = new MapAbstractFake($this->dummyKeyType->reveal(), $this->dummyValueType->reveal());
     $key1 = new \stdClass();
     $key1->param = 'key1';
     $value1 = new \stdClass();
     $value1->param = 'value1';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $otherMap->put($key1, $value1);
     $key2 = new \stdClass();
     $key2->param = 'key2';
     $value2 = new \stdClass();
     $value2->param = 'value2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $this->map->put($key2, $value2);
     $otherMap->put($key2, $value2);
     $key3 = new \stdClass();
     $key3->param = 'key3';
     $value3 = new \stdClass();
     $value3->param = 'value3';
     $this->dummyKeyType->isValid($key3)->willReturn(true);
     $this->dummyValueType->isValid($value3)->willReturn(true);
     $this->map->put($key3, $value3);
     $this->map->removeValueAll($otherMap);
     $result = $this->map->values();
     $this->assertEquals([$value3], $result);
 }
コード例 #2
0
 /**
  * @covers       CollectionType\Map\MapAbstract::removeValue
  * @covers       CollectionType\Map\MapAbstract::validateValueForValueType
  * @covers       CollectionType\Map\MapAbstract::containsValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  */
 public function testRemoveForReturnValues()
 {
     $key1 = new \stdClass();
     $key1->param = 'key1';
     $value1 = new \stdClass();
     $value1->param = 'value1';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $key2 = new \stdClass();
     $key2->param = 'key2';
     $value2 = new \stdClass();
     $value2->param = 'value2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $this->map->put($key2, $value2);
     $key3 = new \stdClass();
     $key3->param = 'key3';
     $value3 = new \stdClass();
     $value3->param = 'value3';
     $this->dummyKeyType->isValid($key3)->willReturn(true);
     $this->dummyValueType->isValid($value3)->willReturn(true);
     $this->map->put($key3, $value3);
     $this->map->removeValue($value2);
     $result = $this->map->values();
     $this->assertEquals([$value1, $value3], $result);
 }
コード例 #3
0
 /**
  * @covers       CollectionType\Map\MapAbstract::putAll
  * @covers       CollectionType\Map\MapAbstract::isSynchronizedKeyAndValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  * @covers       CollectionType\Common\KeyTypeTrait::getKeyType
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testPutAllToFilledMapForValidateValues()
 {
     $otherMap = new MapAbstractFake($this->dummyKeyType->reveal(), $this->dummyValueType->reveal());
     $key1 = 'base';
     $value1 = 'new';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $otherMap->put($key1, $value1);
     $key2 = '2';
     $value2 = '2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $otherMap->put($key2, $value2);
     $key3 = '3';
     $value3 = '3';
     $this->dummyKeyType->isValid($key3)->willReturn(true);
     $this->dummyValueType->isValid($value3)->willReturn(true);
     $otherMap->put($key3, $value3);
     $key0 = '0';
     $value0 = '0';
     $this->dummyKeyType->isValid($key0)->willReturn(true);
     $this->dummyValueType->isValid($value0)->willReturn(true);
     $this->map->put($key0, $value0);
     $key1 = 'base';
     $value1 = 'old';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $this->map->putAll($otherMap);
     $result = $this->map->values();
     $this->assertEquals(['0', 'new', '2', '3'], $result);
 }
コード例 #4
0
 /**
  * @covers       CollectionType\Map\MapAbstract::values
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  */
 public function testValuesForFilledMap()
 {
     $key1 = '1';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $value1 = '1';
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $key2 = '2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $value2 = '2';
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $this->map->put($key2, $value2);
     $key3 = '3';
     $this->dummyKeyType->isValid($key3)->willReturn(true);
     $value3 = '3';
     $this->dummyValueType->isValid($value3)->willReturn(true);
     $this->map->put($key3, $value3);
     $result = $this->map->values();
     $this->assertEquals(['1', '2', '3'], $result);
 }
コード例 #5
0
 /**
  * @covers       CollectionType\Map\MapAbstract::clear
  * @covers       CollectionType\Map\MapAbstract::__construct
  */
 public function testClearFilledMapForValues()
 {
     $key1 = '1';
     $value1 = '1';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $key2 = '2';
     $value2 = '2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $this->map->put($key1, $value1);
     $this->map->clear();
     $result = $this->map->values();
     $this->assertEquals([], $result);
 }
コード例 #6
0
 /**
  * @covers       CollectionType\Map\MapAbstract::putAll
  * @covers       CollectionType\Map\MapAbstract::isSynchronizedKeyAndValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  * @covers       CollectionType\Common\KeyTypeTrait::getKeyType
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testPutAllToFilledMapForValidateValues()
 {
     $otherMap = new MapAbstractFake($this->dummyKeyType->reveal(), $this->dummyValueType->reveal());
     $key1 = new \stdClass();
     $key1->param = 'base';
     $valueNew = new \stdClass();
     $valueNew->param = 'new';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($valueNew)->willReturn(true);
     $otherMap->put($key1, $valueNew);
     $key2 = new \stdClass();
     $key2->param = 'key2';
     $value2 = new \stdClass();
     $value2->param = 'value2';
     $this->dummyKeyType->isValid($key2)->willReturn(true);
     $this->dummyValueType->isValid($value2)->willReturn(true);
     $otherMap->put($key2, $value2);
     $key3 = new \stdClass();
     $key3->param = 'key3';
     $value3 = new \stdClass();
     $value3->param = 'value3';
     $this->dummyKeyType->isValid($key3)->willReturn(true);
     $this->dummyValueType->isValid($value3)->willReturn(true);
     $otherMap->put($key3, $value3);
     $key0 = new \stdClass();
     $key0->param = 'key0';
     $value0 = new \stdClass();
     $value0->param = 'value0';
     $this->dummyKeyType->isValid($key0)->willReturn(true);
     $this->dummyValueType->isValid($value0)->willReturn(true);
     $this->map->put($key0, $value0);
     $key1 = new \stdClass();
     $key1->param = 'base';
     $value1 = new \stdClass();
     $value1->param = 'old';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $this->map->put($key1, $value1);
     $this->map->putAll($otherMap);
     $result = $this->map->values();
     $this->assertEquals([$value0, $valueNew, $value2, $value3], $result);
 }