Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
add IndexControllerFactory test
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Feb 22, 2015
1 parent b41e2a8 commit 13a6ab8
Showing 1 changed file with 70 additions and 0 deletions.
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);
}
}

0 comments on commit 13a6ab8

Please sign in to comment.