public function testSetCacheOptions() { $options = new ModuleOptions(); $cacheOptions = new CacheOptions(); $options->setCacheOptions($cacheOptions); $this->assertEquals($cacheOptions, $options->getCacheOptions()); $options->setCacheOptions(['enabled' => true]); $this->assertTrue(true, $options->getCacheOptions()->isEnabled()); $this->setExpectedException('HtSettingsModule\\Exception\\InvalidArgumentException'); $options->setCacheOptions(new \ArrayObject()); }
public function testUpdateParameter() { $options = new ModuleOptions(); $settingsMapper = $this->getMock('HtSettingsModule\\Mapper\\SettingsMapperInterface'); $settingsService = new SettingsService($options, $settingsMapper, $this->getMock('HtSettingsModule\\Service\\NamespaceHydratorProviderInerface')); $namespace = 'network_settings'; $name = 'ip_address'; $value = '192.168.1.1'; $newValue = '192.168.10.1'; $orginalParameter = new Parameter(); $orginalParameter->setNamespace($namespace); $orginalParameter->setName($name); $orginalParameter->setValue($value); $newParameter = clone $orginalParameter; $newParameter->setValue($newValue); $options->getCacheOptions()->setEnabled(false); $settingsMapper->expects($this->once())->method('findParameter')->with($namespace, $name)->will($this->returnValue($orginalParameter)); $settingsMapper->expects($this->once())->method('updateParameter')->with($newParameter); $settingsService->saveParameter($namespace, $name, $newValue); }