File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111use Drupal \node \Entity \NodeType ;
1212use Drupal \system \Entity \Menu ;
1313use Drupal \user \Entity \User ;
14+ use Drupal \user \Entity \Role ;
15+ use Drupal \user \RoleInterface ;
1416use Symfony \Component \HttpFoundation \Request ;
1517
1618/**
@@ -59,6 +61,18 @@ protected function setUp(): void {
5961 $ this ->installSchema ('node ' , ['node_access ' ]);
6062 $ this ->installConfig (['jsonapi_frontend ' ]);
6163
64+ // Allow anonymous users to access published content, so menu access checks
65+ // treat node links as accessible.
66+ $ anonymous = Role::load (RoleInterface::ANONYMOUS_ID );
67+ if (!$ anonymous ) {
68+ $ anonymous = Role::create ([
69+ 'id ' => RoleInterface::ANONYMOUS_ID ,
70+ 'label ' => 'Anonymous ' ,
71+ ]);
72+ }
73+ $ anonymous ->grantPermission ('access content ' );
74+ $ anonymous ->save ();
75+
6276 $ admin = User::create ([
6377 'name ' => 'admin ' ,
6478 'status ' => 1 ,
You can’t perform that action at this time.
0 commit comments