PagesControllerTest.php 1.6 KB

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