You are here

public function BackendCompilerPassTest::providerTestProcess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\BackendCompilerPassTest::providerTestProcess()

Provides test data for testProcess().

Return value

array

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/BackendCompilerPassTest.php, line 59
Contains \Drupal\Tests\Core\DependencyInjection\Compiler\BackendCompilerPassTest.

Class

BackendCompilerPassTest
@coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\BackendCompilerPass @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function providerTestProcess() {
  $data = array();

  // Add a container with no set default_backend.
  $prefix = __NAMESPACE__ . '\\ServiceClass';
  $service = (new Definition($prefix . 'Default'))
    ->addTag('backend_overridable');
  $container = $this
    ->getMysqlContainer($service);
  $data[] = array(
    $prefix . 'Default',
    $container,
  );

  // Set the default_backend so the mysql service should be used.
  $container = $this
    ->getMysqlContainer($service);
  $container
    ->setParameter('default_backend', 'mysql');
  $data[] = array(
    $prefix . 'Mysql',
    $container,
  );

  // Configure a manual alias for the service, so ensure that it is not
  // overridden by the default backend.
  $container = clone $container;
  $container
    ->setDefinition('mariadb.service', new Definition($prefix . 'MariaDb'));
  $container
    ->setAlias('service', new Alias('mariadb.service'));
  $data[] = array(
    $prefix . 'MariaDb',
    $container,
  );

  // Check the database driver is the default.
  $container = $this
    ->getSqliteContainer($service);
  $data[] = array(
    $prefix . 'Sqlite',
    $container,
  );

  // Test the opt out.
  $container = $this
    ->getSqliteContainer($service);
  $container
    ->setParameter('default_backend', '');
  $data[] = array(
    $prefix . 'Default',
    $container,
  );
  return $data;
}