]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Password change: UT use case with open shaarli
authorArthurHoaro <arthur@hoa.ro>
Wed, 27 May 2020 12:18:07 +0000 (14:18 +0200)
committerArthurHoaro <arthur@hoa.ro>
Thu, 23 Jul 2020 19:19:21 +0000 (21:19 +0200)
tests/front/controller/admin/PasswordControllerTest.php

index 7262243eaf3d34b49196e4f42eecd60d756b44a7..9a01089e2ddecd3747e54a968b846e35c091bdaa 100644 (file)
@@ -6,6 +6,7 @@ namespace Shaarli\Front\Controller\Admin;
 
 use PHPUnit\Framework\TestCase;
 use Shaarli\Config\ConfigManager;
+use Shaarli\Front\Exception\OpenShaarliPasswordException;
 use Shaarli\Front\Exception\WrongTokenException;
 use Shaarli\Security\SessionManager;
 use Slim\Http\Request;
@@ -183,4 +184,20 @@ class PasswordControllerTest extends TestCase
         static::assertSame('changepassword', (string) $result->getBody());
         static::assertSame('Change password - Shaarli', $this->assignedVariables['pagetitle']);
     }
+
+    /**
+     * Change the password on an open shaarli
+     */
+    public function testPostNewPasswordOnOpenShaarli(): void
+    {
+        $this->container->conf = $this->createMock(ConfigManager::class);
+        $this->container->conf->method('get')->with('security.open_shaarli')->willReturn(true);
+
+        $request = $this->createMock(Request::class);
+        $response = new Response();
+
+        $this->expectException(OpenShaarliPasswordException::class);
+
+        $this->controller->change($request, $response);
+    }
 }