Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKonrad Abicht <hi@inspirito.de>2021-02-11 11:56:09 +0300
committerKonrad Abicht <hi@inspirito.de>2021-02-11 11:56:09 +0300
commitd60dd8a20855440625feca3758968b784b5fca9d (patch)
treeeb8be283757ab3d91903bdb1a3e6fe551fdda24f /tests
parentf29748a5e11bc1a86e47ce97dd00f6aaff183c36 (diff)
added unit tests for LoginFlowV2Service::startLoginFlow
Signed-off-by: Konrad Abicht <hi@inspirito.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Service/LoginFlowV2ServiceUnitTest.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
index 511c9be3271..58c558aada4 100644
--- a/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
+++ b/tests/Core/Service/LoginFlowV2ServiceUnitTest.php
@@ -21,6 +21,7 @@
namespace Tests\Core\Data;
+use Exception;
use OC\Core\Service\LoginFlowV2Service;
use OC\Core\Db\LoginFlowV2Mapper;
use OC\Core\Exception\LoginFlowV2NotFoundException;
@@ -244,4 +245,43 @@ class LoginFlowV2ServiceUnitTest extends TestCase {
$this->subjectUnderTest->getByLoginToken('test_token');
}
+
+ /*
+ * Tests for startLoginFlow
+ */
+
+ public function testStartLoginFlow() {
+ $loginFlowV2 = new LoginFlowV2();
+
+ $this->mapper->expects($this->once())
+ ->method('getByLoginToken')
+ ->willReturn($loginFlowV2);
+
+ $this->mapper->expects($this->once())
+ ->method('update');
+
+ $this->assertTrue($this->subjectUnderTest->startLoginFlow('test_token'));
+ }
+
+ public function testStartLoginFlowDoesNotExistException() {
+ $this->mapper->expects($this->once())
+ ->method('getByLoginToken')
+ ->willThrowException(new DoesNotExistException(''));
+
+ $this->assertFalse($this->subjectUnderTest->startLoginFlow('test_token'));
+ }
+
+ /**
+ * If an exception not of type DoesNotExistException is thrown,
+ * it is expected that it is not being handled by startLoginFlow.
+ */
+ public function testStartLoginFlowException() {
+ $this->expectException(Exception::class);
+
+ $this->mapper->expects($this->once())
+ ->method('getByLoginToken')
+ ->willThrowException(new Exception(''));
+
+ $this->subjectUnderTest->startLoginFlow('test_token');
+ }
}