/**
  * @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 testRemoveValueAllWhenMapContainsAllElementsForReturnedKeys()
 {
     $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->keys();
     $this->assertEquals([$key3], $result);
 }
Example #2
0
 /**
  * @covers       CollectionType\Map\MapAbstract::clear
  * @covers       CollectionType\Map\MapAbstract::__construct
  */
 public function testClearFilledMapForKeys()
 {
     $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->keys();
     $this->assertEquals([], $result);
 }
 /**
  * @covers       CollectionType\Map\MapAbstract::removeValue
  * @covers       CollectionType\Map\MapAbstract::validateValueForValueType
  * @covers       CollectionType\Map\MapAbstract::containsValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  */
 public function testRemoveForReturnKeys()
 {
     $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->keys();
     $this->assertEquals([$key1, $key3], $result);
 }
Example #4
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 testPutAllToFilledMapForValidateKeys()
 {
     $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->keys();
     $this->assertEquals(['0', 'base', '2', '3'], $result);
 }
Example #5
0
 /**
  * @covers       CollectionType\Map\MapAbstract::keys
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  */
 public function testKeysForFilledMap()
 {
     $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->keys();
     $this->assertEquals(['1', '2', '3'], $result);
 }
 /**
  * @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 testPutAllToFilledMapForValidateKeys()
 {
     $otherMap = new MapAbstractFake($this->dummyKeyType->reveal(), $this->dummyValueType->reveal());
     $key1 = new \stdClass();
     $key1->param = 'base';
     $value1 = new \stdClass();
     $value1->param = 'new';
     $this->dummyKeyType->isValid($key1)->willReturn(true);
     $this->dummyValueType->isValid($value1)->willReturn(true);
     $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);
     $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->keys();
     $this->assertEquals([$key0, $key1, $key2, $key3], $result);
 }