123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace Test\AppFramework\Http;
- use OCP\AppFramework\Http;
- use OCP\AppFramework\Http\TemplateResponse;
- class TemplateResponseTest extends \Test\TestCase {
-
- private $tpl;
- protected function setUp(): void {
- parent::setUp();
- $this->tpl = new TemplateResponse('app', 'home');
- }
- public function testSetParamsConstructor(): void {
- $params = ['hi' => 'yo'];
- $this->tpl = new TemplateResponse('app', 'home', $params);
- $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
- }
- public function testSetRenderAsConstructor(): void {
- $renderAs = 'myrender';
- $this->tpl = new TemplateResponse('app', 'home', [], $renderAs);
- $this->assertEquals($renderAs, $this->tpl->getRenderAs());
- }
- public function testSetParams(): void {
- $params = ['hi' => 'yo'];
- $this->tpl->setParams($params);
- $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
- }
- public function testGetTemplateName(): void {
- $this->assertEquals('home', $this->tpl->getTemplateName());
- }
- public function testGetRenderAs(): void {
- $render = 'myrender';
- $this->tpl->renderAs($render);
- $this->assertEquals($render, $this->tpl->getRenderAs());
- }
- public function testChainability(): void {
- $params = ['hi' => 'yo'];
- $this->tpl->setParams($params)
- ->setStatus(Http::STATUS_NOT_FOUND);
- $this->assertEquals(Http::STATUS_NOT_FOUND, $this->tpl->getStatus());
- $this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
- }
- }
|