Skip to content
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/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"require-dev": {
"brianium/paratest": "v7.8.4",
"friendsofphp/php-cs-fixer": "3.77.0",
"friendsofphp/php-cs-fixer": "3.84.0",
"hautelook/alice-bundle": "2.15.1",
"justinrainbow/json-schema": "6.4.2",
"php-coveralls/php-coveralls": "2.8.0",
Expand Down
14 changes: 7 additions & 7 deletions api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions api/tests/Api/CampCollaborations/UpdateCampCollaborationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,14 @@ public function testPatchCampCollaborationValidatesInvalidAbbreviation($abbrevia
]);
}

public static function invalidAbbreviations(): \Iterator {
yield ['ABC'];

yield ['D3C'];

yield ['🧑🏿‍🚀🙋🏼‍♀️😊'];
}

#[DataProvider('validAbbreviations')]
public function testPatchCampCollaborationValidatesValidAbbreviation($abbreviation) {
$campCollaboration = static::getFixture('campCollaboration5inactive');
Expand All @@ -415,6 +423,20 @@ public function testPatchCampCollaborationValidatesValidAbbreviation($abbreviati
]);
}

public static function validAbbreviations(): \Iterator {
yield ['A'];

yield ['33'];

yield ['X4'];

yield ['✅😊'];

yield ['🧑🏿‍🚀🧑🏼‍🔧'];

yield ['⚜️'];
}

#[DataProvider('usersWhichCanEditCampCollaborations')]
public function testRejectsPatchStatusFromEstablishedToInactiveIfNoManagerWouldBeInCamp(string $userFixtureName) {
$campCollaboration = static::getFixture('campCollaboration1camp2manager');
Expand Down Expand Up @@ -507,26 +529,4 @@ public static function usersWhichCanEditCampCollaborations(): \Iterator {

yield 'user2member' => ['user2member'];
}

public static function invalidAbbreviations(): \Iterator {
yield ['ABC'];

yield ['D3C'];

yield ['🧑🏿‍🚀🙋🏼‍♀️😊'];
}

public static function validAbbreviations(): \Iterator {
yield ['A'];

yield ['33'];

yield ['X4'];

yield ['✅😊'];

yield ['🧑🏿‍🚀🧑🏼‍🔧'];

yield ['⚜️'];
}
}
36 changes: 18 additions & 18 deletions api/tests/Api/ContentNodes/CreateContentNodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,24 @@ public function testCreateRejectsParentsWhichDontSupportChildren(string $idOfPar
]);
}

public static function getContentNodesWhichCannotHaveChildren(): \Iterator {
yield ContentNode\MaterialNode::class => [
'materialNode1',
];

yield ContentNode\MultiSelect::class => [
'multiSelect1',
];

yield ContentNode\SingleText::class => [
'singleText1',
];

yield ContentNode\StoryBoard::class => [
'storyboard1',
];
}

public function testCreateValidatesIncompatibleContentType() {
// given
/** @var ContentType $contentType */
Expand Down Expand Up @@ -268,24 +286,6 @@ public function testCreatePurgesCacheTags() {
], $cacheManager->getInvalidatedTags());
}

public static function getContentNodesWhichCannotHaveChildren(): \Iterator {
yield ContentNode\MaterialNode::class => [
'materialNode1',
];

yield ContentNode\MultiSelect::class => [
'multiSelect1',
];

yield ContentNode\SingleText::class => [
'singleText1',
];

yield ContentNode\StoryBoard::class => [
'storyboard1',
];
}

protected function getExampleWritePayload($attributes = [], $except = []) {
return parent::getExampleWritePayload(
array_merge([
Expand Down
36 changes: 18 additions & 18 deletions api/tests/Api/ContentNodes/UpdateContentNodeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ public function testPatchRejectsParentsWhichDontSupportChildren(string $idOfPare
]);
}

public static function getContentNodesWhichCannotHaveChildren(): \Iterator {
yield ContentNode\MaterialNode::class => [
'materialNode1',
];

yield ContentNode\MultiSelect::class => [
'multiSelect1',
];

yield ContentNode\SingleText::class => [
'singleText1',
];

yield ContentNode\StoryBoard::class => [
'storyboard1',
];
}

public function testPatchValidatesThatParentSupportsSlotName() {
$this->patch(payload: ['slot' => 'invalidSlot']);

Expand Down Expand Up @@ -192,22 +210,4 @@ public function testPatchCleansTextOfInstanceName() {
'instanceName' => 'control',
]);
}

public static function getContentNodesWhichCannotHaveChildren(): \Iterator {
yield ContentNode\MaterialNode::class => [
'materialNode1',
];

yield ContentNode\MultiSelect::class => [
'multiSelect1',
];

yield ContentNode\SingleText::class => [
'singleText1',
];

yield ContentNode\StoryBoard::class => [
'storyboard1',
];
}
}
40 changes: 20 additions & 20 deletions api/tests/Api/Profiles/UpdateProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,14 @@ public function testPatchCampCollaborationValidatesInvalidAbbreviation($abbrevia
]);
}

public static function invalidAbbreviations(): \Iterator {
yield ['ABC'];

yield ['D3C'];

yield ['🧑🏿‍🚀🙋🏼‍♀️😊'];
}

#[DataProvider('validAbbreviations')]
public function testPatchCampCollaborationValidatesValidAbbreviation($abbreviation) {
$profile = static::getFixture('profile1manager');
Expand All @@ -487,6 +495,18 @@ public function testPatchCampCollaborationValidatesValidAbbreviation($abbreviati
]);
}

public static function validAbbreviations(): \Iterator {
yield ['AB'];

yield ['33'];

yield ['X4'];

yield ['✅😊'];

yield ['🧑🏿‍🚀🧑🏼‍🔧'];
}

public function testPatchProfileValidatesInvalidLanguage() {
$profile = static::getFixture('profile1manager');
static::createClientWithCredentials()->request('PATCH', '/profiles/'.$profile->getId(), ['json' => [
Expand Down Expand Up @@ -555,24 +575,4 @@ public static function notWriteableProfileProperties(): \Iterator {

yield 'user' => ['user'];
}

public static function invalidAbbreviations(): \Iterator {
yield ['ABC'];

yield ['D3C'];

yield ['🧑🏿‍🚀🙋🏼‍♀️😊'];
}

public static function validAbbreviations(): \Iterator {
yield ['AB'];

yield ['33'];

yield ['X4'];

yield ['✅😊'];

yield ['🧑🏿‍🚀🧑🏼‍🔧'];
}
}
30 changes: 15 additions & 15 deletions api/tests/Api/SnapshotTests/EndpointPerformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ public function testNumberOfQueriesDidNotChangeForContentNodeItemEndpoints(strin
}
}

public static function getContentNodeEndpoints(): array {
$collectionEndpoints = self::getCollectionEndpoints();
$normalEndpoints = array_filter($collectionEndpoints, function (string $endpoint) {
return str_contains($endpoint, '/content_node');
});

// @noinspection PhpUnnecessaryLocalVariableInspection
return array_reduce($normalEndpoints, function (?array $left, string $right) {
$newArray = $left ?? [];
$newArray[$right] = [$right];

return $newArray;
});
}

/**
* @param mixed $collectionEndpoint
*
Expand All @@ -176,21 +191,6 @@ public function measurePerformanceFor(string $collectionEndpoint): array {
];
}

public static function getContentNodeEndpoints(): array {
$collectionEndpoints = self::getCollectionEndpoints();
$normalEndpoints = array_filter($collectionEndpoints, function (string $endpoint) {
return str_contains($endpoint, '/content_node');
});

// @noinspection PhpUnnecessaryLocalVariableInspection
return array_reduce($normalEndpoints, function (?array $left, string $right) {
$newArray = $left ?? [];
$newArray[$right] = [$right];

return $newArray;
});
}

protected function getSnapshotId(): string {
return $this->getEnvironment().'_'.parent::getSnapshotId();
}
Expand Down
20 changes: 10 additions & 10 deletions api/tests/Types/Doctrine/BaseDateTypeTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ public function testInvalidTypeConversionToDatabaseValue(mixed $value): void {
$this->type->convertToDatabaseValue($value, $this->platform);
}

public function testNullConversion(): void {
self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}

public function testConvertDateTimeToPHPValue(): void {
$date = new \DateTime('now');

self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform));
}

/** @return \Iterator<(int | string), array<mixed>> */
public static function invalidPHPValuesProvider(): \Iterator {
yield [0];
Expand All @@ -76,4 +66,14 @@ public static function invalidPHPValuesProvider(): \Iterator {

yield [['an array']];
}

public function testNullConversion(): void {
self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}

public function testConvertDateTimeToPHPValue(): void {
$date = new \DateTime('now');

self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform));
}
}