function UserAuthTest::setUp

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::setUp()
  2. 10 core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::setUp()
  3. 11.x core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/user/tests/src/Unit/UserAuthTest.php, line 67

Class

UserAuthTest
@coversDefaultClass \Drupal\user\UserAuth @group user

Namespace

Drupal\Tests\user\Unit

Code

protected function setUp() : void {
    $this->userStorage = $this->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
    
    /** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */
    $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
    $entity_type_manager->expects($this->any())
        ->method('getStorage')
        ->with('user')
        ->willReturn($this->userStorage);
    $this->passwordService = $this->createMock('Drupal\\Core\\Password\\PasswordInterface');
    $this->testUser = $this->getMockBuilder('Drupal\\user\\Entity\\User')
        ->disableOriginalConstructor()
        ->onlyMethods([
        'id',
        'setPassword',
        'save',
        'getPassword',
    ])
        ->getMock();
    $this->userAuth = new UserAuth($entity_type_manager, $this->passwordService);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.