class TestSimpleFbConnectUserManager in Simple FB Connect 8.3
Same name and namespace in other branches
- 8.2 tests/src/Unit/TestSimpleFbConnectUserManager.php \Drupal\Tests\simple_fb_connect\Unit\TestSimpleFbConnectUserManager
This subclass overrides methods that call procedural Drupal functions.
SimpleFbConnectUserManager needs to call procedural Drupal functions, for example user_login_finalize(). These procedural methods are wrapped to methods like userLoginFinalize() in SimpleFbConnectUserManager so that this subclass can override the methods with dummy values for unit testing purposes.
This subclass is also used to unit test the protected methods where needed.
Hierarchy
- class \Drupal\simple_fb_connect\SimpleFbConnectUserManager uses StringTranslationTrait
- class \Drupal\Tests\simple_fb_connect\Unit\TestSimpleFbConnectUserManager
Expanded class hierarchy of TestSimpleFbConnectUserManager
File
- tests/
src/ Unit/ TestSimpleFbConnectUserManager.php, line 19
Namespace
Drupal\Tests\simple_fb_connect\UnitView source
class TestSimpleFbConnectUserManager extends SimpleFbConnectUserManager {
/**
* Allows us to modify the configuration for some test cases.
*/
public function setConfigFactory($new_factory) {
$this->configFactory = $new_factory;
}
/**
* Overrides userLoginFinalize.
*/
protected function userLoginFinalize(UserInterface $account) {
return NULL;
}
/**
* Overrides userPassword.
*/
protected function userPassword($length) {
return "12345";
}
/**
* Public method to help unit testing generateUniqueUsername().
*/
public function subGenerateUniqueUsername($fb_name) {
return $this
->generateUniqueUsername($fb_name);
}
/**
* Public method to help unit testing downloadProfilePic().
*/
public function subDownloadProfilePic($picture_url, $fbid) {
return $this
->downloadProfilePic($picture_url, $fbid);
}
/**
* Overrides filePrepareDirectory.
*/
public function filePrepareDirectory(&$directory, $options) {
// Return FALSE for simulating a directory which is not writeable.
if ($directory == 'not/writeable/directory') {
return FALSE;
}
// Return TRUE for all other directories.
return TRUE;
}
/**
* Overrides systemRetrieveFile.
*/
public function systemRetrieveFile($url, $destination, $managed, $replace) {
// Simulate succesfull download by returning a file object.
$file = $this->entityTypeManager
->getStorage('file')
->create();
return $file;
}
/**
* Overrides drupalSetMessage.
*/
protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
protected | property | ||
SimpleFbConnectUserManager:: |
public | function | Create a new user account. | |
SimpleFbConnectUserManager:: |
protected | function | Downloads the profile picture to Drupal filesystem. | |
SimpleFbConnectUserManager:: |
protected | function | Ensures that Drupal usernames will be unique. | |
SimpleFbConnectUserManager:: |
protected | function | Returns the status for new users. | |
SimpleFbConnectUserManager:: |
protected | function | Returns picture directory if site supports the user picture feature. | |
SimpleFbConnectUserManager:: |
public | function | Loads existing Drupal user object by given property and value. | |
SimpleFbConnectUserManager:: |
protected | function | Checks if the user has one of the "FB login disabled" roles. | |
SimpleFbConnectUserManager:: |
protected | function | Checks if current user is admin and admin login via FB is disabled. | |
SimpleFbConnectUserManager:: |
public | function | Logs the user in. | |
SimpleFbConnectUserManager:: |
protected | function | Checks if user registration is blocked in Drupal account settings. | |
SimpleFbConnectUserManager:: |
public | function | Downloads and sets user profile picture. | |
SimpleFbConnectUserManager:: |
protected | function | Returns whether this site supports the default user picture feature. | |
SimpleFbConnectUserManager:: |
protected | function | Checks if user pictures are enabled and required. | |
SimpleFbConnectUserManager:: |
public | function | Constructor. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TestSimpleFbConnectUserManager:: |
protected | function |
Overrides drupalSetMessage. Overrides SimpleFbConnectUserManager:: |
|
TestSimpleFbConnectUserManager:: |
public | function |
Overrides filePrepareDirectory. Overrides SimpleFbConnectUserManager:: |
|
TestSimpleFbConnectUserManager:: |
public | function | Allows us to modify the configuration for some test cases. | |
TestSimpleFbConnectUserManager:: |
public | function | Public method to help unit testing downloadProfilePic(). | |
TestSimpleFbConnectUserManager:: |
public | function | Public method to help unit testing generateUniqueUsername(). | |
TestSimpleFbConnectUserManager:: |
public | function |
Overrides systemRetrieveFile. Overrides SimpleFbConnectUserManager:: |
|
TestSimpleFbConnectUserManager:: |
protected | function |
Overrides userLoginFinalize. Overrides SimpleFbConnectUserManager:: |
|
TestSimpleFbConnectUserManager:: |
protected | function |
Overrides userPassword. Overrides SimpleFbConnectUserManager:: |