class DrupalGetProfileLegacyTest in Drupal 8
Tests drupal_get_profile().
@group Bootstrap @group legacy @runTestsInSeparateProcesses @preserveGlobalState disabled
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\Core\Bootstrap\DrupalGetProfileLegacyTest
Expanded class hierarchy of DrupalGetProfileLegacyTest
See also
File
- core/
tests/ Drupal/ Tests/ Core/ Bootstrap/ DrupalGetProfileLegacyTest.php, line 17
Namespace
Drupal\Tests\Core\BootstrapView source
class DrupalGetProfileLegacyTest extends UnitTestCase {
/**
* Config storage profile.
*
* @var string
*/
protected $bootstrapConfigStorageProfile;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
include $this->root . '/core/includes/bootstrap.inc';
}
/**
* 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
*/
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());
}
/**
* Data provider for testDrupalGetProfileInstallState().
*
* @return array
* Test data.
*
* @see testDrupalGetProfileInstallState
*/
public function providerDrupalGetProfileInstallState() {
$tests = [];
$tests['install_state_with_profile'] = [
'test_profile',
[
'parameters' => [
'profile' => 'test_profile',
],
],
];
$tests['install_state_with_no_profile_overriding_container_profile'] = [
NULL,
[
'parameters' => [],
],
'test_profile',
];
$tests['no_install_state_with_container_profile'] = [
'container_profile',
NULL,
'container_profile',
];
return $tests;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalGetProfileLegacyTest:: |
protected | property | Config storage profile. | |
DrupalGetProfileLegacyTest:: |
public | function | Data provider for testDrupalGetProfileInstallState(). | |
DrupalGetProfileLegacyTest:: |
protected | function |
Overrides UnitTestCase:: |
|
DrupalGetProfileLegacyTest:: |
public | function | Tests drupal_get_profile() deprecation. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |