Skip to content
This repository was archived by the owner on May 1, 2019. It is now read-only.

Commit 61fd11f

Browse files
committed
Merge pull request #478 from localheinz/fix/assert-route-names
Fix: Assert route names
2 parents 510f49b + 0bb56aa commit 61fd11f

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

module/Application/test/ApplicationTest/Integration/Controller/ContributorsControllerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public function testContributorsActionCanBeAccessed()
9090

9191
$this->dispatch('/contributors');
9292

93+
$this->assertMatchedRouteName('contributors');
94+
9395
$this->assertControllerName(Controller\ContributorsController::class);
9496
$this->assertActionName('index');
9597
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);

module/Application/test/ApplicationTest/Integration/Controller/IndexControllerTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function testIndexActionCanBeAccessed()
6969

7070
$this->dispatch('/');
7171

72+
$this->assertMatchedRouteName('home');
73+
7274
$this->assertControllerName(Controller\IndexController::class);
7375
$this->assertActionName('index');
7476
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
@@ -101,6 +103,8 @@ public function testFeedActionCanBeAccessed()
101103

102104
$this->dispatch('/feed');
103105

106+
$this->assertMatchedRouteName('feed');
107+
104108
$this->assertControllerName(Controller\IndexController::class);
105109
$this->assertActionName('feed');
106110
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);

module/Application/test/ApplicationTest/Integration/Controller/SearchControllerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function testIndexActionCanBeAccessed()
3838

3939
$this->dispatch('/live-search');
4040

41+
$this->assertMatchedRouteName('live-search');
42+
4143
$this->assertControllerName(Controller\SearchController::class);
4244
$this->assertActionName('index');
4345
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);

module/User/test/UserTest/Integration/Controller/UserControllerTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function testIndexActionRedirectsIfNotAuthenticated()
3232

3333
$this->dispatch('/user');
3434

35+
$this->assertMatchedRouteName('scn-social-auth-user');
36+
3537
$this->assertControllerName('zfcuser');
3638
$this->assertActionName('index');
3739
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -103,6 +105,8 @@ public function testIndexActionSetsModulesIfAuthenticated()
103105

104106
$this->dispatch('/user');
105107

108+
$this->assertMatchedRouteName('scn-social-auth-user');
109+
106110
$this->assertControllerName('zfcuser');
107111
$this->assertActionName('index');
108112
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);

module/ZfModule/test/ZfModuleTest/Integration/Controller/ModuleControllerTest.php

+44-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function testIndexActionRedirectsIfNotAuthenticated()
3939

4040
$this->dispatch('/module');
4141

42+
$this->assertMatchedRouteName('zf-module');
43+
4244
$this->assertControllerName(Controller\ModuleController::class);
4345
$this->assertActionName('index');
4446
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -79,6 +81,8 @@ public function testIndexActionFetches100MostRecentlyUpdatedUserRepositories()
7981

8082
$this->dispatch('/module');
8183

84+
$this->assertMatchedRouteName('zf-module');
85+
8286
$this->assertControllerName(Controller\ModuleController::class);
8387
$this->assertActionName('index');
8488
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
@@ -151,6 +155,8 @@ public function testIndexActionRendersUnregisteredModulesOnly()
151155

152156
$this->dispatch('/module');
153157

158+
$this->assertMatchedRouteName('zf-module');
159+
154160
$this->assertControllerName(Controller\ModuleController::class);
155161
$this->assertActionName('index');
156162
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
@@ -181,6 +187,8 @@ public function testListActionRedirectsIfNotAuthenticated()
181187

182188
$this->dispatch($url);
183189

190+
$this->assertMatchedRouteName('zf-module/list');
191+
184192
$this->assertControllerName(Controller\ModuleController::class);
185193
$this->assertActionName('list');
186194
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -223,6 +231,8 @@ public function testListActionFetches100MostRecentlyUpdatedRepositoriesWhenNoOwn
223231

224232
$this->dispatch('/module/list');
225233

234+
$this->assertMatchedRouteName('zf-module/list');
235+
226236
$this->assertControllerName(Controller\ModuleController::class);
227237
$this->assertActionName('list');
228238
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
@@ -331,6 +341,8 @@ public function testListActionFetches100MostRecentlyUpdatedRepositoriesWithOwner
331341

332342
$this->dispatch($url);
333343

344+
$this->assertMatchedRouteName('zf-module/list');
345+
334346
$this->assertControllerName(Controller\ModuleController::class);
335347
$this->assertActionName('list');
336348
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
@@ -410,11 +422,12 @@ public function testListActionRendersUnregisteredModulesOnly()
410422

411423
$this->dispatch($url);
412424

425+
$this->assertMatchedRouteName('zf-module/list');
426+
413427
$this->assertControllerName(Controller\ModuleController::class);
414428
$this->assertActionName('list');
415429
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);
416430

417-
/* @var Mvc\Application $application */
418431
$viewModel = $this->getApplication()->getMvcEvent()->getViewModel();
419432

420433
$this->assertTrue($viewModel->terminate());
@@ -433,6 +446,8 @@ public function testAddActionRedirectsIfNotAuthenticated()
433446

434447
$this->dispatch('/module/add');
435448

449+
$this->assertMatchedRouteName('zf-module/add');
450+
436451
$this->assertControllerName(Controller\ModuleController::class);
437452
$this->assertActionName('add');
438453
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -454,6 +469,8 @@ public function testAddActionThrowsInvalidDataExceptionIfNotPostedTo($method)
454469
$method
455470
);
456471

472+
$this->assertMatchedRouteName('zf-module/add');
473+
457474
$this->assertControllerName(Controller\ModuleController::class);
458475
$this->assertActionName('add');
459476
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -525,6 +542,8 @@ public function testAddActionThrowsRepositoryExceptionIfUnableToFetchRepositoryM
525542
]
526543
);
527544

545+
$this->assertMatchedRouteName('zf-module/add');
546+
528547
$this->assertControllerName(Controller\ModuleController::class);
529548
$this->assertActionName('add');
530549
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -586,6 +605,8 @@ public function testAddActionThrowsRepositoryExceptionWhenRepositoryHasInsuffici
586605
]
587606
);
588607

608+
$this->assertMatchedRouteName('zf-module/add');
609+
589610
$this->assertControllerName(Controller\ModuleController::class);
590611
$this->assertActionName('add');
591612
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -675,6 +696,8 @@ public function testAddActionThrowsRepositoryExceptionWhenRepositoryIsNotAModule
675696
]
676697
);
677698

699+
$this->assertMatchedRouteName('zf-module/add');
700+
678701
$this->assertControllerName(Controller\ModuleController::class);
679702
$this->assertActionName('add');
680703
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -759,6 +782,8 @@ public function testAddActionRegistersRepositoryIfPermissionsAreSufficientAndItI
759782
]
760783
);
761784

785+
$this->assertMatchedRouteName('zf-module/add');
786+
762787
$this->assertControllerName(Controller\ModuleController::class);
763788
$this->assertActionName('add');
764789
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -772,6 +797,8 @@ public function testRemoveActionRedirectsIfNotAuthenticated()
772797

773798
$this->dispatch('/module/remove');
774799

800+
$this->assertMatchedRouteName('zf-module/remove');
801+
775802
$this->assertControllerName(Controller\ModuleController::class);
776803
$this->assertActionName('remove');
777804
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -793,6 +820,8 @@ public function testRemoveActionThrowsInvalidDataExceptionIfNotPostedTo($method)
793820
$method
794821
);
795822

823+
$this->assertMatchedRouteName('zf-module/remove');
824+
796825
$this->assertControllerName(Controller\ModuleController::class);
797826
$this->assertActionName('remove');
798827
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -846,6 +875,8 @@ public function testRemoveActionThrowsRepositoryExceptionIfUnableToFetchReposito
846875
]
847876
);
848877

878+
$this->assertMatchedRouteName('zf-module/remove');
879+
849880
$this->assertControllerName(Controller\ModuleController::class);
850881
$this->assertActionName('remove');
851882
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -907,6 +938,8 @@ public function testRemoveActionThrowsRepositoryExceptionWhenRepositoryHasInsuff
907938
]
908939
);
909940

941+
$this->assertMatchedRouteName('zf-module/remove');
942+
910943
$this->assertControllerName(Controller\ModuleController::class);
911944
$this->assertActionName('remove');
912945
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -982,6 +1015,8 @@ public function testRemoveActionThrowsRepositoryExceptionWhenRepositoryNotPrevio
9821015
]
9831016
);
9841017

1018+
$this->assertMatchedRouteName('zf-module/remove');
1019+
9851020
$this->assertControllerName(Controller\ModuleController::class);
9861021
$this->assertActionName('remove');
9871022
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_500);
@@ -1067,6 +1102,8 @@ public function testRemoveActionDeletesModuleIfPermissionsAreSufficientAndItHasB
10671102
]
10681103
);
10691104

1105+
$this->assertMatchedRouteName('zf-module/remove');
1106+
10701107
$this->assertControllerName(Controller\ModuleController::class);
10711108
$this->assertActionName('remove');
10721109
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_302);
@@ -1107,6 +1144,8 @@ public function testViewActionSetsHttp404ResponseCodeIfModuleNotFound()
11071144

11081145
$this->dispatch($url);
11091146

1147+
$this->assertMatchedRouteName('view-module');
1148+
11101149
$this->assertControllerName(Controller\ModuleController::class);
11111150
$this->assertActionName('not-found');
11121151
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_404);
@@ -1164,6 +1203,8 @@ public function testViewActionSetsHttp404ResponseCodeIfRepositoryMetaDataNotFoun
11641203

11651204
$this->dispatch($url);
11661205

1206+
$this->assertMatchedRouteName('view-module');
1207+
11671208
$this->assertControllerName(Controller\ModuleController::class);
11681209
$this->assertActionName('not-found');
11691210
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_404);
@@ -1221,6 +1262,8 @@ public function testViewActionCanBeAccessed()
12211262

12221263
$this->dispatch($url);
12231264

1265+
$this->assertMatchedRouteName('view-module');
1266+
12241267
$this->assertControllerName(Controller\ModuleController::class);
12251268
$this->assertActionName('view');
12261269
}

module/ZfModule/test/ZfModuleTest/Integration/Controller/UserControllerTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function testUserPageCanBeAccessed()
5959

6060
$this->dispatch($url);
6161

62+
$this->assertMatchedRouteName('modules-for-user');
63+
6264
$this->assertControllerName(Controller\UserController::class);
6365
$this->assertActionName('modulesForUser');
6466
$this->assertResponseStatusCode(Http\Response::STATUS_CODE_200);

0 commit comments

Comments
 (0)