From 13a6ab8d16e88a22b7f82654ea1a5956c7679cf8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 22 Feb 2015 10:41:22 +0700 Subject: [PATCH] add IndexControllerFactory test --- .../Controller/IndexControllerFactoryTest.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 module/LearnZF2Log/test/PHPUnit/LearnZF2LogTest/Factory/Controller/IndexControllerFactoryTest.php diff --git a/module/LearnZF2Log/test/PHPUnit/LearnZF2LogTest/Factory/Controller/IndexControllerFactoryTest.php b/module/LearnZF2Log/test/PHPUnit/LearnZF2LogTest/Factory/Controller/IndexControllerFactoryTest.php new file mode 100644 index 0000000..33a07c5 --- /dev/null +++ b/module/LearnZF2Log/test/PHPUnit/LearnZF2LogTest/Factory/Controller/IndexControllerFactoryTest.php @@ -0,0 +1,70 @@ +getMock('Zend\Mvc\Controller\ControllerManager'); + $this->controllerManager = $controllerManager; + + /** @var ServiceLocatorInterface $serviceLocator */ + $serviceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); + $this->serviceLocator = $serviceLocator; + + $controllerManager->expects($this->any()) + ->method('getServiceLocator') + ->willReturn($serviceLocator); + + $factory = new IndexControllerFactory(); + $this->factory = $factory; + } + + public function testCreateService() + { + $mockFormElementManager = $this->getMock('Zend\Form\FormElementManager'); + $this->serviceLocator->expects($this->at(0)) + ->method('get') + ->with('FormElementManager') + ->willReturn($mockFormElementManager); + $mockLogForm = $this->getMock('LearnZF2Log\Form\LogForm'); + $mockFormElementManager->expects($this->at(0)) + ->method('get') + ->with('LearnZF2Log\Form\LogForm') + ->willReturn($mockLogForm); + + $result = $this->factory->createService($this->controllerManager); + $this->assertInstanceOf('LearnZF2Log\Controller\IndexController', $result); + } +}