You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.7KB

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 3.3.0
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace App\Test\TestCase;
  17. use App\Application;
  18. use App\Middleware\HostHeaderMiddleware;
  19. use Cake\Core\Configure;
  20. use Cake\Error\Middleware\ErrorHandlerMiddleware;
  21. use Cake\Http\MiddlewareQueue;
  22. use Cake\Routing\Middleware\AssetMiddleware;
  23. use Cake\Routing\Middleware\RoutingMiddleware;
  24. use Cake\TestSuite\IntegrationTestTrait;
  25. use Cake\TestSuite\TestCase;
  26. /**
  27. * ApplicationTest class
  28. */
  29. class ApplicationTest extends TestCase
  30. {
  31. use IntegrationTestTrait;
  32. /**
  33. * Test bootstrap in production.
  34. *
  35. * @return void
  36. */
  37. public function testBootstrap()
  38. {
  39. Configure::write('debug', false);
  40. $app = new Application(dirname(__DIR__, 2) . '/config');
  41. $app->bootstrap();
  42. $plugins = $app->getPlugins();
  43. $this->assertTrue($plugins->has('Bake'), 'plugins has Bake?');
  44. $this->assertFalse($plugins->has('DebugKit'), 'plugins has DebugKit?');
  45. $this->assertTrue($plugins->has('Migrations'), 'plugins has Migrations?');
  46. }
  47. /**
  48. * Test bootstrap add DebugKit plugin in debug mode.
  49. *
  50. * @return void
  51. */
  52. public function testBootstrapInDebug()
  53. {
  54. Configure::write('debug', true);
  55. $app = new Application(dirname(__DIR__, 2) . '/config');
  56. $app->bootstrap();
  57. $plugins = $app->getPlugins();
  58. $this->assertTrue($plugins->has('DebugKit'), 'plugins has DebugKit?');
  59. }
  60. /**
  61. * testMiddleware
  62. *
  63. * @return void
  64. */
  65. public function testMiddleware()
  66. {
  67. $app = new Application(dirname(__DIR__, 2) . '/config');
  68. $middleware = new MiddlewareQueue();
  69. $middleware = $app->middleware($middleware);
  70. $this->assertInstanceOf(ErrorHandlerMiddleware::class, $middleware->current());
  71. $middleware->seek(1);
  72. $this->assertInstanceOf(HostHeaderMiddleware::class, $middleware->current());
  73. $middleware->seek(2);
  74. $this->assertInstanceOf(AssetMiddleware::class, $middleware->current());
  75. $middleware->seek(3);
  76. $this->assertInstanceOf(RoutingMiddleware::class, $middleware->current());
  77. }
  78. }

Powered by TurnKey Linux.