You are here

SimpleFbConnectFbManagerTest.php in Simple FB Connect 8.3

File

tests/src/Unit/SimpleFbConnectFbManagerTest.php
View source
<?php

namespace Drupal\Tests\simple_fb_connect\Unit;

use Drupal\Tests\UnitTestCase;
use Drupal\simple_fb_connect\SimpleFbConnectFbManager;

/**
 * @coversDefaultClass Drupal\simple_fb_connect\SimpleFbConnectFbManager
 * @group simple_fb_connect
 */
class SimpleFbConnectFbManagerTest extends UnitTestCase {
  protected $loggerFactory;
  protected $eventDispatcher;
  protected $entityFieldManager;
  protected $urlGenerator;
  protected $persistentDataHandler;
  protected $facebook;
  protected $fbManager;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->loggerFactory = $this
      ->getMock('Drupal\\Core\\Logger\\LoggerChannelFactoryInterface');
    $this->eventDispatcher = $this
      ->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
    $this->entityFieldManager = $this
      ->getMock('Drupal\\Core\\Entity\\EntityFieldManagerInterface');
    $this->urlGenerator = $this
      ->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
    $this->persistentDataHandler = $this
      ->getMockBuilder('Drupal\\simple_fb_connect\\SimpleFbConnectPersistentDataHandler')
      ->disableOriginalConstructor()
      ->getMock();
    $this->fbManager = new SimpleFbConnectFbManager($this->loggerFactory, $this->eventDispatcher, $this->entityFieldManager, $this->urlGenerator, $this->persistentDataHandler);
    $this->facebook = $this
      ->getMockBuilder('Facebook\\Facebook')
      ->disableOriginalConstructor()
      ->getMock();
    $this->fbManager
      ->setFacebookService($this->facebook);
  }

  /**
   * Tests getFbReRequestUrl method.
   *
   * @covers ::getFbReRequestUrl
   */
  public function testGetFbReRequestUrl() {
    $login_helper = $this
      ->getMockBuilder('Facebook\\Helpers\\FacebookRedirectLoginHelper')
      ->disableOriginalConstructor()
      ->getMock();
    $login_helper
      ->expects($this
      ->once())
      ->method('getReRequestUrl')
      ->willReturn('https://www.facebook.com/rerequest-url');
    $this->facebook
      ->expects($this
      ->once())
      ->method('getRedirectLoginHelper')
      ->willReturn($login_helper);
    $this->urlGenerator
      ->expects($this
      ->once())
      ->method('generateFromRoute')
      ->willReturn('http://www.example.com/user/simple-fb-connect/return');
    $this
      ->assertSame($this->fbManager
      ->getFbReRequestUrl(), 'https://www.facebook.com/rerequest-url');
  }

}

Classes

Namesort descending Description
SimpleFbConnectFbManagerTest @coversDefaultClass Drupal\simple_fb_connect\SimpleFbConnectFbManager @group simple_fb_connect