diff --git a/.gitignore b/.gitignore index ce01f7c..fdf29db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /nbproject/ /vendor/ -/.idea/ \ No newline at end of file +/.idea/ +composer.lock diff --git a/.travis.yml b/.travis.yml index f433eba..abd453c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,7 @@ matrix: - php: 7.3 env: - EXECUTE_SCRUTINIZER=true - - php: 7.0 - env: - - PREFER_LOWEST=true + - XDEBUG_MODE=coverage before_script: - if [ -z "$PREFER_LOWEST" ]; then composer update --no-interaction; fi diff --git a/README.md b/README.md index 74b7ec4..8f6acb4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MaglLegacyApplication - Legacy Applications in ZF2 +# MaglLegacyApplication - Legacy Applications in Laminas [![Latest Stable Version](https://poser.pugx.org/maglnet/magl-legacy-application/v/stable.svg)](https://packagist.org/packages/maglnet/magl-legacy-application) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/maglnet/MaglLegacyApplication/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maglnet/MaglLegacyApplication/?branch=master) @@ -6,19 +6,19 @@ [![Build Status](https://travis-ci.org/maglnet/MaglLegacyApplication.svg?branch=master)](https://travis-ci.org/maglnet/MaglLegacyApplication) [![Code Coverage](https://scrutinizer-ci.com/g/maglnet/MaglLegacyApplication/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/maglnet/MaglLegacyApplication/?branch=master) -Run your legacy applications within Zend Framework 2. +Run your legacy applications within Laminas. ## Introduction -Since rewriting your legacy application from scratch to a ZF2 application could be nearly impossible -due to time, effort, and resources, i was searching for a way to migrate a legacy application to a ZF2 application. +Since rewriting your legacy application from scratch to a Laminas application could be nearly impossible +due to time, effort, and resources, I was searching for a way to migrate a legacy application to a Laminas application. A [great article by Chris Abernethy][1] described a way on how to run your legacy application within ZF1, so -I migrated this HowTo to a small ZF2 module, to be able to run a legacy application within ZF2. +I migrated this HowTo to a small Laminas module, to be able to run a legacy application within Laminas. -While running your legacy application within a ZF2 application it is possible to slowly migrate an existing application -to ZF2 by leaving your old application (nearly - see "Adjust your legacy Application") untouched and build new modules -with the power of ZF2. -By adding a simple wrapper (see "Using ZF2 within your legacy application") you could also use the new modules +While running your legacy application within a Laminas application it is possible to slowly migrate an existing application +to Laminas by leaving your old application (nearly - see "Adjust your legacy Application") untouched and build new modules +with the power of Laminas. +By adding a simple wrapper (see "Using Laminas within your legacy application") you could also use the new modules within your legacy application. @@ -32,7 +32,7 @@ Install through composer } ``` -Enable the module within your ZF2 `application.config.php` +Enable the module within your Laminas `application.config.php` ```php 'modules' => array( 'Application', @@ -40,11 +40,11 @@ Enable the module within your ZF2 `application.config.php` ), ``` -Copy the provided file `data/magl-zf2-legacy-wrapper.php` to your `public/` folder. +Copy the provided file `data/magl-laminas-legacy-wrapper.php` to your `public/` folder. Copy the provided file `data/.htaccess` to your publix folder. Copy your legacy Application to your `public/` folder. -Your legacy application should now run within ZF2. :) +Your legacy application should now run within Laminas. :) ## Configuration @@ -54,9 +54,9 @@ routes to legacy controller and remove the mod_rewrite rules from your `.htacces return array( 'router' => array( 'routes' => array( - // example for transferring mod rewrite rules to zf2 routes + // example for transferring mod rewrite rules to laminas routes 'legacy-seo-calendar' => array( - 'type' => 'Zend\Mvc\Router\Http\Regex', + 'type' => 'Laminas\Mvc\Router\Http\Regex', 'options' => array( 'regex' => '/calendar/(?.+)', 'defaults' => array( @@ -76,8 +76,8 @@ return array( There are several cases in which your legacy application won't run without additional adjustments, here are some of them: ### Relative Paths -Using relative paths for `require`, `require_once` or `includes` will possibly fail now, since ZF2 will do a `chdir()` -to the ZF2's application root. So you will need to adjust your paths to match the new root. +Using relative paths for `require`, `require_once` or `includes` will possibly fail now, since Laminas will do a `chdir()` +to the Laminas' application root. So you will need to adjust your paths to match the new root. Example: @@ -112,7 +112,7 @@ $script_name = $legacy->getLegacyScriptName(); ``` -## Using ZF2 within your legacy application +## Using Laminas within your legacy application ```php use MaglLegacyApplication\Application\MaglLegacy; $application = MaglLegacy::getInstance()->getApplication(); @@ -121,12 +121,12 @@ $yourService = $application->getServiceManager()->get('YourService'); ## Injecting responses from within your legacy application from wherever you are within your legacy application, it is possible to bypass your legacy applications controller code -and send a response to the ZF2 Controller wrapper. This response will then be handled like within a normal ZF2 controller. +and send a response to the Laminas Controller wrapper. This response will then be handled like within a normal Laminas controller. ```php use MaglLegacyApplication\Application\MaglLegacy; $application = MaglLegacy::getInstance()->getApplication(); $application->getEventManager()->getSharedManager()->attach('*', MaglLegacy::EVENT_SHORT_CIRCUIT_RESPONSE, function(Event $e){ - $response = new \Zend\Http\Response(); + $response = new \Laminas\Http\Response(); $response->setStatusCode(404); $response->setContent('not found'); $e->stopPropagation(true); @@ -138,4 +138,4 @@ $application->getEventManager()->getSharedManager()->attach('*', MaglLegacy::EVE If you have questions or problems regarding this module just open an issue or, even better, solve it and open a pull request. :+1: -[1]: http://www.chrisabernethy.com/zend-framework-legacy-scripts/ \ No newline at end of file +[1]: http://www.chrisabernethy.com/zend-framework-legacy-scripts/ diff --git a/composer.json b/composer.json index 7d8eca5..8fc1b63 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,14 @@ { "name": "maglnet/magl-legacy-application", "type": "library", - "description": "Provides a ZF2 module that is able to run legacy applications with the power of ZF2.", + "description": "Provides a laminas module that is able to run legacy applications with the power of laminas.", "homepage": "https://github.com/maglnet/MaglLegacyApplication", "license": "BSD-3-Clause", - "keywords": ["legacy", "legacy application", "zend framework", "zf2"], + "keywords": [ + "legacy", + "legacy application", + "laminas" + ], "support": { "source": "https://github.com/maglnet/MaglLegacyApplication", "issues": "https://github.com/maglnet/MaglLegacyApplication/issues" @@ -18,18 +22,22 @@ ], "require": { "php": "^7.0", - "zendframework/zendframework": "^2.5 || ^3.0", - "zendframework/zend-servicemanager": "^2.6 || ^3.0", - "zendframework/zend-mvc": "^2.5 || ^3.0" + "laminas/laminas-eventmanager": "^3.0", + "laminas/laminas-http": "^2.0", + "laminas/laminas-mvc": "^3.0", + "laminas/laminas-router": "^3.0", + "laminas/laminas-servicemanager": "^3.0", + "laminas/laminas-stdlib": "^3.0", + "laminas/laminas-view": "^2.5" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "zendframework/zend-modulemanager": "^2.5", - "zendframework/zend-view": "^2.5", - "zendframework/zend-router": "^2.5 || ^3.3" + "laminas/laminas-modulemanager": "^2.5", + "laminas/laminas-test": "^3.0", + "phpunit/phpunit": "^5.7" }, "autoload": { - "classmap": ["src"], - "psr-0": {"MaglLegacyApplication": "src"} + "psr-4": { + "MaglLegacyApplication\\": "src/MaglLegacyApplication" + } } } diff --git a/config/module.config.php b/config/module.config.php index 75f453b..502b9d2 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -43,7 +43,7 @@ ), // example for transferring mod rewrite rules to zf2 routes // 'legacy-seo-calendar' => array( -// 'type' => 'Zend\Mvc\Router\Http\Regex', +// 'type' => 'Laminas\Mvc\Router\Http\Regex', // 'options' => array( // 'regex' => '/calendar/(?.+)', // 'defaults' => array( diff --git a/data/.htaccess b/data/.htaccess index b49d7c1..ad34228 100644 --- a/data/.htaccess +++ b/data/.htaccess @@ -2,5 +2,5 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} \.php$ RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ %{ENV:BASE}magl-zf2-legacy-wrapper.php [NC,L] +RewriteRule ^(.*)$ %{ENV:BASE}magl-laminas-legacy-wrapper.php [NC,L] diff --git a/data/magl-zf2-legacy-wrapper.php b/data/magl-laminas-legacy-wrapper.php similarity index 82% rename from data/magl-zf2-legacy-wrapper.php rename to data/magl-laminas-legacy-wrapper.php index 03ae83e..a5f9f1b 100644 --- a/data/magl-zf2-legacy-wrapper.php +++ b/data/magl-laminas-legacy-wrapper.php @@ -1,10 +1,10 @@ setApplication($application); $application->run(); diff --git a/src/MaglLegacyApplication/Application/MaglLegacy.php b/src/MaglLegacyApplication/Application/MaglLegacy.php index 8943a0a..463a312 100644 --- a/src/MaglLegacyApplication/Application/MaglLegacy.php +++ b/src/MaglLegacyApplication/Application/MaglLegacy.php @@ -7,6 +7,10 @@ namespace MaglLegacyApplication\Application; +use Laminas\EventManager\EventManagerInterface; +use Laminas\Mvc\ApplicationInterface; +use Laminas\ServiceManager\ServiceLocatorInterface; + class MaglLegacy { @@ -20,7 +24,7 @@ class MaglLegacy /** * - * @var \Zend\Mvc\ApplicationInterface + * @var ApplicationInterface */ private $application; @@ -65,14 +69,14 @@ private function __clone() return null; } - public function setApplication(\Zend\Mvc\ApplicationInterface $application) + public function setApplication(ApplicationInterface $application) { $this->application = $application; } /** * - * @return \Zend\Mvc\ApplicationInterface + * @return ApplicationInterface */ public function getApplication() { @@ -81,7 +85,7 @@ public function getApplication() /** * - * @return \Zend\ServiceManager\ServiceLocatorInterface + * @return ServiceLocatorInterface */ public static function getServiceManager() { @@ -90,7 +94,7 @@ public static function getServiceManager() /** * - * @return \Zend\EventManager\EventManagerInterface + * @return EventManagerInterface */ public static function getEventManager() { @@ -108,7 +112,7 @@ public function getLegacyScriptFilename() /** * - * @param string $legacyScriptFilename + * @param string $legacyScriptFilename * @return boolean true, if the script filenamename was set, false otherwise, e.g. it has already been set */ public function setLegacyScriptFilename($legacyScriptFilename) @@ -127,7 +131,7 @@ public function getLegacyScriptName() /** * - * @param string $legacyScriptName + * @param string $legacyScriptName * @return boolean true, if the script name was set, false otherwise, e.g. it has already been set */ public function setLegacyScriptName($legacyScriptName) diff --git a/src/MaglLegacyApplication/Controller/LegacyController.php b/src/MaglLegacyApplication/Controller/LegacyController.php index d8f2362..e687f4a 100644 --- a/src/MaglLegacyApplication/Controller/LegacyController.php +++ b/src/MaglLegacyApplication/Controller/LegacyController.php @@ -7,11 +7,11 @@ namespace MaglLegacyApplication\Controller; +use Laminas\Http\Response; +use Laminas\Mvc\Controller\AbstractActionController; +use Laminas\View\Model\ViewModel; use MaglLegacyApplication\Application\MaglLegacy; use MaglLegacyApplication\Options\LegacyControllerOptions; -use Zend\Http\Response; -use Zend\Mvc\Controller\AbstractActionController; -use Zend\View\Model\ViewModel; class LegacyController extends AbstractActionController { @@ -37,7 +37,7 @@ public function __construct(LegacyControllerOptions $options, MaglLegacy $legacy public function indexAction() { $docRoots = $this->options->getDocRoots(); - foreach($docRoots as $key => $docRoot) { + foreach ($docRoots as $key => $docRoot) { $docRoots[$key] = rtrim(getcwd() . '/' . $docRoot); } @@ -46,7 +46,7 @@ public function indexAction() if (empty($scriptName)) { $path = $this->params(('path')) ? $this->params('path') : ''; foreach ($this->options->getIndexFiles() as $indexFile) { - foreach($docRoots as $docRoot) { + foreach ($docRoots as $docRoot) { if (is_file($docRoot . '/' . $path . $indexFile)) { $this->legacy->setLegacyScriptName($path . $indexFile); return $this->runScript($docRoot . '/' . $path . $indexFile); @@ -55,11 +55,10 @@ public function indexAction() } } - $scriptUri = '/' . ltrim($scriptName, '/'); // force leading '/' - foreach($docRoots as $docRoot) { + foreach ($docRoots as $docRoot) { $legacyScriptFilename = $docRoot . $scriptUri; - if(is_file($legacyScriptFilename)) { + if (is_file($legacyScriptFilename)) { //inform the application about the used script $this->legacy->setLegacyScriptName($scriptUri); @@ -102,7 +101,6 @@ private function setGetVariables() $routeParams = $this->getEvent()->getRouteMatch()->getParams(); foreach ($routeParams as $paramName => $paramValue) { - if ($globals_options['get'] && !isset($_GET[$paramName])) { $_GET[$paramName] = $paramValue; } diff --git a/src/MaglLegacyApplication/Factory/ControllerServiceFactory.php b/src/MaglLegacyApplication/Factory/ControllerServiceFactory.php index 35ea245..fcb9844 100644 --- a/src/MaglLegacyApplication/Factory/ControllerServiceFactory.php +++ b/src/MaglLegacyApplication/Factory/ControllerServiceFactory.php @@ -1,45 +1,18 @@ __invoke($serviceLocator, 'MaglControllerService'); - } - - /** - * Create an object - * - * @param ContainerInterface $container - * @param string $requestedName - * @param null|array $options - * @return object - * @throws ServiceNotFoundException if unable to resolve the service. - * @throws ServiceNotCreatedException if an exception is raised when - * creating a service. - * @throws ContainerException if any other error occurs + * @inheritDoc */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { @@ -51,13 +24,8 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o $event->setRequest($container->get('Request')); $event->setRouter($container->get('Router')); - $routeMatch = null; - if(class_exists('\Zend\Mvc\Router\RouteMatch')) { - // ZF2.5 compatibility - $routeMatch = new ZF2RouteMatch(array()); - } else { - $routeMatch = new RouteMatch(array()); - } + $routeMatch = new RouteMatch(array()); + $event->setRouteMatch($routeMatch); return new ControllerService($eventManager, $event); diff --git a/src/MaglLegacyApplication/Factory/LegacyControllerFactory.php b/src/MaglLegacyApplication/Factory/LegacyControllerFactory.php index 23d0781..70f5de8 100644 --- a/src/MaglLegacyApplication/Factory/LegacyControllerFactory.php +++ b/src/MaglLegacyApplication/Factory/LegacyControllerFactory.php @@ -1,43 +1,17 @@ __invoke($serviceLocator->getServiceLocator(), 'MaglLegacyApplication\Controller\Legacy'); - } - - /** - * Create an object - * - * @param ContainerInterface $container - * @param string $requestedName - * @param null|array $options - * @return object - * @throws ServiceNotFoundException if unable to resolve the service. - * @throws ServiceNotCreatedException if an exception is raised when - * creating a service. - * @throws ContainerException if any other error occurs + * @inheritDoc */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { diff --git a/src/MaglLegacyApplication/Factory/LegacyControllerOptionsFactory.php b/src/MaglLegacyApplication/Factory/LegacyControllerOptionsFactory.php index 09bdea0..91be08e 100644 --- a/src/MaglLegacyApplication/Factory/LegacyControllerOptionsFactory.php +++ b/src/MaglLegacyApplication/Factory/LegacyControllerOptionsFactory.php @@ -1,42 +1,16 @@ __invoke($serviceLocator, 'MaglLegacyApplicationOptions'); - } - - /** - * Create an object - * - * @param ContainerInterface $container - * @param string $requestedName - * @param null|array $options - * @return object - * @throws ServiceNotFoundException if unable to resolve the service. - * @throws ServiceNotCreatedException if an exception is raised when - * creating a service. - * @throws ContainerException if any other error occurs + * @inheritDoc */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { diff --git a/src/MaglLegacyApplication/Module.php b/src/MaglLegacyApplication/Module.php index c9d831c..738a35d 100644 --- a/src/MaglLegacyApplication/Module.php +++ b/src/MaglLegacyApplication/Module.php @@ -7,28 +7,41 @@ namespace MaglLegacyApplication; +use Laminas\EventManager\EventInterface; +use Laminas\ModuleManager\Feature\AutoloaderProviderInterface; +use Laminas\ModuleManager\Feature\BootstrapListenerInterface; +use Laminas\ModuleManager\Feature\ConfigProviderInterface; +use Laminas\Mvc\MvcEvent; use MaglLegacyApplication\Application\MaglLegacy; -use Psr\Container\ContainerInterface; -use Zend\Mvc\MvcEvent; -use Zend\Router\RouteMatch; -use Zend\ServiceManager\ServiceManager; -class Module +class Module implements BootstrapListenerInterface, ConfigProviderInterface, AutoloaderProviderInterface { - public function onBootstrap(MvcEvent $event) + + /** + * @inheritDoc + */ + public function onBootstrap(EventInterface $event) { - MaglLegacy::getInstance()->setApplication($event->getApplication()); + if ($event instanceof MvcEvent) { + MaglLegacy::getInstance()->setApplication($event->getApplication()); + } } + /** + * @inheritDoc + */ public function getConfig() { - return include realpath(__DIR__ . '/../../config/module.config.php'); + return include __DIR__ . '/../../config/module.config.php'; } + /** + * @inheritDoc + */ public function getAutoloaderConfig() { return array( - 'Zend\Loader\StandardAutoloader' => array( + 'Laminas\Loader\StandardAutoloader' => array( 'namespaces' => array( __NAMESPACE__ => __DIR__, ), diff --git a/src/MaglLegacyApplication/Options/LegacyControllerOptions.php b/src/MaglLegacyApplication/Options/LegacyControllerOptions.php index 6f8f4cb..0ecf395 100644 --- a/src/MaglLegacyApplication/Options/LegacyControllerOptions.php +++ b/src/MaglLegacyApplication/Options/LegacyControllerOptions.php @@ -7,7 +7,9 @@ namespace MaglLegacyApplication\Options; -class LegacyControllerOptions extends \Zend\Stdlib\AbstractOptions +use Laminas\Stdlib\AbstractOptions; + +class LegacyControllerOptions extends AbstractOptions { private $docRoot = array('public'); @@ -38,7 +40,7 @@ public function getGlobals() public function setDocRoot($docRoot) { - if(!is_array($docRoot)) { + if (!is_array($docRoot)) { $docRoot = array($docRoot); } $this->docRoot = $docRoot; @@ -80,6 +82,4 @@ public function setPrependOutputBufferToResponse($prependOutputBufferToResponse) { $this->prependOutputBufferToResponse = $prependOutputBufferToResponse; } - - } diff --git a/src/MaglLegacyApplication/Service/ControllerService.php b/src/MaglLegacyApplication/Service/ControllerService.php index dc7d5ab..2fd83e3 100644 --- a/src/MaglLegacyApplication/Service/ControllerService.php +++ b/src/MaglLegacyApplication/Service/ControllerService.php @@ -8,14 +8,14 @@ namespace MaglLegacyApplication\Service; - -use Zend\EventManager\EventManager; -use Zend\Http\Response; -use Zend\Mvc\Controller\AbstractActionController; -use Zend\Mvc\MvcEvent; -use Zend\Router\RouteMatch; -use Zend\Mvc\View\Http\DefaultRenderingStrategy; -use Zend\View\Model\ViewModel; +use Laminas\EventManager\EventManager; +use Laminas\Http\Response; +use Laminas\Mvc\Controller\AbstractActionController; +use Laminas\Mvc\MvcEvent; +use Laminas\Mvc\View\Http\DefaultRenderingStrategy; +use Laminas\Router\RouteMatch; +use Laminas\Stdlib\ResponseInterface; +use Laminas\View\Model\ViewModel; class ControllerService { @@ -45,12 +45,11 @@ public function __construct(EventManager $eventManager, MvcEvent $event) * @param $controllerName * @param $action * @param array $params - * @return string|\Zend\Stdlib\ResponseInterface + * @return string|ResponseInterface * @throws \Exception */ public function runControllerAction($controllerName, $action, $params = array()) { - $this->event->getRouteMatch() ->setParam('controller', $controllerName) ->setParam('action', $action); @@ -95,5 +94,4 @@ public function runControllerAction($controllerName, $action, $params = array()) return $renderingStrategy->render($this->event); } - } diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 2895c23..0eab7e2 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -3,8 +3,8 @@ namespace MaglLegacyApplicationTest; use RuntimeException; -use Zend\Loader\AutoloaderFactory; -use Zend\Mvc\Application; +use Laminas\Loader\AutoloaderFactory; +use Laminas\Mvc\Application; error_reporting(E_ALL | E_STRICT); chdir(__DIR__); @@ -43,8 +43,8 @@ public static function init() ), ); - if (class_exists('\Zend\Router\Module')) { - $config['modules'][] = 'Zend\Router'; + if (class_exists('\Laminas\Router\Module')) { + $config['modules'][] = 'Laminas\Router'; } $app = Application::init($config); @@ -54,7 +54,7 @@ public static function init() /** * - * @return \Zend\ServiceManager\ServiceManager + * @return \Laminas\ServiceManager\ServiceManager */ public static function getServiceManager() { @@ -73,7 +73,7 @@ protected static function initAutoloader() } AutoloaderFactory::factory(array( - 'Zend\Loader\StandardAutoloader' => array( + 'Laminas\Loader\StandardAutoloader' => array( 'autoregister_zf' => true, 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__, diff --git a/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php b/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php index 7ac8569..dd9c562 100644 --- a/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php +++ b/tests/MaglLegacyApplicationTest/Application/MaglLegacyTest.php @@ -15,7 +15,6 @@ class MaglLegacyTest extends PHPUnit_Framework_TestCase public function testGetInstance() { - $instance = MaglLegacy::getInstance(); $this->assertInstanceOf('\MaglLegacyApplication\Application\MaglLegacy', $instance); @@ -91,8 +90,7 @@ public function testSetGetLegacyScriptFileName() public function testSetGetApplication() { - - $appMock = $this->getMockBuilder('Zend\Mvc\Application') + $appMock = $this->getMockBuilder('Laminas\Mvc\Application') ->disableOriginalConstructor() ->getMock(); diff --git a/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php b/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php index cc695bb..02c51a8 100644 --- a/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php +++ b/tests/MaglLegacyApplicationTest/Controller/LegacyControllerTest.php @@ -7,12 +7,10 @@ namespace MaglLegacyApplicationTest\Controller; -use MaglLegacyApplication\Options\LegacyControllerOptions; -use MaglLegacyApplicationTest\Bootstrap; -use Zend\Stdlib\ResponseInterface; -use Zend\View\Model\ViewModel; +use Laminas\Stdlib\ResponseInterface; +use Laminas\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; -class LegacyControllerTest extends \Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase +class LegacyControllerTest extends AbstractHttpControllerTestCase { protected $traceError = true; diff --git a/tests/MaglLegacyApplicationTest/ModuleTest.php b/tests/MaglLegacyApplicationTest/ModuleTest.php index 353aa5a..464325f 100644 --- a/tests/MaglLegacyApplicationTest/ModuleTest.php +++ b/tests/MaglLegacyApplicationTest/ModuleTest.php @@ -3,13 +3,14 @@ namespace MaglLegacyApplicationTest; use MaglLegacyApplication\Module; +use PHPUnit_Framework_TestCase; /** * Description of ModuleTest * * @author matthias */ -class ModuleTest extends \PHPUnit_Framework_TestCase +class ModuleTest extends PHPUnit_Framework_TestCase { /** @@ -39,7 +40,7 @@ public function testGetAutoloaderConfig() { $config = $this->instance->getAutoloaderConfig(); - $this->assertTrue(array_key_exists('MaglLegacyApplication', $config['Zend\Loader\StandardAutoloader']['namespaces'])); + $this->assertTrue(array_key_exists('MaglLegacyApplication', $config['Laminas\Loader\StandardAutoloader']['namespaces'])); } public function testGetServiceFactories() diff --git a/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php b/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php index 7ae2e9a..2857fc8 100644 --- a/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php +++ b/tests/MaglLegacyApplicationTest/Options/LegacyControllerOptionsTest.php @@ -7,7 +7,9 @@ namespace MaglLegacyApplicationTest\Options; -class LegacyControllerOptionsTest extends \PHPUnit_Framework_TestCase +use PHPUnit_Framework_TestCase; + +class LegacyControllerOptionsTest extends PHPUnit_Framework_TestCase { public function testSetGetDocRoot() diff --git a/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php b/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php index 17a837d..dde3714 100644 --- a/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php +++ b/tests/MaglLegacyApplicationTest/Service/ControllerServiceTest.php @@ -8,14 +8,15 @@ namespace MaglLegacyApplicationTest\Service; - +use Laminas\Mvc\Controller\AbstractActionController; +use Laminas\Mvc\Controller\ControllerManager; +use Laminas\View\Model\ViewModel; use MaglLegacyApplication\Service\ControllerService; use MaglLegacyApplicationTest\Bootstrap; -use Zend\Mvc\Controller\AbstractActionController; -use Zend\Mvc\Controller\ControllerManager; -use Zend\View\Model\ViewModel; +use PHPUnit_Framework_TestCase; -class ControllerServiceTest extends \PHPUnit_Framework_TestCase { +class ControllerServiceTest extends PHPUnit_Framework_TestCase +{ /** * @var ControllerService diff --git a/tests/application.config.php b/tests/application.config.php index 96ad73f..8ca9db8 100644 --- a/tests/application.config.php +++ b/tests/application.config.php @@ -14,7 +14,7 @@ ), 'router' => array( 'routes' => array( - // example for transferring mod rewrite rules to zf2 routes + // example for transferring mod rewrite rules to laminas routes 'legacy-seo-calendar' => array( 'type' => 'Regex', 'options' => array( diff --git a/tests/public/returning-legacy-response.php b/tests/public/returning-legacy-response.php index 21f78a0..3edf5e3 100644 --- a/tests/public/returning-legacy-response.php +++ b/tests/public/returning-legacy-response.php @@ -1,6 +1,6 @@ setContent('myResponse'); $response->setStatusCode(418); return $response; diff --git a/tests/public/returning-legacy-template.php b/tests/public/returning-legacy-template.php index ff729b4..4aceeea 100644 --- a/tests/public/returning-legacy-template.php +++ b/tests/public/returning-legacy-template.php @@ -1,5 +1,5 @@ "bar")); +$model = new \Laminas\View\Model\ViewModel(array('foo' => "bar")); $model->setTemplate('legacy-template'); return $model;