Skip to content

Commit f1f72d0

Browse files
authored
Merge pull request #4 from milroyfraser/pest-2
Upgrade to pest 2
2 parents 00648cd + 6e27f07 commit f1f72d0

File tree

7 files changed

+103
-90
lines changed

7 files changed

+103
-90
lines changed

.github/workflows/static.yml

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,30 @@ name: Static Analysis
33
on: ['push', 'pull_request']
44

55
jobs:
6-
cs:
7-
runs-on: ubuntu-latest
8-
9-
name: Code Style
10-
11-
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v2
14-
15-
- name: Setup PHP
16-
uses: shivammathur/setup-php@v2
17-
with:
18-
php-version: 7.4
19-
tools: composer:v2
20-
coverage: none
6+
static:
7+
name: Static Tests
218

22-
- name: Install Dependencies
23-
run: composer update --no-interaction --no-progress --ansi
24-
25-
- name: Run PHP-CS-Fixer
26-
run: vendor/bin/php-cs-fixer fix -v --allow-risky=yes --dry-run --ansi
27-
28-
phpstan:
299
runs-on: ubuntu-latest
3010
strategy:
3111
matrix:
3212
dependency-version: [prefer-lowest, prefer-stable]
3313

34-
name: PHPStan ${{ matrix.dependency-version }}
35-
3614
steps:
37-
- name: Checkout
38-
uses: actions/checkout@v2
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.1
22+
tools: composer:v2
23+
coverage: none
3924

40-
- name: Setup PHP
41-
uses: shivammathur/setup-php@v2
42-
with:
43-
php-version: 7.4
44-
tools: composer:v2
45-
coverage: none
25+
- name: Install Dependencies
26+
run: composer update --prefer-stable --no-interaction --no-progress --ansi
4627

47-
- name: Install Dependencies
48-
run: composer update --prefer-stable --no-interaction --no-progress --ansi
28+
- name: Types
29+
run: composer test:types
4930

50-
- name: Run PHPStan
51-
run: vendor/bin/phpstan analyse --no-progress --ansi
31+
- name: Style
32+
run: composer test:lint

.github/workflows/tests.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
os: [ubuntu-latest, macos-latest, windows-latest]
11-
php: ['7.3', '7.4', '8.0']
10+
os: [ubuntu-latest] # (macos-latest, windows-latest) 2.x-dev is under development
11+
php: ['8.1', '8.2']
1212
dependency-version: [prefer-lowest, prefer-stable]
13+
parallel: ['', '--parallel']
1314

14-
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}
15+
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} - ${{ matrix.parallel }}
1516

1617
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
19-
20-
- name: Setup PHP
21-
uses: shivammathur/setup-php@v2
22-
with:
23-
php-version: ${{ matrix.php }}
24-
tools: composer:v2
25-
coverage: none
26-
27-
- name: Setup Problem Matches
28-
run: |
29-
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
30-
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
31-
32-
- name: Install PHP dependencies
33-
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi
34-
35-
- name: Unit Tests
36-
run: ./vendor/bin/pest --colors=always
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
tools: composer:v2
26+
coverage: none
27+
28+
- name: Setup Problem Matches
29+
run: |
30+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
31+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
32+
- name: Install PHP dependencies
33+
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi
34+
35+
- name: Unit Tests
36+
run: composer test:unit

composer.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
],
1515
"license": "MIT",
1616
"require": {
17-
"php": "^7.3 || ^8.0",
18-
"pestphp/pest": "^1.0",
19-
"pestphp/pest-plugin": "^1.0"
17+
"php": "^8.1",
18+
"pestphp/pest": "^2.0.0",
19+
"pestphp/pest-plugin": "^2.0.0"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -27,23 +27,21 @@
2727
]
2828
},
2929
"require-dev": {
30-
"pestphp/pest-dev-tools": "dev-master"
31-
},
32-
"extra": {
33-
"branch-alias": {
34-
"dev-master": "1.x-dev"
35-
}
30+
"pestphp/pest-dev-tools": "^2.0.0"
3631
},
3732
"minimum-stability": "dev",
3833
"prefer-stable": true,
3934
"config": {
4035
"sort-packages": true,
41-
"preferred-install": "dist"
36+
"preferred-install": "dist",
37+
"allow-plugins": {
38+
"pestphp/pest-plugin": true
39+
}
4240
},
4341
"scripts": {
44-
"lint": "php-cs-fixer fix -v",
45-
"test:lint": "php-cs-fixer fix -v --dry-run",
46-
"test:types": "phpstan analyse --ansi --debug",
42+
"lint": "pint",
43+
"test:lint": "pint --test",
44+
"test:types": "phpstan analyse --ansi",
4745
"test:unit": "pest --colors=always",
4846
"test": [
4947
"@test:lint",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ parameters:
1313
reportUnmatchedIgnoredErrors: true
1414

1515
ignoreErrors:
16-
- "# with null as default value#"
16+
- "#has parameter \\$exceptionMessage with null as default value.#"

phpunit.xml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
4+
backupGlobals="false"
5+
beStrictAboutTestsThatDoNotTestAnything="true"
6+
beStrictAboutOutputDuringTests="true"
7+
bootstrap="vendor/autoload.php"
8+
cacheResult="false"
49
colors="true"
10+
failOnRisky="true"
11+
failOnWarning="true"
12+
processIsolation="false"
13+
stopOnError="false"
14+
stopOnFailure="false"
15+
cacheDirectory=".phpunit.cache"
16+
backupStaticProperties="false"
17+
displayDetailsOnIncompleteTests="true"
18+
displayDetailsOnSkippedTests="true"
19+
displayDetailsOnTestsThatTriggerDeprecations="true"
20+
displayDetailsOnTestsThatTriggerErrors="true"
21+
displayDetailsOnTestsThatTriggerNotices="true"
22+
displayDetailsOnTestsThatTriggerWarnings="true"
523
>
624
<testsuites>
725
<testsuite name="default">
826
<directory suffix=".php">./tests</directory>
927
</testsuite>
1028
</testsuites>
11-
<coverage processUncoveredFiles="true">
29+
<coverage>
1230
<include>
1331
<directory suffix=".php">./src</directory>
1432
</include>

src/BehaviorDescriptor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Pest\Gwt;
66

77
use Closure;
8-
use Pest\PendingObjects\TestCall;
8+
use Pest\PendingCalls\TestCall;
99
use Pest\Support\Backtrace;
1010
use Pest\TestSuite;
1111

@@ -57,23 +57,23 @@ public function when(Closure $act)
5757
public function then(Closure $asserting)
5858
{
5959
$arranging = $this->arranging;
60-
$acting = $this->acting;
60+
$acting = $this->acting;
6161

6262
$filename = Backtrace::testFile();
6363

6464
return new TestCall(TestSuite::getInstance(), $filename, $this->description, function () use ($arranging, $acting, $asserting) {
6565
$params = [];
6666

67-
if (!is_null($arranging)) {
67+
if (! is_null($arranging)) {
6868
$params = $arranging();
69-
if (!is_array($params)) {
69+
if (! is_array($params)) {
7070
$params = [$params];
7171
}
7272
}
7373

7474
$params = $acting(...$params);
7575

76-
if (!is_array($params)) {
76+
if (! is_array($params)) {
7777
$params = [$params];
7878
}
7979

@@ -86,6 +86,7 @@ public function then(Closure $asserting)
8686
*/
8787
public function throws(string $exception, string $exceptionMessage = null)
8888
{
89-
return $this->then(function () {})->throws($exception, $exceptionMessage);
89+
return $this->then(function () {
90+
})->throws($exception, $exceptionMessage);
9091
}
9192
}

tests/Example.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
use function PHPUnit\Framework\assertEquals;
55

66
scenario('given and when returning nothing')
7-
->given(function () {})
8-
->when(function () {})
9-
->then(function () { assertEquals(1, 1); });
7+
->given(function () {
8+
})
9+
->when(function () {
10+
})
11+
->then(function () {
12+
assertEquals(1, 1);
13+
});
1014

1115
scenario('given and when returning non array values')
1216
->given(function () {
@@ -51,15 +55,26 @@
5155
->throws(Exception::class);
5256

5357
scenario('not returning an array works')
54-
->given(function () { return 'this is not an array'; })
55-
->when(function (string $s) { return $s; })
56-
->then(function (string $s) { expect($s)->toBe('this is not an array'); });
58+
->given(function () {
59+
return 'this is not an array';
60+
})
61+
->when(function (string $s) {
62+
return $s;
63+
})
64+
->then(function (string $s) {
65+
expect($s)->toBe('this is not an array');
66+
});
5767

5868
scenario('returning an arrayable class works')
5969
->given(function () {
60-
return new class() {
70+
return new class()
71+
{
6172
public $a;
6273
};
6374
})
64-
->when(function ($c) { return $c; })
65-
->then(function ($c) { expect((array) $c)->toBe(['a' => null]); });
75+
->when(function ($c) {
76+
return $c;
77+
})
78+
->then(function ($c) {
79+
expect((array) $c)->toBe(['a' => null]);
80+
});

0 commit comments

Comments
 (0)