|
|
|
@ -11,7 +11,7 @@ class DojoTest extends AbstractTest
|
|
|
|
|
/**
|
|
|
|
|
* Requirement: A user should be able to create a dojo!
|
|
|
|
|
*/
|
|
|
|
|
public function testCreateDojo(): void
|
|
|
|
|
public function testDojoCreate(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$dojoName = "BigFightDojo";
|
|
|
|
@ -27,58 +27,18 @@ class DojoTest extends AbstractTest
|
|
|
|
|
|
|
|
|
|
$this->assertResponseStatusCodeSame(201);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(1, $userRepository->findByAuthName($userName));
|
|
|
|
|
}
|
|
|
|
|
$user = $userRepository->findOneByAuthName($userName);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Requirement: A user should be request his own dojo!
|
|
|
|
|
*/
|
|
|
|
|
public function testUserReadDojo(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$dojoName = "BigFightDojo";
|
|
|
|
|
$dojo = DojoFactory::createOne(
|
|
|
|
|
[
|
|
|
|
|
$this->assertJsonContains([
|
|
|
|
|
'name' => $dojoName,
|
|
|
|
|
'owner' => UserFactory::createOne([
|
|
|
|
|
'authName' => $userName
|
|
|
|
|
])
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
static::createClientWithToken($userName)->request('GET', '/api/dojo');
|
|
|
|
|
|
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
|
|
|
|
|
|
|
|
$this->assertJsonContains(
|
|
|
|
|
[
|
|
|
|
|
'name' => 'BigFightDojo',
|
|
|
|
|
'members' => [],
|
|
|
|
|
'owner' => $this->getIri($dojo->getOwner()),
|
|
|
|
|
'id' => $dojo->getId()
|
|
|
|
|
->toBase32()
|
|
|
|
|
'owner' => $this->getIri($user)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Requirement: A user should be request his own dojo!
|
|
|
|
|
* Fails, if the dojo is not yet created.
|
|
|
|
|
*/
|
|
|
|
|
public function testUserReadDojoNotYetCreated(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$userRepository = $this->getContainer()->get(UserRepository::class);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(0, $userRepository->findByAuthName($userName));
|
|
|
|
|
|
|
|
|
|
static::createClientWithToken($userName)->request('GET', '/api/dojo');
|
|
|
|
|
|
|
|
|
|
$this->assertResponseStatusCodeSame(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Requirement: A user should NOT be able to create more than one dojos!
|
|
|
|
|
*/
|
|
|
|
|
public function testUserCannotCreateMultipleDojos(): void
|
|
|
|
|
public function testDojoUserCannotCreateMultipleDojos(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$dojoName = "BigFightDojo";
|
|
|
|
@ -102,7 +62,7 @@ class DojoTest extends AbstractTest
|
|
|
|
|
* Requirement: A user should be able to change the dojos name!
|
|
|
|
|
* FIXME: Add limitation so users will not do this frequently.
|
|
|
|
|
*/
|
|
|
|
|
public function testChangeDojoName(): void
|
|
|
|
|
public function testDojoChangeDojoName(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$dojoName = "BigFightDojo";
|
|
|
|
@ -127,5 +87,24 @@ class DojoTest extends AbstractTest
|
|
|
|
|
|
|
|
|
|
$this->assertResponseStatusCodeSame(200);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDojoRetrieve(): void
|
|
|
|
|
{
|
|
|
|
|
$userName = "FooBarFigher";
|
|
|
|
|
$dojoName = "SmallFightDojo";
|
|
|
|
|
$dojo = DojoFactory::createOne(
|
|
|
|
|
[
|
|
|
|
|
'name' => $dojoName,
|
|
|
|
|
'owner' => UserFactory::createOne([
|
|
|
|
|
'authName' => $userName
|
|
|
|
|
])
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
static::createClientWithToken($userName)->request('GET', '/api/dojos/' . $dojo->getId());
|
|
|
|
|
|
|
|
|
|
$this->assertJsonContains([
|
|
|
|
|
'name' => $dojoName
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|