class StateIntegrationTest in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/service_container/Tests/StateIntegrationTest.php \Drupal\service_container\Tests\StateIntegrationTest
Hierarchy
- class \Drupal\service_container\Tests\ServiceContainerIntegrationTestBase extends \Drupal\service_container\Tests\DrupalWebTestCase
- class \Drupal\service_container\Tests\StateIntegrationTest
Expanded class hierarchy of StateIntegrationTest
File
- lib/
Drupal/ service_container/ Tests/ StateIntegrationTest.php, line 10 - Contains \Drupal\service_container\Tests\StateIntegrationTest.
Namespace
Drupal\service_container\TestsView source
class StateIntegrationTest extends ServiceContainerIntegrationTestBase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'State',
'description' => 'Tests the state system',
'group' => 'service_container',
);
}
public function testState() {
/** @var \Drupal\Core\State\StateInterface $state */
$state = \Drupal::service('state');
$this
->assertEqual(NULL, $state
->get('not-existing'));
$this
->assertEqual('default', $state
->get('not-existing', 'default'));
$state
->set('key', 'value');
$this
->assertEqual('value', $state
->get('key'));
$state
->setMultiple(array(
'key1' => 'value1',
'key2' => 'value2',
));
$this
->assertEqual(array(
'key1' => 'value1',
'key2' => 'value2',
), $state
->getMultiple(array(
'key1',
'key2',
)));
$state
->delete('key1');
$this
->assertEqual(array(
'key2' => 'value2',
), $state
->getMultiple(array(
'key1',
'key2',
)));
$state
->deleteMultiple(array(
'key2',
));
$this
->assertEqual(array(), $state
->getMultiple(array(
'key1',
'key2',
)));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ServiceContainerIntegrationTestBase:: |
protected | property | The dependency injection container usable in the test. | |
ServiceContainerIntegrationTestBase:: |
protected | property | The profile to install as a basis for testing. | 1 |
ServiceContainerIntegrationTestBase:: |
protected | function | 5 | |
StateIntegrationTest:: |
public static | function | ||
StateIntegrationTest:: |
public | function |