Skip to content

Commit a63f95e

Browse files
From PestPHP to PHPunit (#32)
1 parent 49e35c2 commit a63f95e

40 files changed

+2527
-2448
lines changed

.github/workflows/test-coverage.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020

2121
strategy:
2222
matrix:
23-
operating-system: [ 'ubuntu-latest']
24-
php-versions: [ '8.4' ]
25-
dependency-stability: [ 'prefer-none' ]
23+
operating-system: ["ubuntu-latest"]
24+
php-versions: ["8.4"]
25+
dependency-stability: ["prefer-none"]
2626

2727
name: P${{ matrix.php-versions }} - ${{ matrix.operating-system}}
2828

@@ -46,17 +46,14 @@ jobs:
4646
- name: Platform check
4747
run: composer check-platform-reqs
4848

49-
5049
- name: running tests
51-
run: "vendor/bin/pest --configuration=phpunit.xml.dist --coverage-clover=.build/logs/clover.xml"
50+
run: "vendor/bin/phpunit --configuration=phpunit.xml.dist --coverage-clover=.build/logs/clover.xml"
5251

53-
- name: 'Upload coverage reports to Codecov'
52+
- name: "Upload coverage reports to Codecov"
5453
env:
5554
my_codecov_token: ${{ secrets.CODECOV_TOKEN }}
5655
if: ${{ env.my_codecov_token != '' && hashFiles('./.build/logs/clover.xml')!= '' }}
57-
uses: 'codecov/codecov-action@v5.1.2'
56+
uses: "codecov/codecov-action@v5.1.2"
5857
with:
59-
files: './.build/logs/clover.xml'
58+
files: "./.build/logs/clover.xml"
6059
token: ${{ env.my_codecov_token }}
61-
62-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
/vendor/
33
/composer.lock
44
/.php-cs-fixer.cache
5+
/.phpunit.cache/
56
/phpunit.xml
67
/.idea
78
/.phpunit.result.cache
89
.phpunit.cache/test-results
910
/test-output
1011
.phpactor.json
12+
/tmp/test-results

composer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"Storyblok\\ManagementApi\\": "src/"
99
}
1010
},
11+
"autoload-dev": {
12+
"psr-4": {
13+
"Tests\\": "tests/"
14+
}
15+
},
1116
"authors": [
1217
{
1318
"name": "Roberto Butti",
@@ -23,17 +28,17 @@
2328
"phpstan/phpstan": "^2.0",
2429
"rector/rector": "^2",
2530
"friendsofphp/php-cs-fixer": "^3.65",
26-
"pestphp/pest": "^3.7"
31+
"phpunit/phpunit": "^11.0"
2732
},
2833
"scripts": {
2934
"license-check": "php license-checker.php",
3035
"static-code": "vendor/bin/phpstan analyse",
3136
"style-fix-code": "vendor/bin/php-cs-fixer fix",
3237
"style-check-code": "vendor/bin/php-cs-fixer check",
33-
"test-code": "vendor/bin/pest",
34-
"test-code-ci": "vendor/bin/pest -c . --ci --cache-directory ./tmp",
38+
"test-code": "vendor/bin/phpunit",
39+
"test-code-ci": "vendor/bin/phpunit --cache-directory ./tmp",
3540
"refactor-check-code": "vendor/bin/rector --dry-run",
36-
"test-coverage": "vendor/bin/pest --configuration=phpunit.xml.dist --coverage-html .build/html",
41+
"test-coverage": "vendor/bin/phpunit --coverage-html .build/html",
3742
"all-checks": [
3843
"@style-check-code",
3944
"@static-code",
@@ -42,8 +47,6 @@
4247
]
4348
},
4449
"config": {
45-
"allow-plugins": {
46-
"pestphp/pest-plugin": true
47-
}
50+
"allow-plugins": {}
4851
}
4952
}

phpunit.xml.dist

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6+
cacheDirectory=".phpunit.cache"
67
>
78
<testsuites>
8-
<testsuite name="Test Suite">
9-
<directory suffix="Test.php">./tests</directory>
9+
<testsuite name="Feature">
10+
<directory suffix="ApiTest.php">./tests/Feature</directory>
11+
</testsuite>
12+
<testsuite name="Unit">
13+
<directory suffix="ApiTest.php">./tests/Unit</directory>
1014
</testsuite>
1115
</testsuites>
1216
<source>

src/Data/Stories.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,20 @@ public function howManyStories(): int
2424
{
2525
return $this->count();
2626
}
27+
28+
/**
29+
* Returns an array of the UUIDs of each Story in the collection.
30+
*
31+
* @return array<string> Array of UUID strings indexed from 0
32+
*/
33+
public function getUuids(): array
34+
{
35+
$array = [];
36+
/** @var Story $story */
37+
foreach ($this as $story) {
38+
$array[] = $story->uuid();
39+
}
40+
41+
return $array;
42+
}
2743
}

src/StoryblokUtils.php

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
class StoryblokUtils
88
{
99
private const array ALL_REGION_RANGES = [
10-
'EU' => [0, 999_999],
10+
"EU" => [0, 999_999],
1111
// 'CN' => [0, 1_000_000],
12-
'US' => [1_000_000, 1_999_999],
13-
'CA' => [2_000_000, 2_999_999],
14-
'AP' => [3_000_000, 3_999_999],
12+
"US" => [1_000_000, 1_999_999],
13+
"CA" => [2_000_000, 2_999_999],
14+
"AP" => [3_000_000, 3_999_999],
1515
];
1616

1717
public static function getRegionFromSpaceId(string|int $spaceId): string
@@ -22,7 +22,7 @@ public static function getRegionFromSpaceId(string|int $spaceId): string
2222
}
2323
}
2424

25-
return 'EU'; // fallback in case the ID doesn't match any range
25+
return "EU"; // fallback in case the ID doesn't match any range
2626
}
2727

2828
/**
@@ -35,31 +35,29 @@ public static function getRegionFromSpaceId(string|int $spaceId): string
3535
public static function getPlanDescription(int|string $planLevel): string
3636
{
3737
return (string) match ($planLevel) {
38-
39-
0, "0" => 'Starter (Trial)',
40-
2, "2" => 'Pro Space',
41-
1,"1" => 'Standard Space',
42-
1000, "1000" => 'Development',
43-
100, "100" => 'Community',
44-
1100, "1100" => 'Starter (Plan 1)',
45-
200, "200" => 'Entry',
46-
999, "999" => 'Development Plan',
38+
0, "0" => "Starter (Trial)",
39+
2, "2" => "Pro Space",
40+
1, "1" => "Standard Space",
41+
1000, "1000" => "Development",
42+
100, "100" => "Community",
43+
1100, "1100" => "Starter (Plan 1)",
44+
200, "200" => "Entry",
45+
999, "999" => "Development Plan",
4746
1200, "1200" => "Growth (Plan 2i)",
4847
1300, "1300" => "Growth Plus (Plan 2ii)",
49-
300, "300" => 'Teams',
50-
301, "301" => 'Business',
48+
300, "300" => "Teams",
49+
301, "301" => "Business",
5150
1400, "1400" => "Premium (Plan 3)",
5251
1401, "1401" => "Premium CN (Plan 3 CN)",
5352
1500, "1500" => "Elite (Plan 4)",
5453
1501, "1501" => "Elite CN (Plan 4 CN)",
55-
400, "400" => 'Enterprise',
56-
500, "500" => 'Enterprise Plus',
57-
501, "501" => 'Enterprise Essentials',
58-
502, "502" => 'Enterprise Scale',
59-
503, "503" => 'Enterprise Ultimate',
54+
400, "400" => "Enterprise",
55+
500, "500" => "Enterprise Plus",
56+
501, "501" => "Enterprise Essentials",
57+
502, "502" => "Enterprise Scale",
58+
503, "503" => "Enterprise Ultimate",
6059
default => $planLevel,
6160
};
62-
6361
}
6462

6563
public static function baseUriFromRegionForMapi(string $region): string

tests/Architecture/BasicTest.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)