public function UserRegistrationResourceTest::testRegistrationAnonymousOnlyPost in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/tests/src/Unit/UserRegistrationResourceTest.php \Drupal\Tests\user\Unit\UserRegistrationResourceTest::testRegistrationAnonymousOnlyPost()
- 10 core/modules/user/tests/src/Unit/UserRegistrationResourceTest.php \Drupal\Tests\user\Unit\UserRegistrationResourceTest::testRegistrationAnonymousOnlyPost()
Tests that only anonymous users can register users.
File
- core/
modules/ user/ tests/ src/ Unit/ UserRegistrationResourceTest.php, line 117
Class
- UserRegistrationResourceTest
- Tests User Registration REST resource.
Namespace
Drupal\Tests\user\UnitCode
public function testRegistrationAnonymousOnlyPost() {
$this->currentUser
->isAnonymous()
->willReturn(FALSE);
$this->testClass = new UserRegistrationResource([], 'plugin_id', '', [], $this->logger, $this->userSettings
->reveal(), $this->currentUser
->reveal());
$entity = $this
->prophesize(User::class);
$entity
->isNew()
->willReturn(TRUE);
$this
->expectException(AccessDeniedHttpException::class);
$this->testClass
->post($entity
->reveal());
}