This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b41e2a8
commit 13a6ab8
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...earnZF2Log/test/PHPUnit/LearnZF2LogTest/Factory/Controller/IndexControllerFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ | ||
namespace LearnZF2LogTest\Factory\Controller; | ||
|
||
use PHPUnit_Framework_TestCase; | ||
use LearnZF2Log\Factory\Controller\IndexControllerFactory; | ||
use Zend\Mvc\Controller\ControllerManager; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
class IndexControllerFactoryTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** @var IndexControllerFactory */ | ||
protected $factory; | ||
|
||
/** @var ControllerManager */ | ||
protected $controllerManager; | ||
|
||
/** @var ServiceLocatorInterface */ | ||
protected $serviceLocator; | ||
|
||
public function setUp() | ||
{ | ||
/** @var ControllerManager $controllerManager */ | ||
$controllerManager = $this->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); | ||
} | ||
} |