public function SimpleFbConnectUserManagerTest::testCreateUser in Simple FB Connect 8.2
Same name and namespace in other branches
- 8.3 tests/src/Unit/SimpleFbConnectUserManagerTest.php \Drupal\Tests\simple_fb_connect\Unit\SimpleFbConnectUserManagerTest::testCreateUser()
Tests createUser method when user creation is allowed.
@covers ::createUser @covers ::registrationBlocked
File
- tests/
src/ Unit/ SimpleFbConnectUserManagerTest.php, line 213 - Contains Drupal\Tests\simple_fb_connect\Unit\SimpleFbConnectUserManagerTest.
Class
- SimpleFbConnectUserManagerTest
- @coversDefaultClass Drupal\simple_fb_connect\SimpleFbConnectUserManager @group simple_fb_connect
Namespace
Drupal\Tests\simple_fb_connect\UnitCode
public function testCreateUser() {
// User object that will be created in this test.
$user = $this
->getMockBuilder('Drupal\\user\\Entity\\User')
->disableOriginalConstructor()
->getMock();
$storage = $this
->getMockBuilder('Drupal\\Core\\Entity\\EntityStorageInterface')
->getMock();
// Called when we're generating an unique username.
$storage
->expects($this
->once())
->method('loadByProperties')
->willReturn(array());
// Called when user is created.
$storage
->expects($this
->once())
->method('create')
->willReturn($user);
// EntityTypeManager that will return $storage.
$this->entityTypeManager
->expects($this
->any())
->method('getStorage')
->with('user')
->willReturn($storage);
$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
->assertInstanceOf('Drupal\\user\\Entity\\User', $this->userManager
->createUser('Firstname Lastname', 'foo@example.com'));
}