Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api/tests/Api: replace deprecated fixture access static::$fixtures th FixtureStore #4384

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/tests/Api/Activities/CreateActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testCreateActivityIsDeniedForAnonymousUser() {

public function testCreateActivityIsNotPossibleForUnrelatedUserBecausePeriodIsNotReadable() {
/** @var User $user */
$user = static::$fixtures['user4unrelated'];
$user = static::getFixture('user4unrelated');
static::createClientWithCredentials(['email' => $user->getEmail()])
->request('POST', '/activities', ['json' => $this->getExampleWritePayload()])
;
Expand Down
14 changes: 7 additions & 7 deletions api/tests/Api/Activities/DeleteActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class DeleteActivityTest extends ECampApiTestCase {
public function testDeleteActivityIsDeniedForAnonymousUser() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createBasicClient()->request('DELETE', '/activities/'.$activity->getId());
$this->assertResponseStatusCodeSame(401);
$this->assertJsonContains([
Expand All @@ -20,7 +20,7 @@ public function testDeleteActivityIsDeniedForAnonymousUser() {
}

public function testDeleteActivityIsDeniedForUnrelatedUser() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user4unrelated']->getEmail()])
->request('DELETE', '/activities/'.$activity->getId())
;
Expand All @@ -33,7 +33,7 @@ public function testDeleteActivityIsDeniedForUnrelatedUser() {
}

public function testDeleteActivityIsDeniedForInactiveCollaborator() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('DELETE', '/activities/'.$activity->getId())
;
Expand All @@ -46,7 +46,7 @@ public function testDeleteActivityIsDeniedForInactiveCollaborator() {
}

public function testDeleteActivityIsDeniedForGuest() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user3guest']->getEmail()])
->request('DELETE', '/activities/'.$activity->getId())
;
Expand All @@ -59,7 +59,7 @@ public function testDeleteActivityIsDeniedForGuest() {
}

public function testDeleteActivityIsAllowedForMember() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('DELETE', '/activities/'.$activity->getId())
;
Expand All @@ -68,14 +68,14 @@ public function testDeleteActivityIsAllowedForMember() {
}

public function testDeleteActivityIsAllowedForManager() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials()->request('DELETE', '/activities/'.$activity->getId());
$this->assertResponseStatusCodeSame(204);
$this->assertNull($this->getEntityManager()->getRepository(Activity::class)->find($activity->getId()));
}

public function testDeleteActivityFromCampPrototypeIsDeniedForUnrelatedUser() {
$activity = static::$fixtures['activity1campPrototype'];
$activity = static::getFixture('activity1campPrototype');
static::createClientWithCredentials()->request('DELETE', '/activities/'.$activity->getId());

$this->assertResponseStatusCodeSame(403);
Expand Down
8 changes: 4 additions & 4 deletions api/tests/Api/Activities/ListActivitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testListActivitiesIsAllowedForLoggedInUserButFiltered() {
}

public function testListActivitiesFilteredByCampIsAllowedForCollaborator() {
$camp = static::$fixtures['camp1'];
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials()->request('GET', '/activities?camp=%2Fcamps%2F'.$camp->getId());
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
Expand All @@ -60,7 +60,7 @@ public function testListActivitiesFilteredByCampIsAllowedForCollaborator() {
}

public function testListActivitiesFilteredByCampIsDeniedForUnrelatedUser() {
$camp = static::$fixtures['camp1'];
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user4unrelated']->getEmail()])
->request('GET', '/activities?camp=%2Fcamps%2F'.$camp->getId())
;
Expand All @@ -70,7 +70,7 @@ public function testListActivitiesFilteredByCampIsDeniedForUnrelatedUser() {
}

public function testListActivitiesFilteredByCampIsDeniedForInactiveCollaborator() {
$camp = static::$fixtures['camp1'];
$camp = static::getFixture('camp1');
$response = static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('GET', '/activities?camp=%2Fcamps%2F'.$camp->getId())
;
Expand All @@ -80,7 +80,7 @@ public function testListActivitiesFilteredByCampIsDeniedForInactiveCollaborator(
}

public function testListActivitiesFilteredByCampPrototypeIsAllowedForUnrelatedUser() {
$camp = static::$fixtures['campPrototype'];
$camp = static::getFixture('campPrototype');
$response = static::createClientWithCredentials()->request('GET', '/activities?camp=%2Fcamps%2F'.$camp->getId());
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains(['totalItems' => 1]);
Expand Down
14 changes: 7 additions & 7 deletions api/tests/Api/Activities/ReadActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class ReadActivityTest extends ECampApiTestCase {
public function testGetSingleActivityIsDeniedForAnonymousUser() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createBasicClient()->request('GET', '/activities/'.$activity->getId());
$this->assertResponseStatusCodeSame(401);
$this->assertJsonContains([
Expand All @@ -22,7 +22,7 @@ public function testGetSingleActivityIsDeniedForAnonymousUser() {

public function testGetSingleActivityIsDeniedForUnrelatedUser() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user4unrelated']->getEmail()])
->request('GET', '/activities/'.$activity->getId())
;
Expand All @@ -35,7 +35,7 @@ public function testGetSingleActivityIsDeniedForUnrelatedUser() {

public function testGetSingleActivityIsDeniedForInactiveCollaborator() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('GET', '/activities/'.$activity->getId())
;
Expand All @@ -48,7 +48,7 @@ public function testGetSingleActivityIsDeniedForInactiveCollaborator() {

public function testGetSingleActivityIsAllowedForGuest() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user3guest']->getEmail()])
->request('GET', '/activities/'.$activity->getId())
;
Expand All @@ -70,7 +70,7 @@ public function testGetSingleActivityIsAllowedForGuest() {

public function testGetSingleActivityIsAllowedForMember() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
$result = static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('GET', '/activities/'.$activity->getId())
;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testGetSingleActivityIsAllowedForMember() {

public function testGetSingleActivityIsAllowedForManager() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials()->request('GET', '/activities/'.$activity->getId());
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
Expand All @@ -118,7 +118,7 @@ public function testGetSingleActivityIsAllowedForManager() {

public function testGetSingleActivityFromCampPrototypeIsAllowedForUnrelatedUser() {
/** @var Activity $activity */
$activity = static::$fixtures['activity1campPrototype'];
$activity = static::getFixture('activity1campPrototype');
static::createClientWithCredentials()->request('GET', '/activities/'.$activity->getId());
$this->assertResponseStatusCodeSame(200);
$this->assertJsonContains([
Expand Down
36 changes: 18 additions & 18 deletions api/tests/Api/Activities/UpdateActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class UpdateActivityTest extends ECampApiTestCase {
public function testPatchActivityIsDeniedForAnonymousUser() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createBasicClient()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
'location' => 'Stoos',
Expand All @@ -23,7 +23,7 @@ public function testPatchActivityIsDeniedForAnonymousUser() {
}

public function testPatchActivityIsDeniedForUnrelatedUser() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user4unrelated']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
Expand All @@ -39,7 +39,7 @@ public function testPatchActivityIsDeniedForUnrelatedUser() {
}

public function testPatchActivityIsDeniedForInactiveCollaborator() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user5inactive']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
Expand All @@ -55,7 +55,7 @@ public function testPatchActivityIsDeniedForInactiveCollaborator() {
}

public function testPatchActivityIsDeniedForGuest() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user3guest']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
Expand All @@ -71,7 +71,7 @@ public function testPatchActivityIsDeniedForGuest() {
}

public function testPatchActivityIsAllowedForMember() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
Expand All @@ -90,7 +90,7 @@ public function testPatchActivityIsAllowedForMember() {
}

public function testPatchActivityIsAllowedForManager() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
'location' => 'Stoos',
Expand All @@ -107,7 +107,7 @@ public function testPatchActivityIsAllowedForManager() {
}

public function testPatchActivityFromCampPrototypeIsDeniedForUnrelatedUser() {
$activity = static::$fixtures['activity1campPrototype'];
$activity = static::getFixture('activity1campPrototype');
static::createClientWithCredentials()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => 'Hello World',
'location' => 'Stoos',
Expand All @@ -121,7 +121,7 @@ public function testPatchActivityFromCampPrototypeIsDeniedForUnrelatedUser() {
}

public function testPatchActivityValidatesCategoryFromSameCamp() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials()->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'category' => $this->getIriFor('category1camp2'),
], 'headers' => ['Content-Type' => 'application/merge-patch+json']]);
Expand All @@ -138,7 +138,7 @@ public function testPatchActivityValidatesCategoryFromSameCamp() {
}

public function testPatchActivityValidatesNullTitle() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => null,
Expand All @@ -153,7 +153,7 @@ public function testPatchActivityValidatesNullTitle() {
}

public function testPatchActivityValidatesTitleMinLength() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => '',
Expand All @@ -172,7 +172,7 @@ public function testPatchActivityValidatesTitleMinLength() {
}

public function testPatchActivityValidatesTitleMaxLength() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => str_repeat('a', 33),
Expand All @@ -191,7 +191,7 @@ public function testPatchActivityValidatesTitleMaxLength() {
}

public function testPatchActivityCleansForbiddenCharactersFromTitle() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => "this\n\t\u{202E} is 'a' <sample> text😀 \\",
Expand All @@ -205,7 +205,7 @@ public function testPatchActivityCleansForbiddenCharactersFromTitle() {
}

public function testPatchActivityTrimsTitle() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'title' => " \t".str_repeat('a', 32)." \t",
Expand All @@ -219,7 +219,7 @@ public function testPatchActivityTrimsTitle() {
}

public function testPatchActivityValidatesNullLocation() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'location' => null,
Expand All @@ -234,7 +234,7 @@ public function testPatchActivityValidatesNullLocation() {
}

public function testPatchActivityAllowsSettingLocationToEmptyString() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'location' => '',
Expand All @@ -248,7 +248,7 @@ public function testPatchActivityAllowsSettingLocationToEmptyString() {
}

public function testPatchActivityValidatesLocationMaxLength() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'location' => str_repeat('a', 65),
Expand All @@ -267,7 +267,7 @@ public function testPatchActivityValidatesLocationMaxLength() {
}

public function testPatchActivityCleansForbiddenCharactersFromLocation() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'location' => "this\n\t\u{202E} is 'a' <sample> text😀 \\",
Expand All @@ -281,7 +281,7 @@ public function testPatchActivityCleansForbiddenCharactersFromLocation() {
}

public function testPatchActivityTrimsLocation() {
$activity = static::$fixtures['activity1'];
$activity = static::getFixture('activity1');
static::createClientWithCredentials(['email' => static::$fixtures['user2member']->getEmail()])
->request('PATCH', '/activities/'.$activity->getId(), ['json' => [
'location' => " \t".str_repeat('a', 64)." \t",
Expand Down
Loading