From b2d9c20aac35e92e7a7b6838e02c7170991ef352 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 2 Nov 2016 15:16:14 +0100 Subject: [PATCH] Fix unit tests Signed-off-by: Joas Schilling --- .../tests/Unit/Controller/SettingsControllerTest.php | 5 ++++- tests/Settings/Controller/AuthSettingsControllerTest.php | 4 +++- .../Middleware/Security/SecurityMiddlewareTest.php | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php index c7ac33467b3..8427c10e839 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php @@ -24,6 +24,7 @@ namespace OCA\TwoFactorBackupCodes\Tests\Unit\Controller; use OCA\TwoFactorBackupCodes\Controller\SettingsController; use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage; +use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; @@ -89,7 +90,9 @@ class SettingsControllerTest extends TestCase { 'codes' => $codes, 'state' => 'state', ]; - $this->assertEquals($expected, $this->controller->createCodes()); + $response = $this->controller->createCodes(); + $this->assertInstanceOf(JSONResponse::class, $response); + $this->assertEquals($expected, $response->getData()); } } diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php index 782c9f644e0..7fd985f29de 100644 --- a/tests/Settings/Controller/AuthSettingsControllerTest.php +++ b/tests/Settings/Controller/AuthSettingsControllerTest.php @@ -153,7 +153,9 @@ class AuthSettingsControllerTest extends TestCase { 'deviceToken' => ['dummy' => 'dummy', 'canDelete' => true], 'loginName' => 'User13', ]; - $this->assertEquals($expected, $this->controller->create($name)); + $response = $this->controller->create($name); + $this->assertInstanceOf(JSONResponse::class, $response); + $this->assertEquals($expected, $response->getData()); } public function testCreateSessionNotAvailable() { diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 1fdcf485c28..480bff5f59f 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -49,6 +49,7 @@ use OCP\IConfig; use OCP\ILogger; use OCP\INavigationManager; use OCP\IRequest; +use OCP\ISession; use OCP\IURLGenerator; use OCP\Security\ISecureRandom; @@ -63,6 +64,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { private $secException; /** @var SecurityException */ private $secAjaxException; + /** @var ISession|\PHPUnit_Framework_MockObject_MockObject */ + private $session; /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; /** @var ControllerMethodReflector */ @@ -88,6 +91,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->logger = $this->createMock(ILogger::class); $this->navigationManager = $this->createMock(INavigationManager::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); + $this->session = $this->createMock(ISession::class); $this->request = $this->createMock(IRequest::class); $this->contentSecurityPolicyManager = $this->createMock(ContentSecurityPolicyManager::class); $this->csrfTokenManager = $this->createMock(CsrfTokenManager::class); @@ -109,6 +113,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->navigationManager, $this->urlGenerator, $this->logger, + $this->session, 'files', $isLoggedIn, $isAdminUser, -- 2.39.5