You are here

protected function ProtectedUserFieldConstraintValidatorTest::createValidator in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php \Drupal\Tests\user\Unit\Plugin\Validation\Constraint\ProtectedUserFieldConstraintValidatorTest::createValidator()
1 call to ProtectedUserFieldConstraintValidatorTest::createValidator()
ProtectedUserFieldConstraintValidatorTest::testValidate in core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php
@covers ::validate

File

core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php, line 23
Contains \Drupal\Tests\user\Unit\Plugin\Validation\Constraint\ProtectedUserFieldConstraintValidatorTest.

Class

ProtectedUserFieldConstraintValidatorTest
@coversDefaultClass \Drupal\user\Plugin\Validation\Constraint\ProtectedUserFieldConstraintValidator @group user

Namespace

Drupal\Tests\user\Unit\Plugin\Validation\Constraint

Code

protected function createValidator() {

  // Setup mocks that don't need to change.
  $unchanged_field = $this
    ->getMock('Drupal\\Core\\Field\\FieldItemListInterface');
  $unchanged_field
    ->expects($this
    ->any())
    ->method('getValue')
    ->willReturn('unchanged-value');
  $unchanged_account = $this
    ->getMock('Drupal\\user\\UserInterface');
  $unchanged_account
    ->expects($this
    ->any())
    ->method('get')
    ->willReturn($unchanged_field);
  $user_storage = $this
    ->getMock('Drupal\\user\\UserStorageInterface');
  $user_storage
    ->expects($this
    ->any())
    ->method('loadUnchanged')
    ->willReturn($unchanged_account);
  $current_user = $this
    ->getMock('Drupal\\Core\\Session\\AccountProxyInterface');
  $current_user
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('current-user');
  return new ProtectedUserFieldConstraintValidator($user_storage, $current_user);
}