You are here

class GoogleAuthManagerTest in Social Auth Google 8

@coversDefaultClass Drupal\social_auth_google\GoogleAuthManager @group social_auth_google

Hierarchy

Expanded class hierarchy of GoogleAuthManagerTest

File

tests/src/Unit/GoogleAuthManagerTest.php, line 12

Namespace

Drupal\Tests\social_auth_google\Unit
View source
class GoogleAuthManagerTest extends UnitTestCase {

  /**
   * Session object.
   *
   * @var \Symfony\Component\HttpFoundation\Session\Session
   */
  protected $session;

  /**
   * Request object.
   *
   * @var \Symfony\Component\HttpFoundation\Request
   */
  protected $request;

  /**
   * Google Client object.
   *
   * @var \Google_Client
   */
  protected $client;

  /**
   * Google Authentication manager.
   *
   * @var \Drupal\social_auth_google\GoogleAuthManager
   */
  protected $googleManager;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->session = $this
      ->getMock('\\Symfony\\Component\\HttpFoundation\\Session\\Session');
    $this->request = $this
      ->getMock('\\Symfony\\Component\\HttpFoundation\\RequestStack');
    $this->googleManager = new GoogleAuthManager($this->session, $this->request);
    $this->client = $this
      ->getMockBuilder('\\Google_Client')
      ->disableOriginalConstructor()
      ->getMock();
  }

  /**
   * Tests set Google_Client object.
   *
   * @covers ::setClient
   */
  public function testSetGoogleClient() {
    $this
      ->assertInstanceOf('Drupal\\social_auth_google\\GoogleAuthManager', $this
      ->setClient());
  }

  /**
   * Tests get Google_Client object.
   *
   * @covers ::getClient
   * @covers ::saveAccessToken
   * @covers ::createService
   */
  public function testGetGoogleClient() {
    $this
      ->setClient();
    $this
      ->assertInstanceOf('Google_Client', $this->googleManager
      ->getClient());
  }

  /**
   * Sets \Google_Client object to GoogleAuthManager.
   *
   * @return \Drupal\social_auth_google\GoogleAuthManager
   *   setClient() returns $this, the GoogleAuthManager object.
   */
  protected function setClient() {
    return $this->googleManager
      ->setClient($this->client);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GoogleAuthManagerTest::$client protected property Google Client object.
GoogleAuthManagerTest::$googleManager protected property Google Authentication manager.
GoogleAuthManagerTest::$request protected property Request object.
GoogleAuthManagerTest::$session protected property Session object.
GoogleAuthManagerTest::setClient protected function Sets \Google_Client object to GoogleAuthManager.
GoogleAuthManagerTest::setUp protected function Overrides UnitTestCase::setUp
GoogleAuthManagerTest::testGetGoogleClient public function Tests get Google_Client object.
GoogleAuthManagerTest::testSetGoogleClient public function Tests set Google_Client object.
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.