TemplateResponseTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * ownCloud - App Framework
  4. *
  5. * @author Bernhard Posselt
  6. * @copyright 2012 Bernhard Posselt nukeawhale@gmail.com
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OC\AppFramework\Http;
  23. use OCP\AppFramework\Http\TemplateResponse;
  24. class TemplateResponseTest extends \PHPUnit_Framework_TestCase {
  25. /**
  26. * @var \OCP\AppFramework\Http\TemplateResponse
  27. */
  28. private $tpl;
  29. /**
  30. * @var \OCP\AppFramework\IApi
  31. */
  32. private $api;
  33. protected function setUp() {
  34. $this->api = $this->getMock('OC\AppFramework\Core\API',
  35. array('getAppName'), array('test'));
  36. $this->api->expects($this->any())
  37. ->method('getAppName')
  38. ->will($this->returnValue('app'));
  39. $this->tpl = new TemplateResponse($this->api, 'home');
  40. }
  41. public function testSetParams(){
  42. $params = array('hi' => 'yo');
  43. $this->tpl->setParams($params);
  44. $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
  45. }
  46. public function testGetTemplateName(){
  47. $this->assertEquals('home', $this->tpl->getTemplateName());
  48. }
  49. // public function testRender(){
  50. // $ocTpl = $this->getMock('Template', array('fetchPage'));
  51. // $ocTpl->expects($this->once())
  52. // ->method('fetchPage');
  53. //
  54. // $tpl = new TemplateResponse('core', 'error');
  55. //
  56. // $tpl->render();
  57. // }
  58. //
  59. //
  60. // public function testRenderAssignsParams(){
  61. // $params = array('john' => 'doe');
  62. //
  63. // $tpl = new TemplateResponse('app', 'home');
  64. // $tpl->setParams($params);
  65. //
  66. // $tpl->render();
  67. // }
  68. //
  69. //
  70. // public function testRenderDifferentApp(){
  71. //
  72. // $tpl = new TemplateResponse('app', 'home', 'app2');
  73. //
  74. // $tpl->render();
  75. // }
  76. public function testGetRenderAs(){
  77. $render = 'myrender';
  78. $this->tpl->renderAs($render);
  79. $this->assertEquals($render, $this->tpl->getRenderAs());
  80. }
  81. }