public function testSaveSettings()
 {
     $namespace = 'some_namespace';
     $storedSettingsArray = ['color' => 'red', 'interval' => 10, 'last_update' => '2014-06-01'];
     $namespaceParameters = [];
     foreach ($storedSettingsArray as $name => $value) {
         $parameter = new Parameter();
         $parameter->setName($name);
         $parameter->setValue($value);
         $parameter->setNamespace($namespace);
         $namespaceParameters[] = $parameter;
     }
     $hydrator = new Hydrator\ArraySerializable();
     $newSettingsArray = ['color' => 'black', 'interval' => 12, 'height' => 12, 'width' => 6];
     $newSettings = new ArrayObject();
     $hydrator->hydrate($newSettingsArray, $newSettings);
     $namespaceHydratorProvider = $this->getMock('HtSettingsModule\\Service\\NamespaceHydratorProviderInerface');
     $namespaceHydratorProvider->expects($this->once())->method('getHydrator')->with($namespace)->will($this->returnValue($hydrator));
     $settingsMapper = $this->getMock('HtSettingsModule\\Mapper\\SettingsMapperInterface');
     $settingsMapper->expects($this->at(0))->method('findByNamespace')->with($namespace)->will($this->returnValue($namespaceParameters));
     //var_dump($settingsMapper->findByNamespace($namespace));exit();
     $updateParameter1 = Parameter::create($namespace, 'color', 'black');
     $settingsMapper->expects($this->at(1))->method('updateParameter')->with($updateParameter1);
     $updateParameter2 = Parameter::create($namespace, 'interval', 12);
     $settingsMapper->expects($this->at(2))->method('updateParameter')->with($updateParameter2);
     $insertParameter1 = Parameter::create($namespace, 'height', 12);
     $settingsMapper->expects($this->at(3))->method('insertParameter')->with($insertParameter1);
     $insertParameter2 = Parameter::create($namespace, 'width', 6);
     $settingsMapper->expects($this->at(4))->method('insertParameter')->with($insertParameter2);
     $options = new ModuleOptions();
     $settingsService = new SettingsService($options, $settingsMapper, $namespaceHydratorProvider);
     $settingsService->save($newSettings, $namespace);
 }
 /**
  * Gets settings service
  *
  * @param  ServiceLocatorInterface $serviceLocator
  * @return SettingsService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $options = $serviceLocator->get('HtSettingsModule\\Options\\ModuleOptions');
     $settingsService = new SettingsService($options, $serviceLocator->get('HtSettingsModule_SettingsMapper'), $serviceLocator->get('HtSettingsModule\\Service\\NamespaceHydratorProvider'));
     if ($options->getCacheOptions()->isEnabled()) {
         $settingsService->setCacheManager($serviceLocator->get('HtSettingsModule\\Service\\CacheManager'));
     }
     return $settingsService;
 }