Compare commits

...

8 Commits

Author SHA1 Message Date
5ae061d208 release: release: v2.3.0 2023-03-28 10:16:29 +01:00
3d7e621b7d chore: phpunit >10.0.19 support 2023-03-28 10:11:58 +01:00
bf14c4262a Merge pull request #740 from faissaloux/scheduled-workflows-condition
[2.x] Run scheduled workflows only on origin repo
2023-03-28 08:48:42 +01:00
b186d7a4ee Merge pull request #743 from pestphp/feat/uses-hint
[2.x] Adds `uses()` hint
2023-03-28 08:13:10 +01:00
e109cd1da2 feat: uses()hint 2023-03-28 01:48:46 +01:00
473f295b77 run scheduled workflows only on origin repo 2023-03-25 01:48:18 +00:00
5df46d03c3 Merge pull request #739 from dansysanalyst/fix_inconsistent_dataset_spelling
Inconsistency in spelling of "dataset"
2023-03-24 16:22:28 +00:00
19424ae06d fix inconsistency in dataset spelling 2023-03-24 16:00:33 +01:00
15 changed files with 86 additions and 41 deletions

View File

@ -8,6 +8,7 @@ on:
jobs: jobs:
ci: ci:
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:

View File

@ -8,6 +8,7 @@ on:
jobs: jobs:
static: static:
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
name: Static Tests name: Static Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -9,6 +9,7 @@ on:
jobs: jobs:
ci: ci:
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:

View File

@ -2,6 +2,17 @@
## Unreleased ## Unreleased
## [v2.3.0 (2023-03-28)](https://github.com/pestphp/pest/compare/v2.2.3...v2.3.0)
### Added
- Better error handler about missing uses ([#743](https://github.com/pestphp/pest/pull/743))
### Fixed
- Inconsistent spelling of `dataset` ([#739](https://github.com/pestphp/pest/pull/739))
### Chore
- Bumps PHPUnit to `^10.0.19` ([3d7e621](https://github.com/pestphp/pest/commit/3d7e621b7dfc03f0b2d9dcf6eb06c26bc383f502))
## [v2.2.3 (2023-03-24)](https://github.com/pestphp/pest/compare/v2.2.2...v2.2.3) ## [v2.2.3 (2023-03-24)](https://github.com/pestphp/pest/compare/v2.2.2...v2.2.3)
### Fixed ### Fixed

View File

@ -23,11 +23,11 @@
"nunomaduro/termwind": "^1.15.1", "nunomaduro/termwind": "^1.15.1",
"pestphp/pest-plugin": "^2.0.1", "pestphp/pest-plugin": "^2.0.1",
"pestphp/pest-plugin-arch": "^2.0.2", "pestphp/pest-plugin-arch": "^2.0.2",
"phpunit/phpunit": "^10.0.18" "phpunit/phpunit": "^10.0.19"
}, },
"conflict": { "conflict": {
"webmozart/assert": "<1.11.0", "webmozart/assert": "<1.11.0",
"phpunit/phpunit": ">10.0.18" "phpunit/phpunit": ">10.0.19"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string function version(): string
{ {
return '2.2.3'; return '2.3.0';
} }
function testDirectory(string $file = ''): string function testDirectory(string $file = ''): string

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Pest\Support; namespace Pest\Support;
use Closure; use Closure;
use PHPUnit\Framework\TestCase;
use Throwable; use Throwable;
/** /**
@ -15,8 +16,7 @@ final class ExceptionTrace
private const UNDEFINED_METHOD = 'Call to undefined method P\\'; private const UNDEFINED_METHOD = 'Call to undefined method P\\';
/** /**
* Ensures the given closure reports * Ensures the given closure reports the good execution context.
* the good execution context.
* *
* @return mixed * @return mixed
* *
@ -28,8 +28,14 @@ final class ExceptionTrace
return $closure(); return $closure();
} catch (Throwable $throwable) { } catch (Throwable $throwable) {
if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) { if (Str::startsWith($message = $throwable->getMessage(), self::UNDEFINED_METHOD)) {
$class = preg_match('/^Call to undefined method ([^:]+)::/', $message, $matches) === false ? null : $matches[1];
$message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message); $message = str_replace(self::UNDEFINED_METHOD, 'Call to undefined method ', $message);
if (class_exists($class) && count(class_parents($class)) > 0 && array_values(class_parents($class))[0] === TestCase::class) {
$message .= '. Did you forget to use the [uses()] function? https://pestphp.com/docs/configuring-tests';
}
Reflection::setPropertyValue($throwable, 'message', $message); Reflection::setPropertyValue($throwable, 'message', $message);
} }

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.2.3. Pest Testing Framework 2.3.0.
USAGE: pest <file> [options] USAGE: pest <file> [options]
@ -43,17 +43,17 @@
--enforce-time-limit ................. Enforce time limit based on test size --enforce-time-limit ................. Enforce time limit based on test size
--default-time-limit [sec] Timeout in seconds for tests that have no declared size --default-time-limit [sec] Timeout in seconds for tests that have no declared size
--dont-report-useless-tests .. Do not report tests that do not test anything --dont-report-useless-tests .. Do not report tests that do not test anything
--stop-on-defect ................. Stop execution upon first not-passed test --stop-on-defect ... Stop after first error, failure, warning or, risky test
--stop-on-error ............................ Stop execution upon first error --stop-on-error ..................................... Stop after first error
--stop-on-failure ............... Stop execution upon first error or failure --stop-on-failure ................................. Stop after first failure
--stop-on-warning ........................ Stop execution upon first warning --stop-on-warning ................................. Stop after first warning
--stop-on-risky ....................... Stop execution upon first risky test --stop-on-risky ................................ Stop after first risky test
--stop-on-skipped ................... Stop execution upon first skipped test --stop-on-skipped ............................ Stop after first skipped test
--stop-on-incomplete ............. Stop execution upon first incomplete test --stop-on-incomplete ...................... Stop after first incomplete test
--fail-on-incomplete .................... Treat incomplete tests as failures --fail-on-warning Signal failure using shell exit code when a warning was triggered
--fail-on-risky .............................. Treat risky tests as failures --fail-on-risky Signal failure using shell exit code when a test was considered risky
--fail-on-skipped .......................... Treat skipped tests as failures --fail-on-skipped Signal failure using shell exit code when a test was skipped
--fail-on-warning .................... Treat tests with warnings as failures --fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete
--cache-result ............................ Write test results to cache file --cache-result ............................ Write test results to cache file
--do-not-cache-result .............. Do not write test results to cache file --do-not-cache-result .............. Do not write test results to cache file
--order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size --order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size

View File

@ -903,6 +903,10 @@
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #2 ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…rs.php', '/var/www/project/tests/Featur…rs.php') #2
✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Featur…ollers') ✓ it computes the dataset scope with ('/var/www/project/tests/Featur…ts.php', '/var/www/project/tests/Featur…ollers')
PASS Tests\Unit\Support\ExceptionTrace
✓ it ensures the given closures reports the correct class name
✓ it ensures the given closures reports the correct class name and suggests the [uses()] function
PASS Tests\Unit\Support\Reflection PASS Tests\Unit\Support\Reflection
✓ it gets file name from closure ✓ it gets file name from closure
✓ it gets property values ✓ it gets property values
@ -1004,4 +1008,4 @@
PASS Tests\Visual\Version PASS Tests\Visual\Version
✓ visual snapshot of help command output ✓ visual snapshot of help command output
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 703 passed (1702 assertions) Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 705 passed (1706 assertions)

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.2.3. Pest Testing Framework 2.3.0.

View File

@ -0,0 +1,21 @@
<?php
use Pest\Support\ExceptionTrace;
it('ensures the given closures reports the correct class name', function () {
$closure = function () {
throw new Exception('Call to undefined method P\Tests\IntentionallyNotExisting::testBasic().');
};
ExceptionTrace::ensure($closure);
})->throws(
Exception::class,
'Call to undefined method Tests\IntentionallyNotExisting::testBasic().',
);
it('ensures the given closures reports the correct class name and suggests the [uses()] function', function () {
$this->get();
})->throws(
Error::class,
'Call to undefined method Tests\Unit\Support\ExceptionTrace::get(). Did you forget to use the [uses()] function? https://pestphp.com/docs/configuring-tests',
);

View File

@ -15,6 +15,6 @@ $run = function () {
}; };
test('parallel', function () use ($run) { test('parallel', function () use ($run) {
expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 692 passed (1688 assertions)') expect($run())->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 694 passed (1692 assertions)')
->toContain('Parallel: 3 processes'); ->toContain('Parallel: 3 processes');
})->skip(PHP_OS_FAMILY === 'Windows'); })->skip(PHP_OS_FAMILY === 'Windows');