@@ -51,41 +51,20 @@ class OgAdminRoutesControllerTest extends UnitTestCase {
5151 */
5252 protected $ routeMatch ;
5353
54- /**
55- * The event dispatcher service.
56- *
57- * @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher|\Prophecy\Prophecy\ObjectProphecy
58- */
59- protected $ eventDispatcher ;
60-
6154 /**
6255 * The group entity.
6356 *
6457 * @var \Drupal\Core\Entity\EntityInterface|\Prophecy\Prophecy\ObjectProphecy
6558 */
6659 protected $ group ;
6760
68- /**
69- * The OG admin route event.
70- *
71- * @var \Drupal\og\Event\OgAdminRoutesEvent
72- */
73- protected $ event ;
74-
7561 /**
7662 * The entity type ID of the group entity.
7763 *
7864 * @var string
7965 */
8066 protected $ entityTypeId ;
8167
82- /**
83- * The routes info as returned from the event subscribers.
84- *
85- * @var array
86- */
87- protected $ routesInfo ;
88-
8968 /**
9069 * The Url object.
9170 *
@@ -109,25 +88,11 @@ public function setUp() {
10988 $ this ->routeMatch = $ this ->prophesize (RouteMatchInterface::class);
11089
11190 $ this ->group = $ this ->prophesize (EntityInterface::class);
112- $ this ->event = $ this ->prophesize (OgAdminRoutesEvent::class);
113- $ this ->eventDispatcher = $ this ->prophesize (ContainerAwareEventDispatcher::class);
11491 $ this ->route = $ this ->prophesize (Route::class);
11592 $ this ->entityTypeId = $ this ->randomMachineName ();
11693 $ this ->entityId = rand (20 , 30 );
11794 $ this ->url = $ this ->prophesize (Url::class);
11895
119- $ this ->routesInfo = [
120- $ this ->randomMachineName () => [
121- 'title ' => $ this ->randomMachineName (),
122- 'description ' => $ this ->randomMachineName (),
123- ],
124-
125- $ this ->randomMachineName () => [
126- 'title ' => $ this ->randomMachineName (),
127- 'description ' => $ this ->randomMachineName (),
128- ],
129- ];
130-
13196 $ this
13297 ->routeMatch
13398 ->getRouteObject ()
@@ -142,7 +107,7 @@ public function setUp() {
142107
143108 $ this
144109 ->routeMatch
145- ->getParameter ($ parameter_name )
110+ ->getParameter (' group ' )
146111 ->willReturn ($ this ->group ->reveal ());
147112
148113 $ this
@@ -155,18 +120,6 @@ public function setUp() {
155120 ->id ()
156121 ->willReturn ($ this ->entityId );
157122
158- $ this
159- ->eventDispatcher
160- ->dispatch (OgAdminRoutesEventInterface::EVENT_NAME , Argument::type (OgAdminRoutesEvent::class))
161- ->willReturn ($ this ->event ->reveal ())
162- ->shouldBeCalled ();
163-
164- $ this
165- ->event
166- ->getRoutes ($ this ->entityTypeId )
167- ->willReturn ($ this ->routesInfo )
168- ->shouldBeCalled ();
169-
170123 // Set the container for the string translation service.
171124 $ translation = $ this ->getStringTranslationStub ();
172125 $ container = new ContainerBuilder ();
@@ -194,8 +147,8 @@ public function testRoutesWithAccess() {
194147 $ result = $ this ->getRenderElementResult (TRUE );
195148
196149 foreach ($ result ['og_admin_routes ' ]['#content ' ] as $ key => $ value ) {
197- $ this ->assertEquals ($ this -> routesInfo [ $ key ][ ' title ' ] , $ value ['title ' ]);
198- $ this ->assertEquals ($ this -> routesInfo [ $ key ][ ' description ' ] , $ value ['description ' ]);
150+ $ this ->assertEquals (' Members ' , $ value ['title ' ]);
151+ $ this ->assertEquals (' Manage members ' , $ value ['description ' ]);
199152 }
200153
201154 }
@@ -210,16 +163,16 @@ public function testRoutesWithAccess() {
210163 * The render array.
211164 */
212165 protected function getRenderElementResult ($ allow_access ) {
213- $ parameters = [$ this ->entityTypeId => $ this ->entityId ];
214- foreach ( array_keys ( $ this -> routesInfo ) as $ name ) {
215- $ route_name = "entity. { $ this -> entityTypeId } .og_admin_routes. $ name " ;
216- $ this
217- ->accessManager
218- ->checkNamedRoute ($ route_name , $ parameters )
219- ->willReturn ($ allow_access );
220- }
166+ $ parameters = [' entity_type_id ' => $ this ->entityTypeId , ' group ' => $ this ->entityId ];
167+
168+ $ route_name = "og_admin.members " ;
169+ $ this
170+ ->accessManager
171+ ->checkNamedRoute ($ route_name , $ parameters )
172+ ->willReturn ($ allow_access );
173+
221174
222- $ og_admin_routes_controller = new OgAdminRoutesController ($ this ->eventDispatcher -> reveal (), $ this -> accessManager ->reveal ());
175+ $ og_admin_routes_controller = new OgAdminRoutesController ($ this ->accessManager ->reveal ());
223176 return $ og_admin_routes_controller ->overview ($ this ->routeMatch ->reveal ());
224177 }
225178
0 commit comments