You are here

public function DrupalGetProfileLegacyTest::testDrupalGetProfileLegacyInstallState in Drupal 8

Tests drupal_get_profile() deprecation.

@expectedDeprecation drupal_get_profile() is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use the install_profile container parameter or \Drupal::installProfile() instead. If you are accessing the value before it is written to configuration during the installer use the $install_state global. If you need to access the value before container is available you can use BootstrapConfigStorageFactory to load the value directly from configuration. See https://www.drupal.org/node/2538996 @dataProvider providerDrupalGetProfileInstallState

File

core/tests/Drupal/Tests/Core/Bootstrap/DrupalGetProfileLegacyTest.php, line 40

Class

DrupalGetProfileLegacyTest
Tests drupal_get_profile().

Namespace

Drupal\Tests\Core\Bootstrap

Code

public function testDrupalGetProfileLegacyInstallState($expected, array $install_state_array = NULL, $container_parameter = FALSE) {

  // Set up global for install state.
  global $install_state;
  $install_state = $install_state_array;

  // Set up the container.
  $container = new ContainerBuilder();
  $container
    ->setParameter('install_profile', $container_parameter);
  \Drupal::setContainer($container);

  // Do test.
  $this
    ->assertEquals($expected, drupal_get_profile());
}