/** * @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); }
/** * @expectedException \CollectionType\Exception\SynchronizeException * * @covers CollectionType\Map\MapAbstract::removeValue * @covers CollectionType\Map\MapAbstract::validateValueForValueType * @covers CollectionType\Map\MapAbstract::containsValue * @covers CollectionType\Map\MapAbstract::__construct */ public function testRemoveForNotSynchronizedMap() { $key1 = '1'; $this->dummyKeyType->isValid($key1)->willReturn(true); $value1 = '1'; $this->dummyValueType->isValid($value1)->willReturn(true); $this->map->put($key1, $value1); /** fake method, only for UnitTests */ $this->map->putValue('2'); $this->map->removeValue($key1); }