You are here

public function RouteSubscriberTest::testEnabledReplicateFunctionality in Replicate UI 8

@covers ::onRouteBuild

File

tests/src/Unit/RouteSubscriberTest.php, line 41

Class

RouteSubscriberTest
@coversDefaultClass \Drupal\replicate_ui\RouteSubscriber @group replicate

Namespace

Drupal\Tests\replicate_ui\Unit

Code

public function testEnabledReplicateFunctionality() {
  $em = $this
    ->setupEntityManager();
  $config_manager = $this
    ->getConfigFactoryStub([
    'replicate_ui.settings' => [
      'entity_types' => [
        'entity_test_1',
        'entity_test_2',
      ],
    ],
  ]);
  $subscriber = new RouteSubscriber($em
    ->reveal(), $config_manager);
  $routes = $this
    ->setupRouteCollection();
  $event = new RouteBuildEvent($routes);
  $this
    ->assertCount(4, $routes);
  $subscriber
    ->onRouteBuild($event);
  $this
    ->assertCount(6, $routes);
  $this
    ->assertEquals('/entity_test_1/{entity_test_1}/replicate', $routes
    ->get('entity.entity_test_1.replicate')
    ->getPath());
  $this
    ->assertEquals('entity_test_1.replicate', $routes
    ->get('entity.entity_test_1.replicate')
    ->getDefault('_entity_form'));
  $this
    ->assertFalse($routes
    ->get('entity.entity_test_1.replicate')
    ->hasOption('_admin_route'));
  $this
    ->assertEquals('/entity_test_2/{entity_test_2}/replicate', $routes
    ->get('entity.entity_test_2.replicate')
    ->getPath());
  $this
    ->assertEquals('entity_test_2.replicate', $routes
    ->get('entity.entity_test_2.replicate')
    ->getDefault('_entity_form'));
  $this
    ->assertTrue($routes
    ->get('entity.entity_test_2.replicate')
    ->getOption('_admin_route'));
}