classFinder = $this->getMockBuilder(ClassFinder::class)->disableOriginalConstructor()->getMock(); $this->injectableFactory = $this->getMockBuilder(InjectableFactory::class)->disableOriginalConstructor()->getMock(); $this->request = $this->getMockBuilder(RequestWrapper::class)->disableOriginalConstructor()->getMock(); $this->response = $this->getMockBuilder(ResponseWrapper::class)->disableOriginalConstructor()->getMock(); $this->controllerManager = new ControllerManager($this->injectableFactory, $this->classFinder); } public function testAction1() { $controller = $this->getMockBuilder(TestController::class)->disableOriginalConstructor()->getMock(); $this->classFinder ->expects($this->once()) ->method('find') ->with('Controllers', 'Test') ->willReturn(TestController::class); $this->request ->expects($this->once()) ->method('getMethod') ->willReturn('POST'); $this->injectableFactory ->expects($this->once()) ->method('createWith') ->with(TestController::class, ['name' => 'Test']) ->willReturn($controller); $controller ->expects($this->once()) ->method('postActionHello') ->with($this->request, $this->response); $this->controllerManager->process('Test', 'hello', $this->request, $this->response); } }