public function testIndex() { // Inicialização $element = new Configs(); // Localizador de Serviços $serviceLocator = new ServiceManager(); $element->setServiceLocator($serviceLocator); // Configurar Parâmetros de Despacho $element->getEvent()->setRouteMatch(new Router\RouteMatch(['action' => 'index'])); // Execução $result = $element->dispatch(new Http\PhpEnvironment\Request()); // Verificações $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $result); $this->assertRegexp('/^\\$.application.setConfigs/', $result->serialize()); }
public function testModulesAndSaveWithErrors() { // Inicialização $element = new Configs(); // Localizador de Serviços $serviceLocator = new ServiceManager(); $element->setServiceLocator($serviceLocator); // Camada de Modelo $mModules = $this->getMock('Balance\\Model\\Modules'); // Salvar com Dados Corretos $mModules->expects($this->once())->method('save')->will($this->throwException(new ModelException())); // Serviço $serviceLocator->setService('Balance\\Model\\Modules', $mModules); // Configurar Parâmetros de Despacho $element->getEvent()->setRouteMatch(new Router\RouteMatch(['action' => 'modules'])); // Requisição $request = (new Http\PhpEnvironment\Request())->setMethod('POST'); // Execução $element->dispatch($request); }