/** * Registers an option. * * @param string|\Widop\Twitter\Options\OptionInterface $option The option. * @param string $type The option type. * * @throws \InvalidArgumentException If the option is not valid. * * @return \Widop\Twitter\Options\OptionBag The option bag. */ public function register($option, $type = OptionInterface::TYPE_GET) { if (is_string($option)) { $option = $this->factory->create($option, $type); } if (!$option instanceof OptionInterface) { throw new \InvalidArgumentException('The option should be either a string or a "Widop\\Twitter\\Options\\OptionInterface".'); } $this->options[$option->getName()] = $option; return $this; }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The option "foo" does not exist. */ public function testCreateWithUnknownOption() { $this->optionFactory->create('foo'); }