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.

62 lines
1.8 KiB

<?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' => [
'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(405);
$this->assertNotEquals("foo.bar", $response->toArray()['authName']);
}
}