You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
5 months ago
|
<?php
|
||
|
namespace App\Tests;
|
||
|
|
||
|
use App\Factory\UserFactory;
|
||
|
|
||
|
class UserTest extends AbstractTest
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* Requirement: A user should be able to update his properties
|
||
|
*/
|
||
|
public function testUpdateUserProperties(): void
|
||
|
{
|
||
|
$requestUser = UserFactory::createOne();
|
||
|
|
||
|
$response = static::createClientWithToken($requestUser->authName)->request('PATCH', $this->getIri($requestUser),
|
||
|
[
|
||
|
'headers' => [
|
||
|
'content-type' => 'application/merge-patch+json'
|
||
|
],
|
||
|
'json' => [
|
||
|
'authName' => 'foo.bar',
|
||
|
'properties' => [
|
||
|
'a' => 1,
|
||
|
'b' => true,
|
||
|
'c' => null,
|
||
|
'd' => 'text'
|
||
|
]
|
||
|
]
|
||
|
]);
|
||
|
|
||
|
$this->assertResponseStatusCodeSame(200);
|
||
|
|
||
|
$this->assertEquals(1, $response->toArray()['properties']['a']);
|
||
|
$this->assertEquals(true, $response->toArray()['properties']['b']);
|
||
|
$this->assertEquals(null, $response->toArray()['properties']['c']);
|
||
|
$this->assertEquals('text', $response->toArray()['properties']['d']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Requirement: A user should NOT be able to update his authName
|
||
|
*/
|
||
|
public function testUpdateUserAuthnameNotPossible(): void
|
||
|
{
|
||
|
$requestUser = UserFactory::createOne();
|
||
|
|
||
|
$response = static::createClientWithToken($requestUser->authName)->request('PATCH', $this->getIri($requestUser),
|
||
|
[
|
||
|
'headers' => [
|
||
|
'content-type' => 'application/merge-patch+json'
|
||
|
],
|
||
|
'json' => [
|
||
|
'authName' => 'foo.bar'
|
||
|
]
|
||
|
]);
|
||
|
|
||
|
$this->assertResponseStatusCodeSame(200);
|
||
|
|
||
|
$this->assertNotEquals("foo.bar", $response->toArray()['authName']);
|
||
|
}
|
||
|
}
|
||
|
|