Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'hotfix/3842' into develop

Forward port #3842
  • Loading branch information...
commit 54c4dacb4ec1902743402e12c8b5a82642c57e9a 2 parents f9794c6 + ae1cc0c
@weierophinney weierophinney authored
View
27 library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php
@@ -10,6 +10,7 @@
use PHPUnit_Framework_TestCase;
use PHPUnit_Framework_ExpectationFailedException;
+use Zend\Console\Console;
use Zend\EventManager\StaticEventManager;
use Zend\Http\Request as HttpRequest;
use Zend\Mvc\Application;
@@ -40,6 +41,12 @@
protected $useConsoleRequest = false;
/**
+ * Flag console used before tests
+ * @var boolean
+ */
+ private $usedConsoleBackup;
+
+ /**
* Trace error when exception is throwed in application
* @var boolean
*/
@@ -50,10 +57,19 @@
*/
public function setUp()
{
+ $this->usedConsoleBackup = Console::isConsole();
$this->reset();
}
/**
+ * Restore params
+ */
+ public function tearDown()
+ {
+ Console::overrideIsConsole($this->usedConsoleBackup);
+ }
+
+ /**
* Get the trace error flag
* @return boolean
*/
@@ -134,16 +150,7 @@ public function getApplication()
return $this->application;
}
$appConfig = $this->applicationConfig;
- if (!$this->useConsoleRequest) {
- $consoleServiceConfig = array(
- 'service_manager' => array(
- 'factories' => array(
- 'ServiceListener' => 'Zend\Test\PHPUnit\Mvc\Service\ServiceListenerFactory',
- ),
- ),
- );
- $appConfig = array_replace_recursive($appConfig, $consoleServiceConfig);
- }
+ Console::overrideIsConsole($this->getUseConsoleRequest());
$this->application = Application::init($appConfig);
$events = $this->application->getEventManager();
View
31 library/Zend/Test/PHPUnit/Mvc/Service/RouterFactory.php
@@ -1,31 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-namespace Zend\Test\PHPUnit\Mvc\Service;
-
-use Zend\Mvc\Router\Http\TreeRouteStack as HttpRouter;
-use Zend\ServiceManager\FactoryInterface;
-use Zend\ServiceManager\ServiceLocatorInterface;
-
-class RouterFactory implements FactoryInterface
-{
- /**
- * Create and return router
- *
- * @param ServiceLocatorInterface $serviceLocator
- * @param string|null $cName
- * @param string|null $rName
- * @return HttpRouter
- */
- public function createService(ServiceLocatorInterface $serviceLocator, $cName = null, $rName = null)
- {
- $config = $serviceLocator->get('Config');
- $routerConfig = isset($config['router']) ? $config['router'] : array();
- return HttpRouter::factory($routerConfig);
- }
-}
View
37 library/Zend/Test/PHPUnit/Mvc/Service/ServiceListenerFactory.php
@@ -1,37 +0,0 @@
-<?php
-/**
- * Zend Framework (http://framework.zend.com/)
- *
- * @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-namespace Zend\Test\PHPUnit\Mvc\Service;
-
-use Zend\Mvc\Service\ServiceListenerFactory as BaseServiceListenerFactory;
-
-class ServiceListenerFactory extends BaseServiceListenerFactory
-{
- /**
- * Create default service configuration
- */
- public function __construct()
- {
- // merge basee config with specific tests config
- $this->defaultServiceConfig = array_replace_recursive(
- $this->defaultServiceConfig,
- array('factories' => array(
- 'Request' => function($sm) {
- return new \Zend\Http\PhpEnvironment\Request();
- },
- 'Response' => function($sm) {
- return new \Zend\Http\PhpEnvironment\Response();
- },
- 'Router' => 'Zend\Test\PHPUnit\Mvc\Service\RouterFactory',
- 'ViewManager' => function($sm) {
- return new \Zend\Mvc\View\Http\ViewManager();
- },
- ))
- );
- }
-}
View
21 tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php
@@ -9,6 +9,7 @@
*/
namespace ZendTest\Test\PHPUnit\Controller;
+use Zend\Console\Console;
use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent;
use Zend\Stdlib\RequestInterface;
@@ -61,6 +62,26 @@ public function testApplicationClass()
$this->assertEquals($applicationClass, 'Zend\Mvc\Application');
}
+ public function testApplicationClassAndTestRestoredConsoleFlag()
+ {
+ $this->assertTrue(Console::isConsole());
+ $this->getApplication();
+ $this->assertFalse(Console::isConsole());
+ $this->tearDown();
+ $this->assertTrue(Console::isConsole());
+
+ Console::overrideIsConsole(false);
+ parent::setUp();
+
+ $this->assertFalse(Console::isConsole());
+ $this->getApplication();
+ $this->assertFalse(Console::isConsole());
+
+ parent::tearDown();
+
+ $this->assertFalse(Console::isConsole());
+ }
+
public function testApplicationServiceLocatorClass()
{
$smClass = get_class($this->getApplicationServiceLocator());
View
4 ...nit/Controller/ModuleDependenciesTest.php → ...t/Test/PHPUnit/ModuleDependenciesTest.php
@@ -22,7 +22,7 @@ class ModuleDependenciesTest extends AbstractHttpControllerTestCase
public function testDependenciesModules()
{
$this->setApplicationConfig(
- include __DIR__ . '/../../_files/application.config.with.dependencies.php'
+ include __DIR__ . '/../_files/application.config.with.dependencies.php'
);
$sm = $this->getApplicationServiceLocator();
$this->assertEquals(true, $sm->has('FooObject'));
@@ -36,7 +36,7 @@ public function testDependenciesModules()
public function testBadDependenciesModules()
{
$this->setApplicationConfig(
- include __DIR__ . '/../../_files/application.config.with.dependencies.disabled.php'
+ include __DIR__ . '/../_files/application.config.with.dependencies.disabled.php'
);
$sm = $this->getApplicationServiceLocator();
$this->assertEquals(false, $sm->has('FooObject'));
Please sign in to comment.
Something went wrong with that request. Please try again.