mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 339414e348 | |||
| bb56d32643 | |||
| acd6bb2234 | |||
| cf93e316ff | |||
| 47cc88a6ab | |||
| 45bf9e8650 | |||
| 3c766c15d5 | |||
| aa407f34d5 | |||
| 077b5ffce0 | |||
| af6240b4ee | |||
| 78b328e970 | |||
| c92fa45ad7 | |||
| d050ef8d54 | |||
| 1c2f1facac | |||
| 8e695d62e9 | |||
| b9a301a13e | |||
| 4b9da9e3c1 | |||
| 239fceab9e | |||
| bedf033655 | |||
| 66f69617f1 | |||
| 5721e8c29a | |||
| 546d19fd84 | |||
| c1b32b9ffb | |||
| 298b1e6784 | |||
| 63f009fadf | |||
| 1066c2270d | |||
| 984f237a92 | |||
| dccd8239dd | |||
| e103623ecb | |||
| 542fc046d2 | |||
| 4720e0655b | |||
| a533772fe2 | |||
| 2218a0c137 | |||
| 2831629f1b | |||
| 1b7f1dc5b3 | |||
| 92b8d32ef7 | |||
| 2969c7a5e3 | |||
| 63c1faa9f4 | |||
| b5b14ef280 | |||
| 11eb1903c2 | |||
| a110848f9b |
4
.github/workflows/changelog.yml
vendored
4
.github/workflows/changelog.yml
vendored
@ -2,12 +2,12 @@ name: Changelog
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ 1.x ]
|
||||||
paths:
|
paths:
|
||||||
- CHANGELOG.md
|
- CHANGELOG.md
|
||||||
- .github/workflows/changelog.yml
|
- .github/workflows/changelog.yml
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ 1.x ]
|
||||||
paths:
|
paths:
|
||||||
- CHANGELOG.md
|
- CHANGELOG.md
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
6
.github/workflows/tests.yml
vendored
6
.github/workflows/tests.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
php: ['7.3', '7.4', '8.0', '8.1']
|
php: ['7.3', '7.4', '8.0', '8.1', '8.2']
|
||||||
dependency-version: [prefer-lowest, prefer-stable]
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
parallel: ['', '--parallel']
|
parallel: ['', '--parallel']
|
||||||
exclude:
|
exclude:
|
||||||
@ -16,6 +16,10 @@ jobs:
|
|||||||
os: macos-latest
|
os: macos-latest
|
||||||
- php: 8.1
|
- php: 8.1
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
|
- php: 8.2
|
||||||
|
os: macos-latest
|
||||||
|
- php: 8.2
|
||||||
|
os: windows-latest
|
||||||
|
|
||||||
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} - ${{ matrix.parallel }}
|
name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} - ${{ matrix.parallel }}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,11 @@ $rules = [
|
|||||||
],
|
],
|
||||||
'concat_space' => ['spacing' => 'one'],
|
'concat_space' => ['spacing' => 'one'],
|
||||||
'not_operator_with_space' => false,
|
'not_operator_with_space' => false,
|
||||||
|
'global_namespace_import' => [
|
||||||
|
'import_classes' => true,
|
||||||
|
'import_functions' => true,
|
||||||
|
'import_constants' => true,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$rules['increment_style'] = ['style' => 'post'];
|
$rules['increment_style'] = ['style' => 'post'];
|
||||||
|
|||||||
28
CHANGELOG.md
28
CHANGELOG.md
@ -4,6 +4,34 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## [v1.22.2 (2022-11-09)](https://github.com/pestphp/pest/compare/v1.22.1...v1.22.2)
|
||||||
|
### Fixed
|
||||||
|
- Fixes storing lazy datasets into internal array ([#602](https://github.com/pestphp/pest/pull/602))
|
||||||
|
|
||||||
|
## [v1.22.1 (2022-08-29)](https://github.com/pestphp/pest/compare/v1.22.0...v1.22.1)
|
||||||
|
### Fixed
|
||||||
|
- Initial PHP 8.2 support ([d050ef8](https://github.com/pestphp/pest/commit/d050ef8d54ffe8dfe015adeb1188aae2cca33c33))
|
||||||
|
|
||||||
|
## [v1.22.0 (2022-08-28)](https://github.com/pestphp/pest/compare/v1.21.3...v1.22.0)
|
||||||
|
### Added
|
||||||
|
- Initial PHP 8.2 support ([#563](https://github.com/pestphp/pest/pull/563))
|
||||||
|
|
||||||
|
## [v1.21.3 (2022-05-12)](https://github.com/pestphp/pest/compare/v1.21.2...v1.21.3)
|
||||||
|
### Fixed
|
||||||
|
- Debug of high order tests ([c1b32b9](https://github.com/pestphp/pest/commit/c1b32b9ffb5134803c490592454b11b8c05ea27d))
|
||||||
|
|
||||||
|
## [v1.21.2 (2022-03-05)](https://github.com/pestphp/pest/compare/v1.21.1...v1.21.2)
|
||||||
|
### Fixed
|
||||||
|
- `toThrow` expectation when exception does not exist ([#487](https://github.com/pestphp/pest/pull/487))
|
||||||
|
|
||||||
|
## [v1.21.1 (2021-11-25)](https://github.com/pestphp/pest/compare/v1.21.0...v1.21.1)
|
||||||
|
### Fixed
|
||||||
|
- sequence callables causing problems ([#442](https://github.com/pestphp/pest/pull/442))
|
||||||
|
|
||||||
|
## [v1.21.0 (2021-11-17)](https://github.com/pestphp/pest/compare/v1.20.0...v1.21.0)
|
||||||
|
### Added
|
||||||
|
- warn about xdebug modes ([1e011c](https://github.com/pestphp/pest/commit/1e011c7b4074d08f5dabab1f927d45383c85d210))
|
||||||
|
|
||||||
## [v1.20.0 (2021-09-25)](https://github.com/pestphp/pest/compare/v1.19.0...v1.20.0)
|
## [v1.20.0 (2021-09-25)](https://github.com/pestphp/pest/compare/v1.19.0...v1.20.0)
|
||||||
### Added
|
### Added
|
||||||
- `throwsIf` test call ([#371](https://github.com/pestphp/pest/pull/371))
|
- `throwsIf` test call ([#371](https://github.com/pestphp/pest/pull/371))
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
When releasing a new version of Pest there are some checks and updates that need to be done:
|
When releasing a new version of Pest there are some checks and updates that need to be done:
|
||||||
|
|
||||||
- Clear your local repository with: `git add . && git reset --hard && git checkout master`
|
- Clear your local repository with: `git add . && git reset --hard && git checkout 1.x`
|
||||||
- On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...master](https://github.com/pestphp/pest/compare/{latest_version}...master) and update the [changelog](CHANGELOG.md) file with the main changes for this release
|
- On the GitHub repository, check the contents of [github.com/pestphp/pest/compare/{latest_version}...1.x](https://github.com/pestphp/pest/compare/{latest_version}...1.x) and update the [changelog](CHANGELOG.md) file with the main changes for this release
|
||||||
- Update the version number in [src/Pest.php](src/Pest.php)
|
- Update the version number in [src/Pest.php](src/Pest.php)
|
||||||
- Run the tests locally using: `composer test`
|
- Run the tests locally using: `composer test`
|
||||||
- Commit the CHANGELOG and Pest file with the message: `git commit -m "release: vX.X.X"`
|
- Commit the CHANGELOG and Pest file with the message: `git commit -m "release: vX.X.X"`
|
||||||
|
|||||||
@ -18,9 +18,9 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"nunomaduro/collision": "^5.4.0|^6.0",
|
"nunomaduro/collision": "^5.11.0|^6.3.0",
|
||||||
"pestphp/pest-plugin": "^1.0.0",
|
"pestphp/pest-plugin": "^1.1.0",
|
||||||
"phpunit/phpunit": "^9.5.5"
|
"phpunit/phpunit": "^9.5.26"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@ -40,24 +40,27 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"illuminate/console": "^8.47.0",
|
"illuminate/console": "^8.83.26",
|
||||||
"illuminate/support": "^8.47.0",
|
"illuminate/support": "^8.83.26",
|
||||||
"laravel/dusk": "^6.15.0",
|
"laravel/dusk": "^6.25.2",
|
||||||
"pestphp/pest-dev-tools": "dev-master",
|
"pestphp/pest-dev-tools": "^1.0.0",
|
||||||
"pestphp/pest-plugin-parallel": "^1.0"
|
"pestphp/pest-plugin-parallel": "^1.2"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"config": {
|
"config": {
|
||||||
"sort-packages": true,
|
"sort-packages": true,
|
||||||
"preferred-install": "dist"
|
"preferred-install": "dist",
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"bin": [
|
"bin": [
|
||||||
"bin/pest"
|
"bin/pest"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "php-cs-fixer fix -v",
|
"lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v",
|
||||||
"test:lint": "php-cs-fixer fix -v --dry-run",
|
"test:lint": "PHP_CS_FIXER_IGNORE_ENV=true php-cs-fixer fix -v --dry-run",
|
||||||
"test:types": "phpstan analyse --ansi --memory-limit=-1",
|
"test:types": "phpstan analyse --ansi --memory-limit=-1",
|
||||||
"test:unit": "php bin/pest --colors=always --exclude-group=integration",
|
"test:unit": "php bin/pest --colors=always --exclude-group=integration",
|
||||||
"test:parallel": "php bin/pest -p --colors=always --exclude-group=integration",
|
"test:parallel": "php bin/pest -p --colors=always --exclude-group=integration",
|
||||||
@ -73,7 +76,7 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.x-dev"
|
"dev-1.x": "1.x-dev"
|
||||||
},
|
},
|
||||||
"pest": {
|
"pest": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
272
phpstan-baseline.neon
Normal file
272
phpstan-baseline.neon
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
parameters:
|
||||||
|
ignoreErrors:
|
||||||
|
-
|
||||||
|
message: "#^Cannot access an offset on mixed\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$out of class Pest\\\\Logging\\\\JUnit constructor expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$verbose of class NunoMaduro\\\\Collision\\\\Adapters\\\\Phpunit\\\\Printer constructor expects bool, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$verbose of class Pest\\\\Logging\\\\TeamCity constructor expects bool, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#3 \\$colors of class NunoMaduro\\\\Collision\\\\Adapters\\\\Phpunit\\\\Printer constructor expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#3 \\$colors of class Pest\\\\Logging\\\\TeamCity constructor expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/AddsDefaults.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$filename of function file_exists expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/ValidatesConfiguration.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$filename of method PHPUnit\\\\TextUI\\\\XmlConfiguration\\\\Loader\\:\\:load\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Actions/ValidatesConfiguration.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$loader of class PHPUnit\\\\TextUI\\\\TestRunner constructor expects PHPUnit\\\\Runner\\\\TestSuiteLoader\\|null, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Console/Command.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$testSuite of static method Pest\\\\Actions\\\\AddsTests\\:\\:to\\(\\) expects iterable\\<PHPUnit\\\\Framework\\\\TestCase\\>&PHPUnit\\\\Framework\\\\TestSuite, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Console/Command.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$suffixes of method SebastianBergmann\\\\FileIterator\\\\Facade\\:\\:getFilesAsArray\\(\\) expects array\\|string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Console/Command.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Datasets.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Datasets\\:\\:getDataSetsCombinations\\(\\) has parameter \\$combinations with no value type specified in iterable type array\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Datasets.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Datasets\\:\\:getDataSetsCombinations\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Datasets.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Datasets\\:\\:processDatasets\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Datasets.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$key of static method Pest\\\\Datasets\\:\\:getDataSetDescription\\(\\) expects int\\|string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Datasets.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Each.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$ of callable callable\\(Pest\\\\Expectation\\<TValue\\>\\)\\: mixed expects Pest\\\\Expectation\\<TValue\\>, Pest\\\\Expectation\\<mixed\\> given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryExists\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryIsReadable\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$directory of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertDirectoryIsWritable\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$file of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileIsReadable\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$file of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileIsWritable\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$filename of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertFileExists\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$json of function json_decode expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$needle of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$object_or_class of function property_exists expects object\\|string, mixed given\\.$#"
|
||||||
|
count: 2
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertContains\\(\\) expects iterable, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertCount\\(\\) expects Countable\\|iterable, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertMatchesRegularExpression\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringEndsWith\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringStartsWith\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$value of method Pest\\\\Expectation\\<TValue\\>\\:\\:retrieve\\(\\) expects array\\<string, null\\>\\|object, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Trying to invoke mixed but it's not a callable\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Expectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Factories\\\\TestCaseFactory\\:\\:build\\(\\) should return array\\<int, PHPUnit\\\\Framework\\\\TestCase\\> but returns array\\<int, object\\>\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Factories/TestCaseFactory.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Function it\\(\\) should return Pest\\\\PendingObjects\\\\TestCall but returns mixed\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Functions.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$classAndTraits of class Pest\\\\PendingObjects\\\\UsesCall constructor expects array\\<int, string\\>, array\\<int\\|string, string\\> given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Functions.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$value of method Pest\\\\HigherOrderExpectation\\:\\:retrieve\\(\\) expects array\\<string, null\\>\\|object, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/HigherOrderExpectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Dead catch \\- ReflectionException is never thrown in the try block\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Logging/JUnit.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$value of method DOMElement\\:\\:setAttribute\\(\\) expects string, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Logging/JUnit.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\$test of method Pest\\\\Logging\\\\JUnit\\:\\:startTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Logging/JUnit.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\$test of method Pest\\\\Logging\\\\TeamCity\\:\\:endTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Logging/TeamCity.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\$test of method Pest\\\\Logging\\\\TeamCity\\:\\:startTest\\(\\) has invalid type Pest\\\\Concerns\\\\Testable\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Logging/TeamCity.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Dead catch \\- PHPUnit\\\\Framework\\\\ExpectationFailedException is never thrown in the try block\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/OppositeExpectation.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Property Pest\\\\PendingObjects\\\\UsesCall\\:\\:\\$groups \\(array\\<int, string\\>\\) does not accept array\\<int\\|string, string\\>\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/PendingObjects/UsesCall.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Cannot cast mixed to float\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Plugins/Coverage.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Static property Pest\\\\Plugins\\\\Environment\\:\\:\\$instance is unused\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Plugins/Environment.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Support\\\\Container\\:\\:get\\(\\) should return object but returns mixed\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/Container.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/ExceptionTrace.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#2 \\$array of function key_exists expects array, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/ExceptionTrace.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Method Pest\\\\Support\\\\HigherOrderCallables\\:\\:expect\\(\\) should return Pest\\\\Expectation\\<TValue\\> but returns Pest\\\\Expectation\\<mixed\\>\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/HigherOrderCallables.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Parameter \\#1 \\$target of method Pest\\\\Support\\\\HigherOrderMessage\\:\\:call\\(\\) expects object, mixed given\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/HigherOrderMessageCollection.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Constant Pest\\\\Support\\\\HigherOrderTapProxy\\:\\:UNDEFINED_PROPERTY is unused\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/HigherOrderTapProxy.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Dead catch \\- Throwable is never thrown in the try block\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: src/Support/HigherOrderTapProxy.php
|
||||||
|
|
||||||
@ -2,6 +2,7 @@ includes:
|
|||||||
- vendor/phpstan/phpstan-strict-rules/rules.neon
|
- vendor/phpstan/phpstan-strict-rules/rules.neon
|
||||||
- vendor/ergebnis/phpstan-rules/rules.neon
|
- vendor/ergebnis/phpstan-rules/rules.neon
|
||||||
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
|
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
|
||||||
|
- phpstan-baseline.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
level: max
|
level: max
|
||||||
@ -23,9 +24,6 @@ parameters:
|
|||||||
-
|
-
|
||||||
message: '#Call to an undefined method PHPUnit\\Framework\\Test::getName\(\)#'
|
message: '#Call to an undefined method PHPUnit\\Framework\\Test::getName\(\)#'
|
||||||
path: src/Logging
|
path: src/Logging
|
||||||
-
|
|
||||||
message: '#invalid typehint type Pest\\Concerns\\Testable#'
|
|
||||||
path: src/Logging
|
|
||||||
-
|
-
|
||||||
message: '#is not subtype of native type PHPUnit\\Framework\\Test#'
|
message: '#is not subtype of native type PHPUnit\\Framework\\Test#'
|
||||||
path: src/Logging
|
path: src/Logging
|
||||||
|
|||||||
@ -5,7 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Actions;
|
namespace Pest\Actions;
|
||||||
|
|
||||||
use Pest\Support\Str;
|
use Pest\Support\Str;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use PHPUnit\Util\FileLoader;
|
use PHPUnit\Util\FileLoader;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
@ -50,6 +52,7 @@ final class LoadStructure
|
|||||||
$directory = new RecursiveDirectoryIterator($filename);
|
$directory = new RecursiveDirectoryIterator($filename);
|
||||||
$iterator = new RecursiveIteratorIterator($directory);
|
$iterator = new RecursiveIteratorIterator($directory);
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
$filename = $file->__toString();
|
$filename = $file->__toString();
|
||||||
if (Str::endsWith($filename, '.php') && file_exists($filename)) {
|
if (Str::endsWith($filename, '.php') && file_exists($filename)) {
|
||||||
require_once $filename;
|
require_once $filename;
|
||||||
|
|||||||
@ -9,6 +9,9 @@ use Pest\Support\ChainableClosure;
|
|||||||
use Pest\Support\ExceptionTrace;
|
use Pest\Support\ExceptionTrace;
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
use PHPUnit\Framework\ExecutionOrderDependency;
|
use PHPUnit\Framework\ExecutionOrderDependency;
|
||||||
|
|
||||||
|
use function sprintf;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +260,7 @@ trait Testable
|
|||||||
*/
|
*/
|
||||||
public function toString(): string
|
public function toString(): string
|
||||||
{
|
{
|
||||||
return \sprintf(
|
return sprintf(
|
||||||
'%s::%s',
|
'%s::%s',
|
||||||
self::$__filename,
|
self::$__filename,
|
||||||
$this->__description
|
$this->__description
|
||||||
|
|||||||
@ -4,6 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest\Console;
|
namespace Pest\Console;
|
||||||
|
|
||||||
|
use function is_dir;
|
||||||
|
|
||||||
use Pest\Actions\AddsDefaults;
|
use Pest\Actions\AddsDefaults;
|
||||||
use Pest\Actions\AddsTests;
|
use Pest\Actions\AddsTests;
|
||||||
use Pest\Actions\InteractsWithPlugins;
|
use Pest\Actions\InteractsWithPlugins;
|
||||||
@ -81,7 +83,7 @@ final class Command extends BaseCommand
|
|||||||
$testSuite = $this->arguments['test'];
|
$testSuite = $this->arguments['test'];
|
||||||
|
|
||||||
if (is_string($testSuite)) {
|
if (is_string($testSuite)) {
|
||||||
if (\is_dir($testSuite)) {
|
if (is_dir($testSuite)) {
|
||||||
/** @var string[] $files */
|
/** @var string[] $files */
|
||||||
$files = (new FileIteratorFacade())->getFilesAsArray(
|
$files = (new FileIteratorFacade())->getFilesAsArray(
|
||||||
$testSuite,
|
$testSuite,
|
||||||
|
|||||||
@ -122,7 +122,7 @@ final class Datasets
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($datasets[$index] instanceof Traversable) {
|
if ($datasets[$index] instanceof Traversable) {
|
||||||
$datasets[$index] = iterator_to_array($datasets[$index]);
|
$datasets[$index] = iterator_to_array($datasets[$index], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($datasets[$index] as $key => $values) {
|
foreach ($datasets[$index] as $key => $values) {
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use Closure;
|
use Closure;
|
||||||
|
use Error;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Pest\Concerns\Extendable;
|
use Pest\Concerns\Extendable;
|
||||||
use Pest\Concerns\RetrievesValues;
|
use Pest\Concerns\RetrievesValues;
|
||||||
@ -108,7 +109,6 @@ final class Expectation
|
|||||||
public function ray(...$arguments): self
|
public function ray(...$arguments): self
|
||||||
{
|
{
|
||||||
if (function_exists('ray')) {
|
if (function_exists('ray')) {
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
ray($this->value, ...$arguments);
|
ray($this->value, ...$arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ final class Expectation
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($values as $key => $item) {
|
foreach ($values as $key => $item) {
|
||||||
if (is_callable($callbacks[$key])) {
|
if ($callbacks[$key] instanceof Closure) {
|
||||||
call_user_func($callbacks[$key], new self($item), new self($keys[$key]));
|
call_user_func($callbacks[$key], new self($item), new self($keys[$key]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -723,7 +723,7 @@ final class Expectation
|
|||||||
try {
|
try {
|
||||||
Assert::assertTrue(Arr::has($array, $key));
|
Assert::assertTrue(Arr::has($array, $key));
|
||||||
|
|
||||||
/* @phpstan-ignore-next-line */
|
/* @phpstan-ignore-next-line */
|
||||||
} catch (ExpectationFailedException $exception) {
|
} catch (ExpectationFailedException $exception) {
|
||||||
throw new ExpectationFailedException("Failed asserting that an array has the key '$key'", $exception->getComparisonFailure());
|
throw new ExpectationFailedException("Failed asserting that an array has the key '$key'", $exception->getComparisonFailure());
|
||||||
}
|
}
|
||||||
@ -912,8 +912,12 @@ final class Expectation
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
($this->value)();
|
($this->value)();
|
||||||
} catch (Throwable $e) { // @phpstan-ignore-line
|
} catch (Throwable $e) {
|
||||||
if (!class_exists($exception)) {
|
if (!class_exists($exception)) {
|
||||||
|
if ($e instanceof Error && (bool) preg_match("/Class [\"']{$exception}[\"'] not found/", $e->getMessage())) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
Assert::assertStringContainsString($exception, $e->getMessage());
|
Assert::assertStringContainsString($exception, $e->getMessage());
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@ -216,6 +216,7 @@ final class TestCaseFactory
|
|||||||
eval("
|
eval("
|
||||||
namespace $namespace;
|
namespace $namespace;
|
||||||
|
|
||||||
|
#[\AllowDynamicProperties]
|
||||||
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
||||||
$traitsCode
|
$traitsCode
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Pest\Console\Thanks;
|
use Pest\Console\Thanks;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -8,7 +8,9 @@ use Illuminate\Console\Command;
|
|||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Pest\Exceptions\InvalidConsoleArgument;
|
use Pest\Exceptions\InvalidConsoleArgument;
|
||||||
use Pest\Support\Str;
|
use Pest\Support\Str;
|
||||||
|
|
||||||
use function Pest\testDirectory;
|
use function Pest\testDirectory;
|
||||||
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -13,11 +13,14 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Logging;
|
namespace Pest\Logging;
|
||||||
|
|
||||||
use function class_exists;
|
use function class_exists;
|
||||||
|
|
||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
use function get_class;
|
use function get_class;
|
||||||
use function method_exists;
|
use function method_exists;
|
||||||
|
|
||||||
use Pest\Concerns\Testable;
|
use Pest\Concerns\Testable;
|
||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\ExceptionWrapper;
|
use PHPUnit\Framework\ExceptionWrapper;
|
||||||
@ -32,9 +35,12 @@ use PHPUnit\Util\Printer;
|
|||||||
use PHPUnit\Util\Xml;
|
use PHPUnit\Util\Xml;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function str_replace;
|
use function str_replace;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
use function trim;
|
use function trim;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,7 +179,6 @@ final class JUnit extends Printer implements TestListener
|
|||||||
$this->doAddSkipped();
|
$this->doAddSkipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
|
||||||
public function startTestSuite(TestSuite $suite): void
|
public function startTestSuite(TestSuite $suite): void
|
||||||
{
|
{
|
||||||
$testSuite = $this->document->createElement('testsuite');
|
$testSuite = $this->document->createElement('testsuite');
|
||||||
@ -212,7 +217,6 @@ final class JUnit extends Printer implements TestListener
|
|||||||
$this->testSuiteTimes[$this->testSuiteLevel] = 0;
|
$this->testSuiteTimes[$this->testSuiteLevel] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
|
||||||
public function endTestSuite(TestSuite $suite): void
|
public function endTestSuite(TestSuite $suite): void
|
||||||
{
|
{
|
||||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||||
@ -283,7 +287,6 @@ final class JUnit extends Printer implements TestListener
|
|||||||
$class = new ReflectionClass($test);
|
$class = new ReflectionClass($test);
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
} catch (ReflectionException $e) {
|
} catch (ReflectionException $e) {
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
|
throw new Exception($e->getMessage(), (int) $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|||||||
@ -5,10 +5,13 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Logging;
|
namespace Pest\Logging;
|
||||||
|
|
||||||
use function getmypid;
|
use function getmypid;
|
||||||
|
|
||||||
use Pest\Concerns\Logging\WritesToConsole;
|
use Pest\Concerns\Logging\WritesToConsole;
|
||||||
use Pest\Concerns\Testable;
|
use Pest\Concerns\Testable;
|
||||||
use Pest\Support\ExceptionTrace;
|
use Pest\Support\ExceptionTrace;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\Test;
|
use PHPUnit\Framework\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -16,9 +19,11 @@ use PHPUnit\Framework\TestResult;
|
|||||||
use PHPUnit\Framework\TestSuite;
|
use PHPUnit\Framework\TestSuite;
|
||||||
use PHPUnit\Framework\Warning;
|
use PHPUnit\Framework\Warning;
|
||||||
use PHPUnit\TextUI\DefaultResultPrinter;
|
use PHPUnit\TextUI\DefaultResultPrinter;
|
||||||
|
|
||||||
use function round;
|
use function round;
|
||||||
use function str_replace;
|
use function str_replace;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
final class TeamCity extends DefaultResultPrinter
|
final class TeamCity extends DefaultResultPrinter
|
||||||
@ -81,6 +86,7 @@ final class TeamCity extends DefaultResultPrinter
|
|||||||
foreach ($filteredResults as $key => $info) {
|
foreach ($filteredResults as $key => $info) {
|
||||||
$this->writeWithColor($info['color'], $info['count'] . " $key", false);
|
$this->writeWithColor($info['color'], $info['count'] . " $key", false);
|
||||||
|
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
if ($key !== array_reverse(array_keys($filteredResults))[0]) {
|
if ($key !== array_reverse(array_keys($filteredResults))[0]) {
|
||||||
$this->write(', ');
|
$this->write(', ');
|
||||||
}
|
}
|
||||||
@ -106,7 +112,6 @@ final class TeamCity extends DefaultResultPrinter
|
|||||||
- $result->riskyCount();
|
- $result->riskyCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
|
||||||
public function startTestSuite(TestSuite $suite): void
|
public function startTestSuite(TestSuite $suite): void
|
||||||
{
|
{
|
||||||
$suiteName = $suite->getName();
|
$suiteName = $suite->getName();
|
||||||
@ -164,7 +169,6 @@ final class TeamCity extends DefaultResultPrinter
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
|
||||||
public function endTestSuite(TestSuite $suite): void
|
public function endTestSuite(TestSuite $suite): void
|
||||||
{
|
{
|
||||||
$suiteName = $suite->getName();
|
$suiteName = $suite->getName();
|
||||||
|
|||||||
@ -51,6 +51,8 @@ final class OppositeExpectation
|
|||||||
* Handle dynamic method calls into the original expectation.
|
* Handle dynamic method calls into the original expectation.
|
||||||
*
|
*
|
||||||
* @param array<int, mixed> $arguments
|
* @param array<int, mixed> $arguments
|
||||||
|
*
|
||||||
|
* @return Expectation|never
|
||||||
*/
|
*/
|
||||||
public function __call(string $name, array $arguments): Expectation
|
public function __call(string $name, array $arguments): Expectation
|
||||||
{
|
{
|
||||||
@ -61,12 +63,13 @@ final class OppositeExpectation
|
|||||||
return $this->original;
|
return $this->original;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
$this->throwExpectationFailedException($name, $arguments);
|
$this->throwExpectationFailedException($name, $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle dynamic properties gets into the original expectation.
|
* Handle dynamic properties gets into the original expectation.
|
||||||
|
*
|
||||||
|
* @return Expectation|never
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): Expectation
|
public function __get(string $name): Expectation
|
||||||
{
|
{
|
||||||
@ -77,7 +80,6 @@ final class OppositeExpectation
|
|||||||
return $this->original;
|
return $this->original;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @phpstan-ignore-next-line
|
|
||||||
$this->throwExpectationFailedException($name);
|
$this->throwExpectationFailedException($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ final class OppositeExpectation
|
|||||||
* Creates a new expectation failed exception with a nice readable message.
|
* Creates a new expectation failed exception with a nice readable message.
|
||||||
*
|
*
|
||||||
* @param array<int, mixed> $arguments
|
* @param array<int, mixed> $arguments
|
||||||
|
*
|
||||||
|
* @return never
|
||||||
*/
|
*/
|
||||||
private function throwExpectationFailedException(string $name, array $arguments = []): void
|
private function throwExpectationFailedException(string $name, array $arguments = []): void
|
||||||
{
|
{
|
||||||
|
|||||||
@ -102,7 +102,7 @@ final class TestCall
|
|||||||
* Runs the current test multiple times with
|
* Runs the current test multiple times with
|
||||||
* each item of the given `iterable`.
|
* each item of the given `iterable`.
|
||||||
*
|
*
|
||||||
* @param array<\Closure|iterable<int|string, mixed>|string> $data
|
* @param array<Closure|iterable<int|string, mixed>|string> $data
|
||||||
*/
|
*/
|
||||||
public function with(...$data): TestCall
|
public function with(...$data): TestCall
|
||||||
{
|
{
|
||||||
@ -160,7 +160,7 @@ final class TestCall
|
|||||||
|
|
||||||
$condition = is_callable($condition)
|
$condition = is_callable($condition)
|
||||||
? $condition
|
? $condition
|
||||||
: function () use ($condition) { /* @phpstan-ignore-line */
|
: function () use ($condition) {
|
||||||
return $condition;
|
return $condition;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ final class TestCall
|
|||||||
*/
|
*/
|
||||||
public function __get(string $name): self
|
public function __get(string $name): self
|
||||||
{
|
{
|
||||||
return $this->addChain($name);
|
return $this->addChain(Backtrace::file(), Backtrace::line(), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,7 +193,7 @@ final class TestCall
|
|||||||
*/
|
*/
|
||||||
public function __call(string $name, array $arguments): self
|
public function __call(string $name, array $arguments): self
|
||||||
{
|
{
|
||||||
return $this->addChain($name, $arguments);
|
return $this->addChain(Backtrace::file(), Backtrace::line(), $name, $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,11 +201,11 @@ final class TestCall
|
|||||||
*
|
*
|
||||||
* @param array<int, mixed>|null $arguments
|
* @param array<int, mixed>|null $arguments
|
||||||
*/
|
*/
|
||||||
private function addChain(string $name, array $arguments = null): self
|
private function addChain(string $file, int $line, string $name, array $arguments = null): self
|
||||||
{
|
{
|
||||||
$this->testCaseFactory
|
$this->testCaseFactory
|
||||||
->chains
|
->chains
|
||||||
->add(Backtrace::file(), Backtrace::line(), $name, $arguments);
|
->add($file, $line, $name, $arguments);
|
||||||
|
|
||||||
if ($this->descriptionLess) {
|
if ($this->descriptionLess) {
|
||||||
$exporter = new Exporter();
|
$exporter = new Exporter();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '1.20.0';
|
return '1.22.2';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -5,7 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Plugins;
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,6 +26,7 @@ final class Backtrace
|
|||||||
$current = null;
|
$current = null;
|
||||||
|
|
||||||
foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {
|
foreach (debug_backtrace(self::BACKTRACE_OPTIONS) as $trace) {
|
||||||
|
assert(array_key_exists(self::FILE, $trace));
|
||||||
if (Str::endsWith($trace[self::FILE], (string) realpath('vendor/phpunit/phpunit/src/Util/FileLoader.php'))) {
|
if (Str::endsWith($trace[self::FILE], (string) realpath('vendor/phpunit/phpunit/src/Util/FileLoader.php'))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -45,7 +46,11 @@ final class Backtrace
|
|||||||
*/
|
*/
|
||||||
public static function file(): string
|
public static function file(): string
|
||||||
{
|
{
|
||||||
return debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE];
|
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];
|
||||||
|
|
||||||
|
assert(array_key_exists(self::FILE, $trace));
|
||||||
|
|
||||||
|
return $trace[self::FILE];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +58,11 @@ final class Backtrace
|
|||||||
*/
|
*/
|
||||||
public static function dirname(): string
|
public static function dirname(): string
|
||||||
{
|
{
|
||||||
return dirname(debug_backtrace(self::BACKTRACE_OPTIONS)[1][self::FILE]);
|
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];
|
||||||
|
|
||||||
|
assert(array_key_exists(self::FILE, $trace));
|
||||||
|
|
||||||
|
return dirname($trace[self::FILE]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +70,10 @@ final class Backtrace
|
|||||||
*/
|
*/
|
||||||
public static function line(): int
|
public static function line(): int
|
||||||
{
|
{
|
||||||
return debug_backtrace(self::BACKTRACE_OPTIONS)[1]['line'];
|
$trace = debug_backtrace(self::BACKTRACE_OPTIONS)[1];
|
||||||
|
|
||||||
|
assert(array_key_exists('line', $trace));
|
||||||
|
|
||||||
|
return $trace['line'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Support;
|
namespace Pest\Support;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
|
|
||||||
|
use const PHP_MAJOR_VERSION;
|
||||||
|
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@ -132,7 +135,7 @@ final class HigherOrderMessage
|
|||||||
|
|
||||||
private static function getUndefinedMethodMessage(object $target, string $methodName): string
|
private static function getUndefinedMethodMessage(object $target, string $methodName): string
|
||||||
{
|
{
|
||||||
if (\PHP_MAJOR_VERSION >= 8) {
|
if (PHP_MAJOR_VERSION >= 8) {
|
||||||
return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName)));
|
return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -96,6 +96,11 @@
|
|||||||
✓ more than two datasets with (2) / (4) / (5)
|
✓ more than two datasets with (2) / (4) / (5)
|
||||||
✓ more than two datasets with (2) / (4) / (6)
|
✓ more than two datasets with (2) / (4) / (6)
|
||||||
✓ more than two datasets did the job right
|
✓ more than two datasets did the job right
|
||||||
|
✓ eager registered wrapped datasets with Generator functions with (1)
|
||||||
|
✓ eager registered wrapped datasets with Generator functions with (2)
|
||||||
|
✓ eager registered wrapped datasets with Generator functions with (3)
|
||||||
|
✓ eager registered wrapped datasets with Generator functions with (4)
|
||||||
|
✓ eager registered wrapped datasets with Generator functions did the job right
|
||||||
✓ it can resolve a dataset after the test case is available with (Closure Object (...))
|
✓ it can resolve a dataset after the test case is available with (Closure Object (...))
|
||||||
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #1
|
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #1
|
||||||
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #2
|
✓ it can resolve a dataset after the test case is available with shared yield sets with (Closure Object (...)) #2
|
||||||
@ -496,6 +501,8 @@
|
|||||||
✓ not failures
|
✓ not failures
|
||||||
✓ closure missing parameter
|
✓ closure missing parameter
|
||||||
✓ closure missing type-hint
|
✓ closure missing type-hint
|
||||||
|
✓ it can handle a non-defined exception
|
||||||
|
✓ it can handle a class not found Error
|
||||||
|
|
||||||
PASS Tests\Features\Expect\unless
|
PASS Tests\Features\Expect\unless
|
||||||
✓ it pass
|
✓ it pass
|
||||||
@ -720,5 +727,5 @@
|
|||||||
✓ it is a test
|
✓ it is a test
|
||||||
✓ it uses correct parent class
|
✓ it uses correct parent class
|
||||||
|
|
||||||
Tests: 4 incompleted, 9 skipped, 478 passed
|
Tests: 4 incompleted, 9 skipped, 485 passed
|
||||||
|
|
||||||
@ -13,3 +13,20 @@ dataset('numbers.closure.wrapped', function () {
|
|||||||
dataset('numbers.array', [[1], [2]]);
|
dataset('numbers.array', [[1], [2]]);
|
||||||
|
|
||||||
dataset('numbers.array.wrapped', [1, 2]);
|
dataset('numbers.array.wrapped', [1, 2]);
|
||||||
|
|
||||||
|
dataset('numbers.generators.wrapped', function () {
|
||||||
|
yield from firstSetOfNumber();
|
||||||
|
yield from secondSetOfNumbers();
|
||||||
|
});
|
||||||
|
|
||||||
|
function firstSetOfNumber(): Generator
|
||||||
|
{
|
||||||
|
yield 1;
|
||||||
|
yield 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
function secondSetOfNumbers(): Generator
|
||||||
|
{
|
||||||
|
yield 3;
|
||||||
|
yield 4;
|
||||||
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
it('has plugin')->assertTrue(class_exists(CoveragePlugin::class));
|
||||||
|
|
||||||
it('adds coverage if --coverage exist', function () {
|
it('adds coverage if --coverage exist', function () {
|
||||||
$plugin = new CoveragePlugin(new ConsoleOutput());
|
$plugin = new CoveragePlugin(new ConsoleOutput());
|
||||||
$testSuite = TestSuite::getInstance();
|
$testSuite = TestSuite::getInstance();
|
||||||
|
|
||||||
expect($plugin->coverage)->toBeFalse();
|
expect($plugin->coverage)->toBeFalse();
|
||||||
|
|||||||
@ -228,10 +228,31 @@ test('more than two datasets did the job right', function () use ($state) {
|
|||||||
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
expect($state->text)->toBe('121212121212131423241314232411122122111221221112212213142324135136145146235236245246');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$wrapped_generator_state = new stdClass();
|
||||||
|
$wrapped_generator_state->text = '';
|
||||||
|
$wrapped_generator_function_datasets = [1, 2, 3, 4];
|
||||||
|
|
||||||
|
test(
|
||||||
|
'eager registered wrapped datasets with Generator functions',
|
||||||
|
function (int $text) use (
|
||||||
|
$wrapped_generator_state,
|
||||||
|
$wrapped_generator_function_datasets
|
||||||
|
) {
|
||||||
|
$wrapped_generator_state->text .= $text;
|
||||||
|
expect(in_array($text, $wrapped_generator_function_datasets))->toBe(true);
|
||||||
|
}
|
||||||
|
)->with('numbers.generators.wrapped');
|
||||||
|
|
||||||
|
test('eager registered wrapped datasets with Generator functions did the job right', function () use ($wrapped_generator_state) {
|
||||||
|
expect($wrapped_generator_state->text)->toBe('1234');
|
||||||
|
});
|
||||||
|
|
||||||
it('can resolve a dataset after the test case is available', function ($result) {
|
it('can resolve a dataset after the test case is available', function ($result) {
|
||||||
expect($result)->toBe('bar');
|
expect($result)->toBe('bar');
|
||||||
})->with([
|
})->with([
|
||||||
function () { return $this->foo; },
|
function () {
|
||||||
|
return $this->foo;
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
it('can resolve a dataset after the test case is available with shared yield sets', function ($result) {
|
it('can resolve a dataset after the test case is available with shared yield sets', function ($result) {
|
||||||
|
|||||||
@ -9,9 +9,15 @@ test('an exception is thrown if the the type is not iterable', function () {
|
|||||||
test('allows for sequences of checks to be run on iterable data', function () {
|
test('allows for sequences of checks to be run on iterable data', function () {
|
||||||
expect([1, 2, 3])
|
expect([1, 2, 3])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(6);
|
expect(static::getCount())->toBe(6);
|
||||||
@ -20,9 +26,15 @@ test('allows for sequences of checks to be run on iterable data', function () {
|
|||||||
test('loops back to the start if it runs out of sequence items', function () {
|
test('loops back to the start if it runs out of sequence items', function () {
|
||||||
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(16);
|
expect(static::getCount())->toBe(16);
|
||||||
@ -31,17 +43,29 @@ test('loops back to the start if it runs out of sequence items', function () {
|
|||||||
test('fails if the number of iterable items is greater than the number of expectations', function () {
|
test('fails if the number of iterable items is greater than the number of expectations', function () {
|
||||||
expect([1, 2])
|
expect([1, 2])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('it works with associative arrays', function () {
|
test('it works with associative arrays', function () {
|
||||||
expect(['foo' => 'bar', 'baz' => 'boom'])
|
expect(['foo' => 'bar', 'baz' => 'boom'])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation, $key) { $expectation->toEqual('bar'); $key->toEqual('foo'); },
|
function ($expectation, $key) {
|
||||||
function ($expectation, $key) { $expectation->toEqual('boom'); $key->toEqual('baz'); },
|
$expectation->toEqual('bar');
|
||||||
|
$key->toEqual('foo');
|
||||||
|
},
|
||||||
|
function ($expectation, $key) {
|
||||||
|
$expectation->toEqual('boom');
|
||||||
|
$key->toEqual('baz');
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -54,7 +78,9 @@ test('it can be passed non-callable values', function () {
|
|||||||
test('it can be passed a mixture of value types', function () {
|
test('it can be passed a mixture of value types', function () {
|
||||||
expect(['foo', 'bar', 'baz'])->sequence(
|
expect(['foo', 'bar', 'baz'])->sequence(
|
||||||
'foo',
|
'foo',
|
||||||
function ($expectation) { $expectation->toEqual('bar')->toBeString(); },
|
function ($expectation) {
|
||||||
|
$expectation->toEqual('bar')->toBeString();
|
||||||
|
},
|
||||||
'baz'
|
'baz'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use PHPUnit\Framework\ExpectationFailedException;
|
|||||||
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
expect(true)->toBeTrue()->and(false)->toBeFalse();
|
||||||
|
|
||||||
test('strict comparisons', function () {
|
test('strict comparisons', function () {
|
||||||
$nuno = new stdClass();
|
$nuno = new stdClass();
|
||||||
$dries = new stdClass();
|
$dries = new stdClass();
|
||||||
|
|
||||||
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
expect($nuno)->toBe($nuno)->not->toBe($dries);
|
||||||
|
|||||||
@ -3,24 +3,24 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('pass', function () {
|
test('pass', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
$object->name = 'Jhon';
|
$object->name = 'Jhon';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
expect($object)->toHaveProperties(['name', 'age']);
|
expect($object)->toHaveProperties(['name', 'age']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
$object->name = 'Jhon';
|
$object->name = 'Jhon';
|
||||||
|
|
||||||
expect($object)->toHaveProperties(['name', 'age']);
|
expect($object)->toHaveProperties(['name', 'age']);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
$object->name = 'Jhon';
|
$object->name = 'Jhon';
|
||||||
$object->age = 21;
|
$object->age = 21;
|
||||||
|
|
||||||
expect($object)->not->toHaveProperties(['name', 'age']);
|
expect($object)->not->toHaveProperties(['name', 'age']);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
@ -58,3 +58,15 @@ test('closure missing parameter', function () {
|
|||||||
test('closure missing type-hint', function () {
|
test('closure missing type-hint', function () {
|
||||||
expect(function () {})->toThrow(function ($e) {});
|
expect(function () {})->toThrow(function ($e) {});
|
||||||
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
|
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
|
||||||
|
|
||||||
|
it('can handle a non-defined exception', function () {
|
||||||
|
expect(function () {
|
||||||
|
throw new NonExistingException();
|
||||||
|
})->toThrow(NonExistingException::class);
|
||||||
|
})->throws(Error::class);
|
||||||
|
|
||||||
|
it('can handle a class not found Error', function () {
|
||||||
|
expect(function () {
|
||||||
|
throw new NonExistingException();
|
||||||
|
})->toThrow(Error::class);
|
||||||
|
});
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->unlessObject = new stdClass();
|
$this->unlessObject = new stdClass();
|
||||||
$this->unlessObject->trueValue = true;
|
$this->unlessObject->trueValue = true;
|
||||||
$this->unlessObject->foo = 'foo';
|
$this->unlessObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('pass', function () {
|
it('pass', function () {
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$this->whenObject = new stdClass();
|
$this->whenObject = new stdClass();
|
||||||
$this->whenObject->trueValue = true;
|
$this->whenObject->trueValue = true;
|
||||||
$this->whenObject->foo = 'foo';
|
$this->whenObject->foo = 'foo';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('pass', function () {
|
it('pass', function () {
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\CustomTestCase;
|
namespace Tests\CustomTestCase;
|
||||||
|
|
||||||
use function PHPUnit\Framework\assertTrue;
|
use function PHPUnit\Framework\assertTrue;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class CustomTestCase extends TestCase
|
class CustomTestCase extends TestCase
|
||||||
|
|||||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\CustomTestCase;
|
namespace Tests\CustomTestCase;
|
||||||
|
|
||||||
use function PHPUnit\Framework\assertTrue;
|
use function PHPUnit\Framework\assertTrue;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ExecutedTest extends TestCase
|
class ExecutedTest extends TestCase
|
||||||
|
|||||||
@ -23,7 +23,7 @@ test('default php unit tests', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('removes warnings', function () {
|
it('removes warnings', function () {
|
||||||
$testSuite = new TestSuite();
|
$testSuite = new TestSuite();
|
||||||
$warningTestCase = new WarningTestCase('No tests found in class "Pest\TestCase".');
|
$warningTestCase = new WarningTestCase('No tests found in class "Pest\TestCase".');
|
||||||
$testSuite->addTest($warningTestCase);
|
$testSuite->addTest($warningTestCase);
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Pest\Plugins\Version;
|
use Pest\Plugins\Version;
|
||||||
|
|
||||||
use function Pest\version;
|
use function Pest\version;
|
||||||
|
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||||||
|
|
||||||
it('outputs the version when --version is used', function () {
|
it('outputs the version when --version is used', function () {
|
||||||
|
|||||||
@ -10,7 +10,7 @@ it('gets file name from closure', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('gets property values', function () {
|
it('gets property values', function () {
|
||||||
$class = new class() {
|
$class = new class() {
|
||||||
private $foo = 'bar';
|
private $foo = 'bar';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use Pest\TestSuite;
|
|||||||
|
|
||||||
it('does not allow to add the same test description twice', function () {
|
it('does not allow to add the same test description twice', function () {
|
||||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||||
$test = function () {};
|
$test = function () {};
|
||||||
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
})->throws(
|
})->throws(
|
||||||
@ -18,7 +18,7 @@ it('does not allow to add the same test description twice', function () {
|
|||||||
|
|
||||||
it('alerts users about tests with arguments but no input', function () {
|
it('alerts users about tests with arguments but no input', function () {
|
||||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||||
$test = function (int $arg) {};
|
$test = function (int $arg) {};
|
||||||
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
})->throws(
|
})->throws(
|
||||||
DatasetMissing::class,
|
DatasetMissing::class,
|
||||||
@ -27,7 +27,7 @@ it('alerts users about tests with arguments but no input', function () {
|
|||||||
|
|
||||||
it('can return an array of all test suite filenames', function () {
|
it('can return an array of all test suite filenames', function () {
|
||||||
$testSuite = TestSuite::getInstance(getcwd(), 'tests');
|
$testSuite = TestSuite::getInstance(getcwd(), 'tests');
|
||||||
$test = function () {};
|
$test = function () {};
|
||||||
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'foo', $test));
|
||||||
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'bar', $test));
|
$testSuite->tests->set(new TestCaseFactory(__FILE__, 'bar', $test));
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ it('can return an array of all test suite filenames', function () {
|
|||||||
|
|
||||||
it('can filter the test suite filenames to those with the only method', function () {
|
it('can filter the test suite filenames to those with the only method', function () {
|
||||||
$testSuite = new TestSuite(getcwd(), 'tests');
|
$testSuite = new TestSuite(getcwd(), 'tests');
|
||||||
$test = function () {};
|
$test = function () {};
|
||||||
|
|
||||||
$testWithOnly = new TestCaseFactory(__FILE__, 'foo', $test);
|
$testWithOnly = new TestCaseFactory(__FILE__, 'foo', $test);
|
||||||
$testWithOnly->only = true;
|
$testWithOnly->only = true;
|
||||||
$testSuite->tests->set($testWithOnly);
|
$testSuite->tests->set($testWithOnly);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ it('does not filter the test suite filenames to those with the only method when
|
|||||||
|
|
||||||
$test = function () {};
|
$test = function () {};
|
||||||
|
|
||||||
$testWithOnly = new TestCaseFactory(__FILE__, 'foo', $test);
|
$testWithOnly = new TestCaseFactory(__FILE__, 'foo', $test);
|
||||||
$testWithOnly->only = true;
|
$testWithOnly->only = true;
|
||||||
$testSuite->tests->set($testWithOnly);
|
$testSuite->tests->set($testWithOnly);
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ test('visual snapshot of help command output', function () {
|
|||||||
|
|
||||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||||
$outputBuffer = new BufferedOutput();
|
$outputBuffer = new BufferedOutput();
|
||||||
$plugin = new Help($outputBuffer);
|
$plugin = new Help($outputBuffer);
|
||||||
|
|
||||||
$plugin();
|
$plugin();
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
test('visual snapshot of test suite on success', function () {
|
test('visual snapshot of test suite on success', function () {
|
||||||
$testsPath = dirname(__DIR__);
|
$testsPath = dirname(__DIR__);
|
||||||
$snapshot = implode(DIRECTORY_SEPARATOR, [
|
$snapshot = implode(DIRECTORY_SEPARATOR, [
|
||||||
$testsPath,
|
$testsPath,
|
||||||
'.snapshots',
|
'.snapshots',
|
||||||
'success.txt',
|
'success.txt',
|
||||||
|
|||||||
0
tests/Visual/junit.html
Normal file
0
tests/Visual/junit.html
Normal file
Reference in New Issue
Block a user