| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
|
|---|
| 4 | * @copyright Copyright (c) 2016 Zend Technologies USA Inc. (http://www.zend.com)
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | namespace ApplicationTest\Controller;
|
|---|
| 8 |
|
|---|
| 9 | use Application\Controller\IndexController;
|
|---|
| 10 | use Zend\Stdlib\ArrayUtils;
|
|---|
| 11 | use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
|
|---|
| 12 |
|
|---|
| 13 | /**
|
|---|
| 14 | * Name is intentional, to force it to run last; this was necessary as,
|
|---|
| 15 | * once the Admin module is loaded, the controller is able to find it and
|
|---|
| 16 | * will attempt the redirect.
|
|---|
| 17 | */
|
|---|
| 18 | class ZZIndexControllerDevModeTest extends AbstractHttpControllerTestCase
|
|---|
| 19 | {
|
|---|
| 20 | public function setUp()
|
|---|
| 21 | {
|
|---|
| 22 | // The module configuration should still be applicable for tests.
|
|---|
| 23 | // You can override configuration here with test case specific values,
|
|---|
| 24 | // such as sample view templates, path stacks, module_listener_options,
|
|---|
| 25 | // etc.
|
|---|
| 26 | $configOverrides = [
|
|---|
| 27 | 'modules' => [
|
|---|
| 28 | 'ZF\Apigility\Admin',
|
|---|
| 29 | 'ZF\Apigility\Admin\Ui',
|
|---|
| 30 | ],
|
|---|
| 31 | 'module_listener_options' => [
|
|---|
| 32 | 'config_cache_enabled' => false,
|
|---|
| 33 | 'config_glob_paths' => [
|
|---|
| 34 | __DIR__ . '/../../../../config/autoload/{,*.}{global,local}.php',
|
|---|
| 35 | __DIR__ . '/../../../../config/autoload/{,*.}{global,local}-development.php',
|
|---|
| 36 | ],
|
|---|
| 37 | ]
|
|---|
| 38 | ];
|
|---|
| 39 |
|
|---|
| 40 | $this->setApplicationConfig(ArrayUtils::merge(
|
|---|
| 41 | include __DIR__ . '/../../../../config/application.config.php',
|
|---|
| 42 | $configOverrides
|
|---|
| 43 | ));
|
|---|
| 44 |
|
|---|
| 45 | parent::setUp();
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | public function testIndexActionRedirectsToAdminUi()
|
|---|
| 49 | {
|
|---|
| 50 | $this->dispatch('/', 'GET');
|
|---|
| 51 | $this->assertResponseStatusCode(302);
|
|---|
| 52 | $this->assertRedirectRegex('#/ui$#');
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|