3 namespace Drupal\Tests\outside_in\Unit;
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;
12 * @coversDefaultClass \Drupal\outside_in\OutsideInManager
15 class OutsideInManagerTest extends UnitTestCase {
18 * @covers ::isApplicable
19 * @dataProvider providerTestIsApplicable
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);
25 $route_match = $this->prophesize(RouteMatchInterface::class);
26 $route_match->getRouteName()->willReturn($route_name);
28 $account = $this->prophesize(AccountInterface::class);
29 $account->hasPermission('administer blocks')->willReturn($has_permission);
31 $outside_in_manager = new OutsideInManager($admin_context->reveal(), $route_match->reveal(), $account->reveal());
33 $this->assertSame($expected, $outside_in_manager->isApplicable());
37 * Data provider for ::testIsApplicable().
39 public function providerTestIsApplicable() {
42 // Passing combination.
43 $data[] = [FALSE, 'the_route_name', TRUE, TRUE];
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];