public function testCreateService() { // Fábrica de Componentes $factory = new AbstractModelFactory(); $result = $factory->canCreateServiceWithName($this->serviceLocator, 'model', 'Balance\\Model\\Model'); $this->assertTrue($result); // Construir Elemento $element = $factory->createServiceWithName($this->serviceLocator, 'table', 'Balance\\Model\\Model'); $this->assertInstanceOf('Balance\\Model\\Model', $element); $this->assertSame($this->form, $element->getForm()); $this->assertSame($this->inputFilter, $element->getForm()->getInputFilter()); $this->assertSame($this->formSearch, $element->getFormSearch()); $this->assertSame($this->inputFilterSearch, $element->getFormSearch()->getInputFilter()); $this->assertSame($this->persistence, $element->getPersistence()); }
public function testCreateService() { // Inicializar Localizador de Serviço $serviceLocator = new ServiceManager(); // Inicialização $form = new Form(); $inputFilter = new InputFilter(); $formSearch = new Form(); $inputFilterSearch = new InputFilter(); $persistence = $this->getMock('Balance\\Model\\Persistence\\PersistenceInterface'); // Formulário $serviceLocator->setService('Balance\\Form\\Form', $form); // Filtro de Dados $serviceLocator->setService('Balance\\InputFilter\\InputFilter', $inputFilter); // Formulário de Pesquisa $serviceLocator->setService('Balance\\Form\\Search\\Form', $formSearch); // Filtro de Dados de Pesquisa $serviceLocator->setService('Balance\\InputFilter\\Search\\InputFilter', $inputFilterSearch); // Persistência $serviceLocator->setService('Balance\\Model\\Persistence\\Model', $persistence); // Gerenciadores $serviceLocator->setService('FormElementManager', $serviceLocator)->setService('InputFilterManager', $serviceLocator); // Configurar Elemento $serviceLocator->setService('Config', array('balance_manager' => array('factories' => array('Balance\\Model\\Model' => array('factory' => 'Balance\\Model\\AbstractModelFactory', 'params' => array('form' => 'Balance\\Form\\Form', 'input_filter' => 'Balance\\InputFilter\\InputFilter', 'form_search' => 'Balance\\Form\\Search\\Form', 'input_filter_search' => 'Balance\\InputFilter\\Search\\InputFilter', 'persistence' => 'Balance\\Model\\Persistence\\Model')))))); // Fábrica de Componentes $factory = new AbstractModelFactory(); $result = $factory->canCreateServiceWithName($serviceLocator, 'model', 'Balance\\Model\\Model'); $this->assertTrue($result); // Construir Elemento $element = $factory->createServiceWithName($serviceLocator, 'table', 'Balance\\Model\\Model'); $this->assertInstanceOf('Balance\\Model\\Model', $element); $this->assertSame($form, $element->getForm()); $this->assertSame($inputFilter, $element->getForm()->getInputFilter()); $this->assertSame($formSearch, $element->getFormSearch()); $this->assertSame($inputFilterSearch, $element->getFormSearch()->getInputFilter()); $this->assertSame($persistence, $element->getPersistence()); }