function UserRegistrationResourceTest::testExistedEntityPost

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

Tests that only new user accounts can be registered.

File

core/modules/user/tests/src/Unit/UserRegistrationResourceTest.php, line 99

Class

UserRegistrationResourceTest
Tests User Registration REST resource.

Namespace

Drupal\Tests\user\Unit

Code

public function testExistedEntityPost() : void {
    $entity = $this->prophesize(User::class);
    $entity->isNew()
        ->willReturn(FALSE);
    $this->expectException(BadRequestHttpException::class);
    $this->testClass
        ->post($entity->reveal());
}

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