class SimpleFbConnectFbFactoryTest in Simple FB Connect 8.3
@coversDefaultClass Drupal\simple_fb_connect\SimpleFbConnectFbFactory @group simple_fb_connect
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\simple_fb_connect\Unit\SimpleFbConnectFbFactoryTest
Expanded class hierarchy of SimpleFbConnectFbFactoryTest
File
- tests/
src/ Unit/ SimpleFbConnectFbFactoryTest.php, line 12
Namespace
Drupal\Tests\simple_fb_connect\UnitView source
class SimpleFbConnectFbFactoryTest extends UnitTestCase {
protected $configFactory;
protected $loggerFactory;
protected $persistentDataHandler;
protected $fbFactory;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->loggerFactory = $this
->getMock('Drupal\\Core\\Logger\\LoggerChannelFactoryInterface');
$this->persistentDataHandler = $this
->getMockBuilder('Drupal\\simple_fb_connect\\SimpleFbConnectPersistentDataHandler')
->disableOriginalConstructor()
->getMock();
}
/**
* Creates mocks with desired configFactory parameters.
*/
protected function finalizeSetup($app_id, $app_secret) {
$this->configFactory = $this
->getConfigFactoryStub([
'simple_fb_connect.settings' => [
'app_id' => $app_id,
'app_secret' => $app_secret,
],
]);
$this->fbFactory = new SimpleFbConnectFbFactory($this->configFactory, $this->loggerFactory, $this->persistentDataHandler);
}
/**
* Tests getFbService when app ID and app Secrete have been set.
*
* @covers ::getFbService
* @covers ::validateConfig
* @covers ::getAppId
* @covers ::getAppSecret
*/
public function testGetFbServiceWithGoodData() {
$this
->finalizeSetup('123', 'abc');
$this
->assertInstanceOf('Facebook\\Facebook', $this->fbFactory
->getFbService());
}
/**
* Tests getFbService with bad data.
*
* @covers ::getFbService
* @covers ::validateConfig
* @covers ::getAppId
* @covers ::getAppSecret
*
* @dataProvider getFbServiceBadDataProvider
*/
public function testGetFbServiceWithBadData($app_id, $app_secret) {
$logger_channel = $this
->getMockBuilder('Drupal\\Core\\Logger\\LoggerChannel')
->disableOriginalConstructor()
->getMock();
$this->loggerFactory
->expects($this
->any())
->method('get')
->with('simple_fb_connect')
->willReturn($logger_channel);
$this
->finalizeSetup($app_id, $app_secret);
$this
->assertFalse($this->fbFactory
->getFbService());
}
/**
* Data provider for testLoginUser().
*
* @return array
* Nested arrays of values to check.
*
* @see ::testLoginuser()
*/
public function getFbServiceBadDataProvider() {
return [
[
NULL,
NULL,
],
[
'',
'',
],
[
'123',
NULL,
],
[
NULL,
'abc',
],
[
'123',
'',
],
[
NULL,
'',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
SimpleFbConnectFbFactoryTest:: |
protected | property | ||
SimpleFbConnectFbFactoryTest:: |
protected | property | ||
SimpleFbConnectFbFactoryTest:: |
protected | property | ||
SimpleFbConnectFbFactoryTest:: |
protected | property | ||
SimpleFbConnectFbFactoryTest:: |
protected | function | Creates mocks with desired configFactory parameters. | |
SimpleFbConnectFbFactoryTest:: |
public | function | Data provider for testLoginUser(). | |
SimpleFbConnectFbFactoryTest:: |
protected | function |
Overrides UnitTestCase:: |
|
SimpleFbConnectFbFactoryTest:: |
public | function | Tests getFbService with bad data. | |
SimpleFbConnectFbFactoryTest:: |
public | function | Tests getFbService when app ID and app Secrete have been set. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |