You are here

public function SimpleFbConnectUserManagerTest::testCreateUserWhenRegistrationBlocked in Simple FB Connect 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/SimpleFbConnectUserManagerTest.php \Drupal\Tests\simple_fb_connect\Unit\SimpleFbConnectUserManagerTest::testCreateUserWhenRegistrationBlocked()

Tests createUser method when user creation is blocked in Drupal settings.

@covers ::createUser @covers ::registrationBlocked

File

tests/src/Unit/SimpleFbConnectUserManagerTest.php, line 183

Class

SimpleFbConnectUserManagerTest
@coversDefaultClass Drupal\simple_fb_connect\SimpleFbConnectUserManager @group simple_fb_connect

Namespace

Drupal\Tests\simple_fb_connect\Unit

Code

public function testCreateUserWhenRegistrationBlocked() {

  // Set registration to be blocked in Drupal account settings.
  $new_config_factory = $this
    ->getConfigFactoryStub([
    'user.settings' => [
      'register' => 'admin_only',
    ],
  ]);
  $this->userManager
    ->setConfigFactory($new_config_factory);
  $logger_channel = $this
    ->getMockBuilder('Drupal\\Core\\Logger\\LoggerChannel')
    ->disableOriginalConstructor()
    ->getMock();
  $this->loggerFactory
    ->expects($this
    ->any())
    ->method('get')
    ->with('simple_fb_connect')
    ->willReturn($logger_channel);
  $fb_profile_pic = $this
    ->getMockBuilder('Facebook\\GraphNodes\\GraphNode')
    ->disableOriginalConstructor()
    ->getMock();
  $this
    ->assertFalse($this->userManager
    ->createUser('Firstname Lastname', 'foo@example.com', 12345, $fb_profile_pic));
}