| [74c3571] | 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 | class IndexControllerTest extends AbstractHttpControllerTestCase
|
|---|
| 14 | {
|
|---|
| 15 | public function setUp()
|
|---|
| 16 | {
|
|---|
| 17 | // The module configuration should still be applicable for tests.
|
|---|
| 18 | // You can override configuration here with test case specific values,
|
|---|
| 19 | // such as sample view templates, path stacks, module_listener_options,
|
|---|
| 20 | // etc.
|
|---|
| 21 | $configOverrides = [
|
|---|
| 22 | 'module_listener_options' => [
|
|---|
| 23 | 'config_cache_enabled' => false,
|
|---|
| 24 | ],
|
|---|
| 25 | ];
|
|---|
| 26 |
|
|---|
| 27 | $this->setApplicationConfig(ArrayUtils::merge(
|
|---|
| 28 | include __DIR__ . '/../../../../config/application.config.php',
|
|---|
| 29 | $configOverrides
|
|---|
| 30 | ));
|
|---|
| 31 |
|
|---|
| 32 | parent::setUp();
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | public function testIndexActionCanBeAccessed()
|
|---|
| 36 | {
|
|---|
| 37 | $this->dispatch('/', 'GET');
|
|---|
| 38 | $this->assertResponseStatusCode(200);
|
|---|
| 39 | $this->assertModuleName('application');
|
|---|
| 40 | $this->assertControllerName(IndexController::class); // as specified in router's controller name alias
|
|---|
| 41 | $this->assertControllerClass('IndexController');
|
|---|
| 42 | $this->assertMatchedRouteName('home');
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | public function testIndexActionViewModelTemplateRenderedWithinLayout()
|
|---|
| 46 | {
|
|---|
| 47 | $this->dispatch('/', 'GET');
|
|---|
| 48 | $this->assertQuery('.hero-unit');
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | public function testInvalidRouteDoesNotCrash()
|
|---|
| 52 | {
|
|---|
| 53 | $this->dispatch('/invalid/route', 'GET');
|
|---|
| 54 | $this->assertResponseStatusCode(404);
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|