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;
class SimpleFbConnectFbManagerTest extends UnitTestCase {
protected $loggerFactory;
protected $eventDispatcher;
protected $entityFieldManager;
protected $urlGenerator;
protected $persistentDataHandler;
protected $facebook;
protected $fbManager;
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);
}
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');
}
}