db backup prior to drupal security update
[yaffs-website] / web / core / modules / outside_in / tests / src / Unit / OutsideInManagerTest.php
1 <?php
2
3 namespace Drupal\Tests\outside_in\Unit;
4
5 use Drupal\Core\Routing\AdminContext;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Drupal\Core\Session\AccountInterface;
8 use Drupal\outside_in\OutsideInManager;
9 use Drupal\Tests\UnitTestCase;
10
11 /**
12  * @coversDefaultClass \Drupal\outside_in\OutsideInManager
13  * @group outside_in
14  */
15 class OutsideInManagerTest extends UnitTestCase {
16
17   /**
18    * @covers ::isApplicable
19    * @dataProvider providerTestIsApplicable
20    */
21   public function testIsApplicable($is_admin_route, $route_name, $has_permission, $expected) {
22     $admin_context = $this->prophesize(AdminContext::class);
23     $admin_context->isAdminRoute()->willReturn($is_admin_route);
24
25     $route_match = $this->prophesize(RouteMatchInterface::class);
26     $route_match->getRouteName()->willReturn($route_name);
27
28     $account = $this->prophesize(AccountInterface::class);
29     $account->hasPermission('administer blocks')->willReturn($has_permission);
30
31     $outside_in_manager = new OutsideInManager($admin_context->reveal(), $route_match->reveal(), $account->reveal());
32
33     $this->assertSame($expected, $outside_in_manager->isApplicable());
34   }
35
36   /**
37    * Data provider for ::testIsApplicable().
38    */
39   public function providerTestIsApplicable() {
40     $data = [];
41
42     // Passing combination.
43     $data[] = [FALSE, 'the_route_name', TRUE, TRUE];
44
45     // Failing combinations.
46     $data[] = [TRUE, 'the_route_name', TRUE, FALSE];
47     $data[] = [TRUE, 'the_route_name', FALSE, FALSE];
48     $data[] = [TRUE, 'block.admin_demo', TRUE, FALSE];
49     $data[] = [TRUE, 'block.admin_demo', FALSE, FALSE];
50     $data[] = [FALSE, 'the_route_name', FALSE, FALSE];
51     $data[] = [FALSE, 'block.admin_demo', TRUE, FALSE];
52     $data[] = [FALSE, 'block.admin_demo', FALSE, FALSE];
53
54     return $data;
55   }
56
57 }