Ejemplo n.º 1
0
 public function testGetServices()
 {
     $template = new ServicesTraitTemplate();
     $services = new Services();
     Provider::setServices($services);
     $this->assertSame($services, $template->getServices());
 }
Ejemplo n.º 2
0
 public function testGetServer()
 {
     $server = new Server();
     $services = new Services();
     $services->set('Server', $server);
     Provider::setServices($services);
     $template = new ServerTraitTemplate();
     $this->assertSame($server, $template->getServer());
 }
 public function testGetControllers()
 {
     $controllers = new Controllers();
     $services = new Services();
     $services->set('Controllers', $controllers);
     Provider::setServices($services);
     $template = new ControllersTraitTemplate();
     $this->assertSame($controllers, $template->getControllers());
 }
 public function testSetPlugins()
 {
     $services = new Services();
     Provider::setServices($services);
     $plugins = new ControllerPlugins();
     $listener = new ConfigurePluginsListener();
     $listener->setPlugins($plugins);
     $this->assertSame($plugins, $services->get('ControllerPlugins'));
 }
Ejemplo n.º 5
0
 public function testGetConfig()
 {
     $config = new SystemConfig();
     $services = new Services();
     $services->set('Config', $config);
     Provider::setServices($services);
     $template = new ConfigTraitTemplate();
     $this->assertSame($config, $template->getConfig());
 }
 public function testSetResolver()
 {
     $resolver = new Resolver();
     $services = new Services();
     $services->set('ViewResolver', $resolver);
     Provider::setServices($services);
     $listener = new ConfigureResolverListener();
     $this->assertSame($resolver, $listener->getResolver());
 }
Ejemplo n.º 7
0
 public function testGetListeners()
 {
     $listeners = new Listeners();
     $services = new Services();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $template = new ListenersTraitTemplate();
     $this->assertSame($listeners, $template->getListeners());
 }
Ejemplo n.º 8
0
 public function testGetView()
 {
     $view = new View();
     $services = new Services();
     $services->set('View', $view);
     Provider::setServices($services);
     $template = new ViewTraitTemplate();
     $this->assertSame($view, $template->getView());
 }
Ejemplo n.º 9
0
 public function testGetEvents()
 {
     $events = new Events();
     $services = new Services();
     $services->set('Events', $events);
     Provider::setServices($services);
     $template = new EventsTraitTemplate();
     $this->assertSame($events, $template->getEvents());
 }
Ejemplo n.º 10
0
 public function testGetListeners()
 {
     $listeners = new Listeners();
     $services = new Services();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $trigger = new Trigger('foo', 'bar');
     $this->assertSame($listeners, $trigger->getListeners());
 }
 public function testGetPlugins()
 {
     $plugins = new ControllerPlugins();
     $services = new Services();
     $services->set('ControllerPlugins', $plugins);
     Provider::setServices($services);
     $controller = new PluginsTraitTemplate();
     $this->assertSame($plugins, $controller->getPlugins());
 }
 public function testSetStrategy()
 {
     $services = new Services();
     $listeners = new Listeners();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $strategy = new StrategyListener();
     $listener = new ConfigureStrategyListener();
     $listener->setStrategy($strategy);
     $this->assertSame($strategy, $listeners->get('Es.View.Listener.ViewStrategy'));
 }
Ejemplo n.º 13
0
 public function setUp()
 {
     if (!class_exists('Error', false)) {
         require_once 'Error.php';
     }
     require_once 'SystemTestHelper.php';
     require_once 'FakeComponent.php';
     $this->services = new Services();
     Provider::setServices($this->services);
     SystemTestHelper::resetSystem();
 }
Ejemplo n.º 14
0
 public function testInvokeOnSuccess()
 {
     $result = 'Lorem ipsum dolor sit amet';
     $engine = $this->getMock(FakeTemplateEngine::CLASS);
     $services = new Services();
     $services->set('FooTemplateEngine', $engine);
     Provider::setServices($services);
     $resolver = $this->getMock(Resolver::CLASS);
     $listener = new StrategyListener();
     $listener->setResolver($resolver);
     $listener->setConfig(['phtml' => 'FooTemplateEngine']);
     $model = new ViewModel();
     $event = new ViewEvent($model);
     $resolver->expects($this->once())->method('resolve')->will($this->returnValue($this->fooTemplate));
     $engine->expects($this->once())->method('render')->with($this->identicalTo($model))->will($this->returnValue($result));
     $listener($event);
     $this->assertSame($result, $event->getResult());
 }
 public function testMake()
 {
     $config = new SystemConfig();
     $config['error'] = ['strategies' => ['JsonErrorStrategy']];
     $services = new Services();
     $services->set('Config', $config);
     $services->set('JsonErrorStrategy', JsonErrorStrategy::CLASS);
     Provider::setServices($services);
     $listener = ErrorListenerFactory::make();
     $this->assertInstanceOf(ErrorListener::CLASS, $listener);
     $reflection = new ReflectionProperty($listener, 'strategies');
     $reflection->setAccessible(true);
     $strategies = $reflection->getValue($listener);
     $strategies->rewind();
     $this->assertSame(1, count($strategies));
     $strategy = $strategies->current();
     $this->assertInstanceOf(JsonErrorStrategy::CLASS, $strategy);
 }
Ejemplo n.º 16
0
 public function testInitOnSuccess()
 {
     $events = new Events();
     $config = new SystemConfig();
     $services = new Services();
     $listeners = new Listeners();
     $listeners->set('FakeListener', FakeListener::CLASS);
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     $components = new Components();
     $components->register(FakeComponent::CLASS);
     $components->init($services, $listeners, $events, $config);
     $component = $components->get(FakeComponent::CLASS);
     $this->assertSame($component->getServicesConfig(), $services->getRegistry());
     $this->assertSame($component->getListenersConfig(), $listeners->getRegistry());
     $this->assertSame($component->getSystemConfig(), $config->toArray());
     $event = new SystemEvent();
     $events->trigger($event);
     $this->assertTrue($event->getResult(SystemEvent::INIT));
 }
Ejemplo n.º 17
0
 public function testSetServices()
 {
     $services = new Services();
     Provider::setServices($services);
     $this->assertSame(Provider::getServices(), $services);
 }
Ejemplo n.º 18
0
 protected function buildListeners()
 {
     $listeners = new Listeners();
     $services = new Services();
     $services->set('Listeners', $listeners);
     Provider::setServices($services);
     return $listeners;
 }