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.
74 lines
2.3 KiB
74 lines
2.3 KiB
<?php
|
|
namespace App\Tests;
|
|
|
|
use App\Factory\UserFactory;
|
|
|
|
class UserTest extends AbstractTest
|
|
{
|
|
|
|
public function testUserGetByAuthname(): void
|
|
{
|
|
$requestUser = UserFactory::createOne();
|
|
UserFactory::createMany(5);
|
|
|
|
$response = static::createClientWithToken($requestUser->authName)->request('GET',
|
|
'/api/users/authName/' . $requestUser->authName);
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
$this->assertEquals($requestUser->getId(), $response->toArray()['id']);
|
|
}
|
|
|
|
/**
|
|
* 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(200);
|
|
|
|
$this->assertNotEquals("foo.bar", $response->toArray()['authName']);
|
|
}
|
|
}
|
|
|