PartKeepr\AuthBundle\Exceptions\UserProtectedException::getMessageKey PHP Method

getMessageKey() public method

public getMessageKey ( )
    public function getMessageKey()
    {
        return 'User is protected against changes';
    }

Usage Example

Exemplo n.º 1
0
 public function testUserProtect()
 {
     /**
      * @var FOSUser
      */
     $fosUser = $this->fixtures->getReference('user.admin');
     $userService = $this->getContainer()->get('partkeepr.userservice');
     $user = $userService->getProxyUser($fosUser->getUsername(), $userService->getBuiltinProvider(), true);
     /*
      * @var User $user
      */
     $userService->protect($user);
     $this->assertTrue($user->isProtected());
     $client = static::makeClient(true);
     $iriConverter = $this->getContainer()->get('api.iri_converter');
     $iri = $iriConverter->getIriFromItem($user);
     $data = ['username' => 'foo'];
     $client->request('PUT', $iri, [], [], [], json_encode($data));
     $response = json_decode($client->getResponse()->getContent());
     $exception = new UserProtectedException();
     $this->assertEquals(500, $client->getResponse()->getStatusCode());
     $this->assertObjectHasAttribute('hydra:description', $response);
     $this->assertEquals($exception->getMessageKey(), $response->{'hydra:description'});
     $client->request('DELETE', $iri);
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals(500, $client->getResponse()->getStatusCode());
     $this->assertObjectHasAttribute('hydra:description', $response);
     $this->assertEquals($exception->getMessageKey(), $response->{'hydra:description'});
 }
UserProtectedException