PHP code example of ixis / codeception-module-drupal-user-registry

1. Go to this page and download the library: Download ixis/codeception-module-drupal-user-registry library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ixis / codeception-module-drupal-user-registry example snippets


// Returns a DrupalTestUser object representing the test user available for
// this role.
$user = $I->getUserByRole($roleName);

// Returns a DrupalTestUser object representing the test user available for
// exactly these roles.
$user = $I->getUserByRole([$roleName1, $roleName2]);

// Returns a DrupalTestUser object representing the user, or false if no users
// were found. Note this will only return a user defined and managed by this
// module, it will not return information about arbitrary accounts on the site
// being tested.
$user = $I->getUser($userName);

// Returns an indexed array of configured roles, for example:
//   array(
//     0 => 'administrator',
//     1 => 'editor',
//     2 => ...
//   );
$roles = $I->getRoles();

// Returns a DrupalTestUser object representing the "root" user (account with
// uid 1), if credentials are configured:
$rootUser = $I->getRootUser();

// Also provided are a few utility methods that can be used in tests to
// store and retrieve a DrupalTestUser object representing the logged in user.
// Note these methods don't actually log a user in or out - that currently
// needs to be handled elsewhere.
$I->setLoggedInUser($I->getUserByRole('administrator'));
$I->getLoggedInUser();
$I->removeLoggedInUser();