Commit ed7f8ac4 authored by Dieter Holvoet's avatar Dieter Holvoet
Browse files

Issue #3283260 by DieterHolvoet: Adhere to Drupal Coding Standards

parent 651d3e85
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -5,11 +5,19 @@ namespace Drupal\dotenv;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;

class DotenvServiceProvider implements ServiceProviderInterface
{
    public function register(ContainerBuilder $container)
    {
/**
 * The dotenv service provider.
 *
 * Sets container parameters for configuring the Symfony Console commands.
 */
class DotenvServiceProvider implements ServiceProviderInterface {

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {
    $container->setParameter('dotenv.project_dir', DRUPAL_ROOT . '/..');
    $container->setParameter('dotenv.environment', $_ENV['APP_ENV'] ?? 'prod');
  }

}
+34 −28
Original line number Diff line number Diff line
@@ -7,17 +7,20 @@ use Drupal\dotenv\DotenvServiceProvider;
use Drupal\Tests\UnitTestCase;

/**
 * Tests the dotenv service provider
 * Tests the dotenv service provider.
 *
 * @coversDefaultClass \Drupal\dotenv\DotenvServiceProvider
 *
 * @group Dotenv
 */
class DotenvServiceProviderTest extends UnitTestCase
{
    /** @dataProvider dataProvider */
    public function testRegister(?string $appEnv, string $expectedEnv): void
    {
class DotenvServiceProviderTest extends UnitTestCase {

  /**
   * Tests the dotenv service provider.
   *
   * @dataProvider dataProvider
   */
  public function testRegister(?string $appEnv, string $expectedEnv): void {
    $container = new ContainerBuilder();
    $dotenvServiceProvider = new DotenvServiceProvider();
    $originalEnv = $_ENV['APP_ENV'];
@@ -29,17 +32,20 @@ class DotenvServiceProviderTest extends UnitTestCase
    static::assertEquals($expectedEnv, $container->getParameter('dotenv.environment'));
  }

    public function dataProvider(): array
    {
  /**
   * Provides some test cases.
   */
  public function dataProvider(): array {
    return [
      'When no APP_ENV is set, it fallback to "prod"' => [
                null,
        NULL,
        'prod',
      ],
      'It uses the APP_ENV to populate "dotenv.environment"' => [
        'foobar',
        'foobar',
            ]
      ],
    ];
  }

}
+14 −14

File changed.

Contains only whitespace changes.