PagesControllerTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * PagesControllerTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
  8. * Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
  15. * @package cake.tests.cases.libs.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.tests.cases.libs.controller
  24. */
  25. class PagesControllerTest extends CakeTestCase {
  26. /**
  27. * endTest method
  28. *
  29. * @access public
  30. * @return void
  31. */
  32. function endTest() {
  33. App::build();
  34. }
  35. /**
  36. * testDisplay method
  37. *
  38. * @access public
  39. * @return void
  40. */
  41. function testDisplay() {
  42. App::build(array(
  43. 'View' => array(
  44. LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS
  45. )
  46. ));
  47. $Pages = new PagesController(new CakeRequest(null, false));
  48. $Pages->viewPath = 'posts';
  49. $Pages->display('index');
  50. $this->assertPattern('/posts index/', $Pages->getResponse()->body());
  51. $this->assertEqual($Pages->viewVars['page'], 'index');
  52. $Pages->viewPath = 'themed';
  53. $Pages->display('test_theme', 'posts', 'index');
  54. $this->assertPattern('/posts index themed view/', $Pages->getResponse()->body());
  55. $this->assertEqual($Pages->viewVars['page'], 'test_theme');
  56. $this->assertEqual($Pages->viewVars['subpage'], 'posts');
  57. }
  58. }