PagesControllerTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 1.2.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace App\Test\TestCase\Controller;
  16. use App\Controller\PagesController;
  17. use Cake\Core\App;
  18. use Cake\Core\Configure;
  19. use Cake\Network\Request;
  20. use Cake\Network\Response;
  21. use Cake\TestSuite\IntegrationTestCase;
  22. use Cake\View\Exception\MissingTemplateException;
  23. /**
  24. * PagesControllerTest class
  25. */
  26. class PagesControllerTest extends IntegrationTestCase
  27. {
  28. /**
  29. * testDisplay method
  30. *
  31. * @return void
  32. */
  33. public function testDisplay()
  34. {
  35. $this->get('/pages/home');
  36. $this->assertResponseOk();
  37. $this->assertResponseContains('CakePHP');
  38. $this->assertResponseContains('<html>');
  39. }
  40. /**
  41. * Test that missing template renders 404 page in production
  42. *
  43. * @return void
  44. */
  45. public function testMissingTemplate()
  46. {
  47. Configure::write('debug', false);
  48. $this->get('/pages/not_existing');
  49. $this->assertResponseError();
  50. $this->assertResponseContains('Error');
  51. }
  52. /**
  53. * Test that missing template in debug mode renders missing_template error page
  54. *
  55. * @return void
  56. */
  57. public function testMissingTemplateInDebug()
  58. {
  59. Configure::write('debug', true);
  60. $this->get('/pages/not_existing');
  61. $this->assertResponseFailure();
  62. $this->assertResponseContains('Missing Template');
  63. $this->assertResponseContains('Stacktrace');
  64. $this->assertResponseContains('not_existing.ctp');
  65. }
  66. }