/**
  * @covers       CollectionType\Map\MapAbstract::put
  * @covers       CollectionType\Map\MapAbstract::isSynchronizedKeyAndValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testPutForOverrideValue()
 {
     $key = new \stdClass();
     $key->param = 'key';
     $oldValue = new \stdClass();
     $oldValue->param = 'oldValue';
     $this->dummyKeyType->isValid($key)->willReturn(true);
     $this->dummyValueType->isValid($oldValue)->willReturn(true);
     $this->map->put($key, $oldValue);
     $newValue = new \stdClass();
     $newValue->param = 'newValue';
     $this->dummyValueType->isValid($newValue)->willReturn(true);
     $this->map->put($key, $newValue);
     $result = $this->map->get($key);
     $this->assertEquals($newValue, $result);
 }
Example #2
0
 /**
  * @covers       CollectionType\Map\MapAbstract::put
  * @covers       CollectionType\Map\MapAbstract::isSynchronizedKeyAndValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testPutForOverrideValue()
 {
     $key = 'key';
     $valueOld = 'old';
     $this->dummyKeyType->isValid($key)->willReturn(true);
     $this->dummyValueType->isValid($valueOld)->willReturn(true);
     $this->map->put($key, $valueOld);
     $valueNew = 'new';
     $this->dummyValueType->isValid($valueNew)->willReturn(true);
     $this->map->put($key, $valueNew);
     $result = $this->map->get($key);
     $this->assertEquals($valueNew, $result);
 }
Example #3
0
 /**
  * @expectedException \CollectionType\Exception\InvalidTypeException
  *
  * @covers       CollectionType\Map\MapAbstract::getKeyOfValue
  * @covers       CollectionType\Map\MapAbstract::__construct
  * @covers       CollectionType\Common\KeyTypeTrait::validateValueForKeyType
  */
 public function testGetKeyOfValueForIncorrectValueType()
 {
     $value = 1;
     $this->dummyKeyType->isValid($value)->willReturn(false);
     $this->map->get($value);
 }