nextcloud/tests/lib/AppFramework/Http/TemplateResponseTest.php

70 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2013-08-17 05:16:48 -04:00
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
2013-08-17 05:16:48 -04:00
*/
2016-05-18 12:40:34 -04:00
namespace Test\AppFramework\Http;
2013-08-17 05:16:48 -04:00
2014-03-09 18:01:16 -04:00
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\TemplateResponse;
2013-08-17 05:16:48 -04:00
class TemplateResponseTest extends \Test\TestCase {
/**
* @var TemplateResponse
*/
2013-08-17 05:16:48 -04:00
private $tpl;
protected function setUp(): void {
parent::setUp();
$this->tpl = new TemplateResponse('app', 'home');
2013-08-17 05:16:48 -04:00
}
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'];
2013-08-17 05:16:48 -04:00
$this->tpl->setParams($params);
$this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
2013-08-17 05:16:48 -04:00
}
public function testGetTemplateName(): void {
2013-08-17 05:16:48 -04:00
$this->assertEquals('home', $this->tpl->getTemplateName());
}
public function testGetRenderAs(): void {
2013-08-17 05:16:48 -04:00
$render = 'myrender';
$this->tpl->renderAs($render);
$this->assertEquals($render, $this->tpl->getRenderAs());
}
public function testChainability(): void {
$params = ['hi' => 'yo'];
2014-03-09 18:01:16 -04:00
$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());
2014-03-09 18:01:16 -04:00
}
2013-08-17 05:16:48 -04:00
}