0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-18 12:11:41 +00:00
nextcloud_server/tests/lib/AppFramework/Http/TemplateResponseTest.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.7 KiB
PHP
Raw Normal View History

2013-08-17 11:16:48 +02: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 11:16:48 +02:00
*/
2016-05-18 18:40:34 +02:00
namespace Test\AppFramework\Http;
2013-08-17 11:16:48 +02:00
2014-03-09 23:01:16 +01:00
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\TemplateResponse;
2013-08-17 11:16:48 +02:00
class TemplateResponseTest extends \Test\TestCase {
/**
* @var \OCP\AppFramework\Http\TemplateResponse
*/
2013-08-17 11:16:48 +02:00
private $tpl;
protected function setUp(): void {
parent::setUp();
$this->tpl = new TemplateResponse('app', 'home');
2013-08-17 11:16:48 +02: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 11:16:48 +02:00
$this->tpl->setParams($params);
$this->assertEquals(['hi' => 'yo'], $this->tpl->getParams());
2013-08-17 11:16:48 +02:00
}
public function testGetTemplateName(): void {
2013-08-17 11:16:48 +02:00
$this->assertEquals('home', $this->tpl->getTemplateName());
}
public function testGetRenderAs(): void {
2013-08-17 11:16:48 +02:00
$render = 'myrender';
$this->tpl->renderAs($render);
$this->assertEquals($render, $this->tpl->getRenderAs());
}
2014-03-09 23:01:16 +01:00
public function testChainability(): void {
$params = ['hi' => 'yo'];
2014-03-09 23:01:16 +01: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 23:01:16 +01:00
}
2013-08-17 11:16:48 +02:00
}