function BackendCompilerPassTest::providerTestProcess

Same name in other branches
  1. 9 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

Class

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

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function providerTestProcess() {
    $data = [];
    // Add a container with no set default_backend.
    $prefix = __NAMESPACE__ . '\\ServiceClass';
    $service = (new Definition($prefix . 'Default'))->addTag('backend_overridable');
    $container = $this->getMysqlContainer($service);
    $data[] = [
        $prefix . 'Default',
        $container,
    ];
    // Set the default_backend so the mysql service should be used.
    $container = $this->getMysqlContainer($service);
    $container->setParameter('default_backend', 'mysql');
    $data[] = [
        $prefix . 'Mysql',
        $container,
    ];
    // Configure a manual alias for the service, so ensure that it is not
    // overridden by the default backend.
    $container = $this->getMysqlContainer($service);
    $container->setParameter('default_backend', 'mysql');
    $container->setDefinition('mariadb.service', new Definition($prefix . 'MariaDb'));
    $container->setAlias('service', new Alias('mariadb.service'));
    $data[] = [
        $prefix . 'MariaDb',
        $container,
    ];
    // Check the database driver is the default.
    $container = $this->getSqliteContainer($service);
    $data[] = [
        $prefix . 'Sqlite',
        $container,
    ];
    // Test the opt out.
    $container = $this->getSqliteContainer($service);
    $container->setParameter('default_backend', '');
    $data[] = [
        $prefix . 'Default',
        $container,
    ];
    return $data;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.