summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-02-04 08:54:56 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-02-06 11:26:18 +0100
commitb68567e9ba5b4b081378061bf938b5b505638fb3 (patch)
tree801af720fe93b968a225e852cdbc582bb352a632 /tests
parentd88604015a0828e78a05bf7f1ee80bb78f980dae (diff)
downloadnextcloud-server-b68567e9ba5b4b081378061bf938b5b505638fb3.tar.gz
nextcloud-server-b68567e9ba5b4b081378061bf938b5b505638fb3.zip
Add StandaloneTemplateResponse
This can be used by pages that do not have the full Nextcloud UI. So notifications etc do not load there. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/ClientFlowLoginControllerTest.php10
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php6
-rw-r--r--tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php17
3 files changed, 25 insertions, 8 deletions
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php
index 9230cfb4af2..eddcc1bbdb9 100644
--- a/tests/Core/Controller/ClientFlowLoginControllerTest.php
+++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php
@@ -30,7 +30,7 @@ use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Defaults;
use OCP\IL10N;
use OCP\IRequest;
@@ -108,7 +108,7 @@ class ClientFlowLoginControllerTest extends TestCase {
}
public function testShowAuthPickerPageNoClientOrOauthRequest() {
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'error',
[
@@ -166,7 +166,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('getServerProtocol')
->willReturn('https');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'loginflow/authpicker',
[
@@ -225,7 +225,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('getServerProtocol')
->willReturn('https');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'loginflow/authpicker',
[
@@ -253,7 +253,7 @@ class ClientFlowLoginControllerTest extends TestCase {
->method('remove')
->with('client.flow.state.token');
- $expected = new TemplateResponse(
+ $expected = new StandaloneTemplateResponse(
'core',
'403',
[
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index 6a01c510ed2..a405914cc47 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -27,7 +27,7 @@ use OC\Authentication\TwoFactorAuth\ProviderSet;
use OC\Core\Controller\TwoFactorChallengeController;
use OC_Util;
use OCP\AppFramework\Http\RedirectResponse;
-use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\TwoFactorException;
use OCP\IRequest;
@@ -100,7 +100,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
->with($user)
->will($this->returnValue($providerSet));
- $expected = new TemplateResponse('core', 'twofactorselectchallenge', [
+ $expected = new StandaloneTemplateResponse('core', 'twofactorselectchallenge', [
'providers' => [
$p1,
],
@@ -151,7 +151,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('fetchPage')
->will($this->returnValue('<html/>'));
- $expected = new TemplateResponse('core', 'twofactorshowchallenge', [
+ $expected = new StandaloneTemplateResponse('core', 'twofactorshowchallenge', [
'error' => true,
'provider' => $provider,
'backupProvider' => $backupProvider,
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
index 2a789a848a3..7f817e03c1e 100644
--- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php
@@ -27,6 +27,7 @@ namespace Test\AppFramework\Middleware;
use OC\AppFramework\Middleware\AdditionalScriptsMiddleware;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Http\StandaloneTemplateResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\PublicShareController;
use OCP\IUserSession;
@@ -77,6 +78,22 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
$this->middleWare->afterController($this->createMock(PublicShareController::class), 'myMethod', $this->createMock(Response::class));
}
+ public function testStandaloneTemplateResponse() {
+ $this->dispatcher->expects($this->once())
+ ->method('dispatch')
+ ->willReturnCallback(function($eventName) {
+ if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) {
+ return;
+ }
+
+ $this->fail('Wrong event dispatched');
+ });
+ $this->userSession->expects($this->never())
+ ->method($this->anything());
+
+ $this->middleWare->afterController($this->controller, 'myMethod', $this->createMock(StandaloneTemplateResponse::class));
+ }
+
public function testTemplateResponseNotLoggedIn() {
$this->dispatcher->expects($this->once())
->method('dispatch')