You are here

class TestSimpleFbConnectUserManager in Simple FB Connect 8.3

Same name and namespace in other branches
  1. 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

Expanded class hierarchy of TestSimpleFbConnectUserManager

File

tests/src/Unit/TestSimpleFbConnectUserManager.php, line 19

Namespace

Drupal\Tests\simple_fb_connect\Unit
View 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

Namesort descending Modifiers Type Description Overrides
SimpleFbConnectUserManager::$configFactory protected property
SimpleFbConnectUserManager::$entityFieldManager protected property
SimpleFbConnectUserManager::$entityTypeManager protected property
SimpleFbConnectUserManager::$eventDispatcher protected property
SimpleFbConnectUserManager::$languageManager protected property
SimpleFbConnectUserManager::$loggerFactory protected property
SimpleFbConnectUserManager::$token protected property
SimpleFbConnectUserManager::$transliteration protected property
SimpleFbConnectUserManager::createUser public function Create a new user account.
SimpleFbConnectUserManager::downloadProfilePic protected function Downloads the profile picture to Drupal filesystem.
SimpleFbConnectUserManager::generateUniqueUsername protected function Ensures that Drupal usernames will be unique.
SimpleFbConnectUserManager::getNewUserStatus protected function Returns the status for new users.
SimpleFbConnectUserManager::getPictureDirectory protected function Returns picture directory if site supports the user picture feature.
SimpleFbConnectUserManager::loadUserByProperty public function Loads existing Drupal user object by given property and value.
SimpleFbConnectUserManager::loginDisabledByRole protected function Checks if the user has one of the "FB login disabled" roles.
SimpleFbConnectUserManager::loginDisabledForAdmin protected function Checks if current user is admin and admin login via FB is disabled.
SimpleFbConnectUserManager::loginUser public function Logs the user in.
SimpleFbConnectUserManager::registrationBlocked protected function Checks if user registration is blocked in Drupal account settings.
SimpleFbConnectUserManager::setProfilePic Deprecated public function Downloads and sets user profile picture.
SimpleFbConnectUserManager::userPictureEnabled protected function Returns whether this site supports the default user picture feature.
SimpleFbConnectUserManager::userPictureRequired protected function Checks if user pictures are enabled and required.
SimpleFbConnectUserManager::__construct public function Constructor.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TestSimpleFbConnectUserManager::drupalSetMessage protected function Overrides drupalSetMessage. Overrides SimpleFbConnectUserManager::drupalSetMessage
TestSimpleFbConnectUserManager::filePrepareDirectory public function Overrides filePrepareDirectory. Overrides SimpleFbConnectUserManager::filePrepareDirectory
TestSimpleFbConnectUserManager::setConfigFactory public function Allows us to modify the configuration for some test cases.
TestSimpleFbConnectUserManager::subDownloadProfilePic public function Public method to help unit testing downloadProfilePic().
TestSimpleFbConnectUserManager::subGenerateUniqueUsername public function Public method to help unit testing generateUniqueUsername().
TestSimpleFbConnectUserManager::systemRetrieveFile public function Overrides systemRetrieveFile. Overrides SimpleFbConnectUserManager::systemRetrieveFile
TestSimpleFbConnectUserManager::userLoginFinalize protected function Overrides userLoginFinalize. Overrides SimpleFbConnectUserManager::userLoginFinalize
TestSimpleFbConnectUserManager::userPassword protected function Overrides userPassword. Overrides SimpleFbConnectUserManager::userPassword