class CurrentUserIntegrationTest in Service Container 7.2
Same name and namespace in other branches
- 7 lib/Drupal/service_container/Tests/CurrentUserIntegrationTest.php \Drupal\service_container\Tests\CurrentUserIntegrationTest
Hierarchy
- class \Drupal\service_container\Tests\ServiceContainerIntegrationTestBase extends \Drupal\service_container\Tests\DrupalWebTestCase
- class \Drupal\service_container\Tests\CurrentUserIntegrationTest
Expanded class hierarchy of CurrentUserIntegrationTest
File
- lib/
Drupal/ service_container/ Tests/ CurrentUserIntegrationTest.php, line 12 - Contains \Drupal\service_container\Tests\CurrentUserIntegrationTest.
Namespace
Drupal\service_container\TestsView source
class CurrentUserIntegrationTest extends ServiceContainerIntegrationTestBase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'CurrentUser',
'description' => 'Tests the current user integration',
'group' => 'service_container',
);
}
public function testCurrentUser() {
/** @var \Drupal\service_container\Session\Account $account */
$account_service = $this->container
->get('current_user');
$this
->assertTrue($account_service instanceof Account);
$admin_user = $this
->drupalCreateUser(array(
'access content',
));
$this
->drupalLogin($admin_user);
drupal_save_session(FALSE);
$GLOBALS['user'] = $admin_user;
$account = $this->container
->get('current_user');
$this
->assertEqual(spl_object_hash($account_service), spl_object_hash($account), 'Ensure that the object in the container stays the same.');
$this
->assertEqual($admin_user->uid, $account
->id());
$this
->assertEqual(array_keys($admin_user->roles), $account
->getRoles());
$this
->assertEqual(1, count($account
->getRoles(TRUE)));
$this
->assertEqual($admin_user->name, $account
->getUsername());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CurrentUserIntegrationTest:: |
public static | function | ||
CurrentUserIntegrationTest:: |
public | function | ||
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 |