コード例 #1
0
 public function testInvoke()
 {
     $controllers = new Controllers();
     $controllers->set('foo', new \stdClass());
     $services = new Services();
     $services->set('Controllers', $controllers);
     $this->setServices($services);
     $rootModel = $this->getMock(ViewModel::CLASS, ['addChild']);
     $toolbarEvent = new ToolbarEvent($rootModel);
     $model = new ViewModel();
     $listener = new ControllersListener();
     $listener->setModel($model);
     $rootModel->expects($this->once())->method('addChild')->with($this->identicalTo($model));
     $listener($toolbarEvent);
     $this->assertTrue(isset($model['controllers']));
     $items = $model['controllers'];
     $this->assertInternalType('array', $items);
     $this->assertSame(1, count($items));
     $this->assertArrayHasKey('foo', $items);
 }
コード例 #2
0
 public function testInvokeSpecifiedActionAsIndexIfActionIsNotProvided()
 {
     $controller = new FakeController();
     $controllers = new Controllers();
     $controllers->set('FakeController', $controller);
     $events = $this->getMock(Events::CLASS, ['trigger']);
     $plugin = new Forward();
     $plugin->setControllers($controllers);
     $plugin->setEvents($events);
     $events->expects($this->once())->method('trigger')->with($this->callback(function ($event) {
         if (!$event instanceof DispatchEvent) {
             return false;
         }
         if ('index' !== $event->getParam('action')) {
             return false;
         }
         return true;
     }));
     $plugin('FakeController');
 }
コード例 #3
0
 public function testExteptionClassWhenControllerNotFound()
 {
     $controllers = new Controllers();
     $this->setExpectedException(ControllerNotFoundException::CLASS);
     $controllers->get('foo');
 }