PagesControllerTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-2011, 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-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/view/1196/Testing 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. * endTest method
  28. *
  29. * @return void
  30. */
  31. public function endTest() {
  32. App::build();
  33. }
  34. /**
  35. * testDisplay method
  36. *
  37. * @return void
  38. */
  39. public function testDisplay() {
  40. App::build(array(
  41. 'View' => array(
  42. CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS
  43. )
  44. ));
  45. $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse());
  46. $Pages->viewPath = 'Posts';
  47. $Pages->display('index');
  48. $this->assertPattern('/posts index/', $Pages->response->body());
  49. $this->assertEqual($Pages->viewVars['page'], 'index');
  50. $Pages->viewPath = 'Themed';
  51. $Pages->display('TestTheme', 'Posts', 'index');
  52. $this->assertPattern('/posts index themed view/', $Pages->response->body());
  53. $this->assertEqual($Pages->viewVars['page'], 'TestTheme');
  54. $this->assertEqual($Pages->viewVars['subpage'], 'Posts');
  55. }
  56. }