PagesControllerTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * PagesControllerTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  16. * @package Cake.Test.Case.Controller
  17. * @since CakePHP(tm) v 1.2.0.5436
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. App::uses('PagesController', 'Controller');
  21. /**
  22. * PagesControllerTest class
  23. *
  24. * @package Cake.Test.Case.Controller
  25. */
  26. class PagesControllerTest extends CakeTestCase {
  27. /**
  28. * testDisplay method
  29. *
  30. * @return void
  31. */
  32. public function testDisplay() {
  33. App::build(array(
  34. 'View' => array(
  35. CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
  36. )
  37. ));
  38. $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
  39. $Pages->viewPath = 'Posts';
  40. $Pages->display('index');
  41. $this->assertRegExp('/posts index/', $Pages->response->body());
  42. $this->assertEquals('index', $Pages->viewVars['page']);
  43. $Pages->viewPath = 'Themed';
  44. $Pages->display('TestTheme', 'Posts', 'index');
  45. $this->assertRegExp('/posts index themed view/', $Pages->response->body());
  46. $this->assertEquals('TestTheme', $Pages->viewVars['page']);
  47. $this->assertEquals('Posts', $Pages->viewVars['subpage']);
  48. }
  49. }