mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63f009fadf | |||
| 1066c2270d | |||
| 984f237a92 | |||
| dccd8239dd | |||
| e103623ecb | |||
| 542fc046d2 | |||
| 4720e0655b | |||
| a533772fe2 | |||
| 2218a0c137 | |||
| 2831629f1b | |||
| 1b7f1dc5b3 |
@ -4,6 +4,10 @@ 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.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)
|
## [v1.21.1 (2021-11-25)](https://github.com/pestphp/pest/compare/v1.21.0...v1.21.1)
|
||||||
### Fixed
|
### Fixed
|
||||||
- sequence callables causing problems ([#442](https://github.com/pestphp/pest/pull/442))
|
- sequence callables causing problems ([#442](https://github.com/pestphp/pest/pull/442))
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"nunomaduro/collision": "^5.4.0|^6.0",
|
"nunomaduro/collision": "^5.10.0|^6.0",
|
||||||
"pestphp/pest-plugin": "^1.0.0",
|
"pestphp/pest-plugin": "^1.0.0",
|
||||||
"phpunit/phpunit": "^9.5.5"
|
"phpunit/phpunit": "^9.5.5"
|
||||||
},
|
},
|
||||||
@ -50,7 +50,10 @@
|
|||||||
"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"
|
||||||
|
|||||||
@ -140,11 +140,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: src/Expectation.php
|
path: src/Expectation.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$value of method Pest\\\\Expectation\\<TValue\\>\\:\\:and\\(\\) expects TValue, mixed given\\.$#"
|
|
||||||
count: 2
|
|
||||||
path: src/Expectation.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertContains\\(\\) expects iterable, mixed given\\.$#"
|
message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertContains\\(\\) expects iterable, mixed given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|||||||
@ -50,6 +50,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;
|
||||||
|
|||||||
@ -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;
|
||||||
@ -911,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;
|
||||||
|
|||||||
@ -173,7 +173,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 +211,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(
|
||||||
|
|||||||
@ -106,7 +106,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 +163,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();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '1.21.1';
|
return '1.21.2';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@ -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'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -496,6 +496,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 +722,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, 480 passed
|
||||||
|
|
||||||
@ -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);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user