From ef00f9d2033f6de11e71bf3a909399cae6f73a9f Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 27 May 2020 13:35:48 +0200 Subject: Process password change controller through Slim --- .../controller/visitor/DailyControllerTest.php | 14 ------------ .../controller/visitor/FeedControllerTest.php | 6 ----- .../visitor/FrontControllerMockHelper.php | 8 +------ .../controller/visitor/LoginControllerTest.php | 10 --------- .../visitor/OpenSearchControllerTest.php | 2 -- .../visitor/PictureWallControllerTest.php | 4 ---- .../visitor/ShaarliPublicControllerTest.php | 18 --------------- .../controller/visitor/TagCloudControllerTest.php | 12 ---------- .../front/controller/visitor/TagControllerTest.php | 26 ---------------------- 9 files changed, 1 insertion(+), 99 deletions(-) (limited to 'tests/front/controller/visitor') diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php index 6ff769fc..872420fd 100644 --- a/tests/front/controller/visitor/DailyControllerTest.php +++ b/tests/front/controller/visitor/DailyControllerTest.php @@ -27,8 +27,6 @@ class DailyControllerTest extends TestCase public function testValidIndexControllerInvokeDefault(): void { - $this->createValidContainerMockSet(); - $currentDay = new \DateTimeImmutable('2020-05-13'); $request = $this->createMock(Request::class); @@ -169,8 +167,6 @@ class DailyControllerTest extends TestCase */ public function testValidIndexControllerInvokeNoFutureOrPast(): void { - $this->createValidContainerMockSet(); - $currentDay = new \DateTimeImmutable('2020-05-13'); $request = $this->createMock(Request::class); @@ -243,8 +239,6 @@ class DailyControllerTest extends TestCase */ public function testValidIndexControllerInvokeHeightAdjustment(): void { - $this->createValidContainerMockSet(); - $currentDay = new \DateTimeImmutable('2020-05-13'); $request = $this->createMock(Request::class); @@ -314,8 +308,6 @@ class DailyControllerTest extends TestCase */ public function testValidIndexControllerInvokeNoBookmark(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -363,8 +355,6 @@ class DailyControllerTest extends TestCase */ public function testValidRssControllerInvokeDefault(): void { - $this->createValidContainerMockSet(); - $dates = [ new \DateTimeImmutable('2020-05-17'), new \DateTimeImmutable('2020-05-15'), @@ -439,8 +429,6 @@ class DailyControllerTest extends TestCase */ public function testValidRssControllerInvokeTriggerCache(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -465,8 +453,6 @@ class DailyControllerTest extends TestCase */ public function testValidRssControllerInvokeNoBookmark(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); diff --git a/tests/front/controller/visitor/FeedControllerTest.php b/tests/front/controller/visitor/FeedControllerTest.php index fd4679ea..fb417e2a 100644 --- a/tests/front/controller/visitor/FeedControllerTest.php +++ b/tests/front/controller/visitor/FeedControllerTest.php @@ -30,8 +30,6 @@ class FeedControllerTest extends TestCase */ public function testDefaultRssController(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -71,8 +69,6 @@ class FeedControllerTest extends TestCase */ public function testDefaultAtomController(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -112,8 +108,6 @@ class FeedControllerTest extends TestCase */ public function testAtomControllerWithParameters(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request->method('getParams')->willReturn(['parameter' => 'value']); $response = new Response(); diff --git a/tests/front/controller/visitor/FrontControllerMockHelper.php b/tests/front/controller/visitor/FrontControllerMockHelper.php index bc3266b5..d16b6949 100644 --- a/tests/front/controller/visitor/FrontControllerMockHelper.php +++ b/tests/front/controller/visitor/FrontControllerMockHelper.php @@ -31,18 +31,12 @@ trait FrontControllerMockHelper protected $container; /** - * Mock the container instance + * Mock the container instance and initialize container's services used by tests */ protected function createContainer(): void { $this->container = $this->createMock(ShaarliTestContainer::class); - } - /** - * Initialize container's services used by tests - */ - protected function createValidContainerMockSet(): void - { $this->container->loginManager = $this->createMock(LoginManager::class); // Config diff --git a/tests/front/controller/visitor/LoginControllerTest.php b/tests/front/controller/visitor/LoginControllerTest.php index 9d223316..faa8ac71 100644 --- a/tests/front/controller/visitor/LoginControllerTest.php +++ b/tests/front/controller/visitor/LoginControllerTest.php @@ -26,8 +26,6 @@ class LoginControllerTest extends TestCase public function testValidControllerInvoke(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request->expects(static::once())->method('getServerParam')->willReturn('> referer'); $response = new Response(); @@ -57,8 +55,6 @@ class LoginControllerTest extends TestCase public function testValidControllerInvokeWithUserName(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request->expects(static::once())->method('getServerParam')->willReturn('> referer'); $request->expects(static::exactly(2))->method('getParam')->willReturn('myUser>'); @@ -90,8 +86,6 @@ class LoginControllerTest extends TestCase public function testLoginControllerWhileLoggedIn(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -106,8 +100,6 @@ class LoginControllerTest extends TestCase public function testLoginControllerOpenShaarli(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -129,8 +121,6 @@ class LoginControllerTest extends TestCase public function testLoginControllerWhileBanned(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); diff --git a/tests/front/controller/visitor/OpenSearchControllerTest.php b/tests/front/controller/visitor/OpenSearchControllerTest.php index 52475318..5f9f5b12 100644 --- a/tests/front/controller/visitor/OpenSearchControllerTest.php +++ b/tests/front/controller/visitor/OpenSearchControllerTest.php @@ -24,8 +24,6 @@ class OpenSearchControllerTest extends TestCase public function testOpenSearchController(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); diff --git a/tests/front/controller/visitor/PictureWallControllerTest.php b/tests/front/controller/visitor/PictureWallControllerTest.php index 7ac842cb..3dc3f292 100644 --- a/tests/front/controller/visitor/PictureWallControllerTest.php +++ b/tests/front/controller/visitor/PictureWallControllerTest.php @@ -28,8 +28,6 @@ class PictureWallControllerTest extends TestCase public function testValidControllerInvokeDefault(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request->expects(static::once())->method('getQueryParams')->willReturn([]); $response = new Response(); @@ -106,8 +104,6 @@ class PictureWallControllerTest extends TestCase { $this->expectException(ThumbnailsDisabledException::class); - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); diff --git a/tests/front/controller/visitor/ShaarliPublicControllerTest.php b/tests/front/controller/visitor/ShaarliPublicControllerTest.php index e2e88da3..1f7d57ad 100644 --- a/tests/front/controller/visitor/ShaarliPublicControllerTest.php +++ b/tests/front/controller/visitor/ShaarliPublicControllerTest.php @@ -67,8 +67,6 @@ class ShaarliControllerTest extends TestCase public function testAssignView(): void { - $this->createValidContainerMockSet(); - $this->assignTemplateVars($this->assignedValues); $self = $this->controller->assignView('variableName', 'variableValue'); @@ -79,8 +77,6 @@ class ShaarliControllerTest extends TestCase public function testRender(): void { - $this->createValidContainerMockSet(); - $this->assignTemplateVars($this->assignedValues); $this->container->bookmarkService @@ -120,8 +116,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererDefault(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -137,8 +131,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithUnmatchedLoopTerm(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -154,8 +146,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithMatchingLoopTermInPath(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -171,8 +161,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithMatchingLoopTermInQueryParam(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -189,8 +177,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithMatchingLoopTermInQueryValue(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -207,8 +193,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithLoopTermInDomain(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); @@ -225,8 +209,6 @@ class ShaarliControllerTest extends TestCase */ public function testRedirectFromRefererWithMatchingClearedParam(): void { - $this->createValidContainerMockSet(); - $this->container->environment['HTTP_REFERER'] = 'http://shaarli.tld/subfolder/controller?query=param&other=2'; $response = new Response(); diff --git a/tests/front/controller/visitor/TagCloudControllerTest.php b/tests/front/controller/visitor/TagCloudControllerTest.php index e636d496..9a6a4bc0 100644 --- a/tests/front/controller/visitor/TagCloudControllerTest.php +++ b/tests/front/controller/visitor/TagCloudControllerTest.php @@ -28,8 +28,6 @@ class TagCloudControllerTest extends TestCase */ public function testValidCloudControllerInvokeDefault(): void { - $this->createValidContainerMockSet(); - $allTags = [ 'ghi' => 1, 'abc' => 3, @@ -94,8 +92,6 @@ class TagCloudControllerTest extends TestCase */ public function testValidCloudControllerInvokeWithParameters(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request ->method('getQueryParam') @@ -161,8 +157,6 @@ class TagCloudControllerTest extends TestCase */ public function testEmptyCloud(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -209,8 +203,6 @@ class TagCloudControllerTest extends TestCase */ public function testValidListControllerInvokeDefault(): void { - $this->createValidContainerMockSet(); - $allTags = [ 'def' => 12, 'abc' => 3, @@ -271,8 +263,6 @@ class TagCloudControllerTest extends TestCase */ public function testValidListControllerInvokeWithParameters(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request ->method('getQueryParam') @@ -336,8 +326,6 @@ class TagCloudControllerTest extends TestCase */ public function testEmptyList(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); diff --git a/tests/front/controller/visitor/TagControllerTest.php b/tests/front/controller/visitor/TagControllerTest.php index 9a2b1f71..1242a2e9 100644 --- a/tests/front/controller/visitor/TagControllerTest.php +++ b/tests/front/controller/visitor/TagControllerTest.php @@ -23,8 +23,6 @@ class TagControllerTest extends TestCase public function testAddTagWithReferer(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/']; $request = $this->createMock(Request::class); @@ -41,8 +39,6 @@ class TagControllerTest extends TestCase public function testAddTagWithRefererAndExistingSearch(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def']; $request = $this->createMock(Request::class); @@ -59,8 +55,6 @@ class TagControllerTest extends TestCase public function testAddTagWithoutRefererAndExistingSearch(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -75,8 +69,6 @@ class TagControllerTest extends TestCase public function testAddTagRemoveLegacyQueryParam(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def&addtag=abc']; $request = $this->createMock(Request::class); @@ -93,8 +85,6 @@ class TagControllerTest extends TestCase public function testAddTagResetPagination(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def&page=12']; $request = $this->createMock(Request::class); @@ -111,8 +101,6 @@ class TagControllerTest extends TestCase public function testAddTagWithRefererAndEmptySearch(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=']; $request = $this->createMock(Request::class); @@ -129,8 +117,6 @@ class TagControllerTest extends TestCase public function testAddTagWithoutNewTagWithReferer(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def']; $request = $this->createMock(Request::class); @@ -145,8 +131,6 @@ class TagControllerTest extends TestCase public function testAddTagWithoutNewTagWithoutReferer(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -159,8 +143,6 @@ class TagControllerTest extends TestCase public function testRemoveTagWithoutMatchingTag(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def']; $request = $this->createMock(Request::class); @@ -177,8 +159,6 @@ class TagControllerTest extends TestCase public function testRemoveTagWithoutTagsearch(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/']; $request = $this->createMock(Request::class); @@ -195,8 +175,6 @@ class TagControllerTest extends TestCase public function testRemoveTagWithoutReferer(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -211,8 +189,6 @@ class TagControllerTest extends TestCase public function testRemoveTagWithoutTag(): void { - $this->createValidContainerMockSet(); - $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtag=abc']; $request = $this->createMock(Request::class); @@ -227,8 +203,6 @@ class TagControllerTest extends TestCase public function testRemoveTagWithoutTagWithoutReferer(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); -- cgit v1.2.3