1
0

TemplateResponseTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * ownCloud - App Framework
  4. *
  5. * @author Bernhard Posselt
  6. * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.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 Test\AppFramework\Http;
  23. use OCP\AppFramework\Http\TemplateResponse;
  24. use OCP\AppFramework\Http;
  25. class TemplateResponseTest extends \Test\TestCase {
  26. /**
  27. * @var \OCP\AppFramework\Http\TemplateResponse
  28. */
  29. private $tpl;
  30. protected function setUp() {
  31. parent::setUp();
  32. $this->tpl = new TemplateResponse('app', 'home');
  33. }
  34. public function testSetParamsConstructor(){
  35. $params = array('hi' => 'yo');
  36. $this->tpl = new TemplateResponse('app', 'home', $params);
  37. $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
  38. }
  39. public function testSetRenderAsConstructor(){
  40. $renderAs = 'myrender';
  41. $this->tpl = new TemplateResponse('app', 'home', array(), $renderAs);
  42. $this->assertEquals($renderAs, $this->tpl->getRenderAs());
  43. }
  44. public function testSetParams(){
  45. $params = array('hi' => 'yo');
  46. $this->tpl->setParams($params);
  47. $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
  48. }
  49. public function testGetTemplateName(){
  50. $this->assertEquals('home', $this->tpl->getTemplateName());
  51. }
  52. public function testGetRenderAs(){
  53. $render = 'myrender';
  54. $this->tpl->renderAs($render);
  55. $this->assertEquals($render, $this->tpl->getRenderAs());
  56. }
  57. public function testChainability() {
  58. $params = array('hi' => 'yo');
  59. $this->tpl->setParams($params)
  60. ->setStatus(Http::STATUS_NOT_FOUND);
  61. $this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus());
  62. $this->assertEquals(array('hi' => 'yo'), $this->tpl->getParams());
  63. }
  64. }