/** * @covers CollectionType\Map\MapAbstract::containsKey * @covers CollectionType\Map\MapAbstract::put * @covers CollectionType\Map\MapAbstract::__construct * @covers CollectionType\Common\KeyTypeTrait::validateValueForKeyType */ public function testContainsKeyForCorrectKeyTypeAndNotAvailableKey() { $key = new \stdClass(); $key->param = 'key'; $value = new \stdClass(); $value->param = 'value'; $this->dummyKeyType->isValid($key)->willReturn(true); $this->dummyValueType->isValid($value)->willReturn(true); $this->map->put($key, $value); $notExists = new \stdClass(); $notExists->param = 'notExists'; $this->dummyKeyType->isValid($notExists)->willReturn(true); $result = $this->map->containsKey($notExists); $this->assertFalse($result); }
/** * @expectedException \CollectionType\Exception\InvalidTypeException * * @covers CollectionType\Map\MapAbstract::containsKey * @covers CollectionType\Map\MapAbstract::put * @covers CollectionType\Map\MapAbstract::__construct * @covers CollectionType\Common\KeyTypeTrait::validateValueForKeyType */ public function testContainsKeyForIncorrectKeyType() { $key = 'key'; $value = 'value'; $this->dummyKeyType->isValid($key)->willReturn(true); $this->dummyValueType->isValid($value)->willReturn(true); $this->map->put($key, $value); $incorrect = 1; $this->dummyKeyType->isValid($incorrect)->willReturn(false); $this->map->containsKey($incorrect); }