Compare commits

...

53 Commits

Author SHA1 Message Date
ef120125e0 release: 2.34.9 2024-07-11 09:36:26 +01:00
8a9a416133 chore: bumps dependencies 2024-07-11 09:35:43 +01:00
4783334f15 chore: style 2024-07-11 09:35:38 +01:00
e8f122bf47 release: 2.34.8 2024-06-10 23:02:16 +01:00
9fc607a2b8 Fixes wrong stub 2024-06-10 22:52:21 +01:00
b33af71036 Merge pull request #1157 from ExeQue/2.x
[2.x] Added `toBeList` expectation
2024-05-27 13:08:05 +01:00
3c6c89a6ad Added test to toBeList 2024-05-21 08:15:32 +02:00
55f6b5696e Added toBeList expectation 2024-05-21 08:13:20 +02:00
303f4c0113 Adds sponsor 2024-04-19 20:47:46 +01:00
35a1fcd0cf chore: updates readme 2024-04-08 12:28:43 +01:00
a7a3e4240e release: v2.34.7 2024-04-05 08:44:17 +01:00
e4af33867b chore: bumps dependencies 2024-04-05 08:44:07 +01:00
680111fb1e release: v2.34.6 2024-03-28 11:36:46 +00:00
aa6ff95ea4 chore: bumps dependencies 2024-03-28 11:36:36 +00:00
863a0cc837 release: v2.34.5 2024-03-22 08:44:19 +00:00
126a84a63e chore: bumps dependencies 2024-03-22 08:44:13 +00:00
d519e40b95 chore: adjusts workflow 2024-03-15 21:14:22 +00:00
6a1161ead8 release: v2.34.4 2024-03-14 19:44:18 +00:00
a1b3547dd6 chore: fixes paratest version 2024-03-14 19:42:03 +00:00
b9e3146a47 release: v2.34.3 2024-03-14 19:40:23 +00:00
ce1607cba9 chore: bumps phpunit 2024-03-14 19:40:16 +00:00
ac07bc1770 chore: override changes 2024-03-14 19:40:03 +00:00
521a41dd10 fix: no duplicate --no-output 2024-03-14 19:39:45 +00:00
1b68b340e8 chore: fixes static analysis 2024-03-14 19:39:31 +00:00
853f6efce6 release: v2.34.2 2024-03-11 18:05:47 +00:00
62a9a78ee2 chore: bumps dependencies 2024-03-11 18:05:37 +00:00
78d9fd31d0 release: v2.34.1 2024-02-28 15:15:55 +00:00
602b696348 release: v2.34.0 2024-02-17 10:06:53 +00:00
5b0f88c227 release: v2.33.6 2024-02-12 08:55:32 +00:00
f31a2c3220 chore: fixes paratest 2024-02-12 08:53:04 +00:00
e8fa98c810 release: 2.33.5 2024-02-12 08:44:52 +00:00
07e314fbf5 chore: bumps dependencies 2024-02-12 08:44:40 +00:00
4baf27911e release: 2.33.4 2024-02-02 16:54:54 +00:00
12e48a14d1 chore: fixes deps 2024-02-02 16:53:58 +00:00
1bc0f79508 release: 2.33.3 2024-02-02 16:51:42 +00:00
cb0f256791 release: 2.33.2 2024-02-02 16:50:40 +00:00
923970a117 chore: bumps versioning 2024-02-01 11:51:11 +00:00
b3db7dfd4c chore: fixes type checking 2024-02-01 11:45:19 +00:00
b303f9f818 Merge pull request #1082 from nhaynes/fix-ci-flag
fix: updates Only plugin to check for CI environment
2024-01-30 14:17:03 +00:00
d29997d5b0 fix: updates Only plugin to check for CI environment 2024-01-29 19:03:06 -06:00
13f340a742 feat: improves badge coloring 2024-01-29 23:00:30 +00:00
eeade88ad2 Fixes kernel throwing all kind of errors 2024-01-29 12:50:00 +00:00
06280ef75d chore: updates snaphosts 2024-01-29 11:54:23 +00:00
aa46f73888 Merge pull request #1081 from nuernbergerA/track-vendor-changes
[2.x] Track vendor changes
2024-01-29 11:39:34 +00:00
3660865e5e update snapshot 2024-01-29 08:58:07 +01:00
13695d597b Merge branch '2.x' into track-vendor-changes 2024-01-29 08:56:41 +01:00
fab2de833f Merge pull request #1080 from nuernbergerA/test-junit
[2.x] Add test for junit implementation
2024-01-28 23:49:06 +00:00
5b630bcdff possible implementation 2024-01-28 09:48:37 +01:00
e70edbfa38 normalize path for windows 2024-01-28 09:11:06 +01:00
b1558ddde5 update snapshot 2024-01-28 09:04:42 +01:00
582529377b add test for junit output 2024-01-28 08:53:20 +01:00
88714598b6 Merge pull request #1076 from pestphp/fixing-version
[2.x] Fixing Version `2.33` for New Release
2024-01-27 13:01:06 +00:00
AJ
5136267bbe fixing version for new release 2024-01-26 23:43:52 -03:00
68 changed files with 265 additions and 217 deletions

View File

@ -3,8 +3,6 @@ name: Tests
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
tests:

View File

@ -21,6 +21,8 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
### Platinum Sponsors
- **[LaraJobs](https://larajobs.com)**
- **[Brokerchooser](https://brokerchooser.com)**
- **[Forge](https://forge.laravel.com)**
- **[Spatie](https://spatie.be)**
- **[Worksome](https://www.worksome.com/)**
@ -30,9 +32,7 @@ We cannot thank our sponsors enough for their incredible support in funding Pest
- [Akaunting](https://akaunting.com/?ref=pestphp)
- [Codecourse](https://codecourse.com/?ref=pestphp)
- [Laracasts](https://laracasts.com/?ref=pestphp)
- [Laradir](https://laradir.com/?ref=pestphp)
- [Localazy](https://localazy.com/?ref=pestphp)
- [Stormlikes](https://www.stormlikes.net/?ref=pestphp)
- [Zapiet](https://www.zapiet.com/?ref=pestphp)
Pest is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

View File

@ -81,6 +81,7 @@ $bootPest = (static function (): void {
$getopt['teamcity-file'] ?? null,
$getopt['testdox-file'] ?? null,
isset($getopt['testdox-color']),
$getopt['testdox-columns'] ?? null,
);
while (true) {

View File

@ -19,14 +19,14 @@
"require": {
"php": "^8.1.0",
"brianium/paratest": "^7.3.1",
"nunomaduro/collision": "^7.10.0|^8.1.0",
"nunomaduro/termwind": "^1.15.1|^2.0.0",
"nunomaduro/collision": "^7.10.0|^8.1.1",
"nunomaduro/termwind": "^1.15.1|^2.0.1",
"pestphp/pest-plugin": "^2.1.1",
"pestphp/pest-plugin-arch": "^2.6.1",
"phpunit/phpunit": "^10.5.9"
"pestphp/pest-plugin-arch": "^2.7.0",
"phpunit/phpunit": "^10.5.17"
},
"conflict": {
"phpunit/phpunit": ">10.5.9",
"phpunit/phpunit": ">10.5.17",
"sebastian/exporter": "<5.1.0",
"webmozart/assert": "<1.11.0"
},
@ -52,8 +52,8 @@
},
"require-dev": {
"pestphp/pest-dev-tools": "^2.16.0",
"pestphp/pest-plugin-type-coverage": "^2.8.0",
"symfony/process": "^6.4.0|^7.0.2"
"pestphp/pest-plugin-type-coverage": "^2.8.4",
"symfony/process": "^6.4.0|^7.1.1"
},
"minimum-stability": "dev",
"prefer-stable": true,

View File

@ -59,7 +59,6 @@ use function file_get_contents;
use function file_put_contents;
use function is_array;
use function is_dir;
use function is_file;
use function json_decode;
use function json_encode;
use function Pest\version;
@ -129,13 +128,15 @@ final class DefaultResultCache implements ResultCache
public function load(): void
{
if (! is_file($this->cacheFilename)) {
$contents = @file_get_contents($this->cacheFilename);
if ($contents === false) {
return;
}
$data = json_decode(
file_get_contents($this->cacheFilename),
true
$contents,
true,
);
if ($data === null) {

View File

@ -59,19 +59,14 @@ use function array_map;
*/
final class TestSuiteFilterProcessor
{
private Factory $filterFactory;
public function __construct(Factory $factory = new Factory)
{
$this->filterFactory = $factory;
}
/**
* @throws Event\RuntimeException
* @throws FilterNotConfiguredException
*/
public function process(Configuration $configuration, TestSuite $suite): void
{
$factory = new Factory;
if (! $configuration->hasFilter() &&
! $configuration->hasGroups() &&
! $configuration->hasExcludeGroups() &&
@ -83,21 +78,21 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasExcludeGroups()) {
$this->filterFactory->addExcludeGroupFilter(
$factory->addExcludeGroupFilter(
$configuration->excludeGroups()
);
}
if (Only::isEnabled()) {
$this->filterFactory->addIncludeGroupFilter(['__pest_only']);
$factory->addIncludeGroupFilter(['__pest_only']);
} elseif ($configuration->hasGroups()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
$configuration->groups()
);
}
if ($configuration->hasTestsCovering()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_covers_'.$name,
$configuration->testsCovering()
@ -106,7 +101,7 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasTestsUsing()) {
$this->filterFactory->addIncludeGroupFilter(
$factory->addIncludeGroupFilter(
array_map(
static fn (string $name): string => '__phpunit_uses_'.$name,
$configuration->testsUsing()
@ -115,12 +110,12 @@ final class TestSuiteFilterProcessor
}
if ($configuration->hasFilter()) {
$this->filterFactory->addNameFilter(
$factory->addNameFilter(
$configuration->filter()
);
}
$suite->injectFilter($this->filterFactory);
$suite->injectFilter($factory);
Event\Facade::emitter()->testSuiteFiltered(
Event\TestSuite\TestSuiteBuilder::from($suite)

View File

@ -10,7 +10,7 @@
?>
<div class="my-1">
<span class="ml-2 px-1 bg-<?php echo $bgBadgeColor ?>-600 font-bold"><?php echo htmlspecialchars($bgBadgeText) ?></span>
<span class="ml-2 px-1 bg-<?php echo $bgBadgeColor ?> font-bold"><?php echo htmlspecialchars($bgBadgeText) ?></span>
<span class="ml-1">
<?php echo htmlspecialchars($content) ?>
</span>

View File

@ -15,17 +15,17 @@ final class BootOverrides implements Bootstrapper
/**
* The list of files to be overridden.
*
* @var array<int, string>
* @var array<string, string>
*/
private const FILES = [
'Runner/Filter/NameFilterIterator.php',
'Runner/ResultCache/DefaultResultCache.php',
'Runner/TestSuiteLoader.php',
'TextUI/Command/WarmCodeCoverageCacheCommand.php',
'TextUI/Output/Default/ProgressPrinter/TestSkippedSubscriber.php',
'TextUI/TestSuiteFilterProcessor.php',
'Event/Value/ThrowableBuilder.php',
'Logging/JUnit/JunitXmlLogger.php',
public const FILES = [
'c7b9c8a96006dea314204a8f09a8764e51ce0b9b79aadd58da52e8c328db4870' => 'Runner/Filter/NameFilterIterator.php',
'c7c09ab7c9378710b27f761a4b2948196cbbdf2a73e4389bcdca1e7c94fa9c21' => 'Runner/ResultCache/DefaultResultCache.php',
'bc8718c89264f65800beabc23e51c6d3bcff87dfc764a12179ef5dbfde272c8b' => 'Runner/TestSuiteLoader.php',
'f41e48d6cb546772a7de4f8e66b6b7ce894a5318d063eb52e354d206e96c701c' => 'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
'cb7519f2d82893640b694492cf7ec9528da80773cc1d259634181b5d393528b5' => 'TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php',
'2f06e4b1a9f3a24145bfc7ea25df4f124117f940a2cde30a04d04d5678006bff' => 'TextUI/TestSuiteFilterProcessor.php',
'ef64a657ed9c0067791483784944107827bf227c7e3200f212b6751876b99e25' => 'Event/Value/ThrowableBuilder.php',
'c78f96e34b98ed01dd8106539d59b8aa8d67f733274118b827c01c5c4111c033' => 'Logging/JUnit/JunitXmlLogger.php',
];
/**

View File

@ -32,8 +32,7 @@ final class BootSubscribers implements Bootstrapper
*/
public function __construct(
private readonly Container $container,
) {
}
) {}
/**
* Boots the list of Subscribers.

View File

@ -24,9 +24,7 @@ final class EachExpectation
*
* @param Expectation<TValue> $original
*/
public function __construct(private readonly Expectation $original)
{
}
public function __construct(private readonly Expectation $original) {}
/**
* Creates a new expectation.

View File

@ -36,9 +36,7 @@ final class OppositeExpectation
*
* @param Expectation<TValue> $original
*/
public function __construct(private readonly Expectation $original)
{
}
public function __construct(private readonly Expectation $original) {}
/**
* Asserts that the value array not has the provided $keys.

View File

@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
*/
final class CoversClass
{
public function __construct(public string $class)
{
}
public function __construct(public string $class) {}
}

View File

@ -9,7 +9,5 @@ namespace Pest\Factories\Covers;
*/
final class CoversFunction
{
public function __construct(public string $function)
{
}
public function __construct(public string $function) {}
}

View File

@ -7,6 +7,4 @@ namespace Pest\Factories\Covers;
/**
* @internal
*/
final class CoversNothing
{
}
final class CoversNothing {}

View File

@ -139,6 +139,10 @@ final class Kernel
$this->terminate();
if (is_array($error = error_get_last())) {
if (! in_array($error['type'], [E_ERROR, E_CORE_ERROR], true)) {
return;
}
$message = $error['message'];
$file = $error['file'];
$line = $error['line'];

View File

@ -17,8 +17,7 @@ final class ServiceMessage
public function __construct(
private readonly string $type,
private readonly array $parameters,
) {
}
) {}
public function toString(): string
{

View File

@ -14,9 +14,7 @@ abstract class Subscriber
/**
* Creates a new Subscriber instance.
*/
public function __construct(private readonly TeamCityLogger $logger)
{
}
public function __construct(private readonly TeamCityLogger $logger) {}
/**
* Creates a new TeamCityLogger instance.

View File

@ -7,6 +7,4 @@ namespace Pest\Matchers;
/**
* @internal
*/
final class Any
{
}
final class Any {}

View File

@ -467,6 +467,18 @@ final class Expectation
return $this;
}
/**
* Asserts that the value is a list.
*
* @return self<TValue>
*/
public function toBeList(string $message = ''): self
{
Assert::assertIsList($this->value, $message);
return $this;
}
/**
* Asserts that the value is of type bool.
*

View File

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

View File

@ -40,6 +40,10 @@ final class Only implements Terminable
*/
public static function enable(TestCall $testCall): void
{
if (Environment::name() == Environment::CI) {
return;
}
$testCall->group('__pest_only');
$lockFile = self::TEMPORARY_FOLDER.DIRECTORY_SEPARATOR.'only.lock';

View File

@ -63,8 +63,7 @@ final class ResultPrinter
{
public function __construct(
private readonly OutputInterface $output,
) {
}
) {}
public function print(string $buffer): void
{
@ -79,9 +78,7 @@ final class ResultPrinter
$this->output->write(OutputFormatter::escape($buffer));
}
public function flush(): void
{
}
public function flush(): void {}
};
$this->compactPrinter = CompactPrinter::default();

View File

@ -22,6 +22,10 @@ final class Printer implements HandlesArguments
return $arguments;
}
if (in_array('--no-output', $arguments, true)) {
return $arguments;
}
return $this->pushArgument('--no-output', $arguments);
}
}

View File

@ -21,8 +21,7 @@ final class SnapshotRepository
public function __construct(
readonly private string $testsPath,
readonly private string $snapshotsPath,
) {
}
) {}
/**
* Checks if the snapshot exists.

View File

@ -24,8 +24,7 @@ final class EnsureTeamCityEnabled implements ConfiguredSubscriber
private readonly InputInterface $input,
private readonly OutputInterface $output,
private readonly TestSuite $testSuite,
) {
}
) {}
/**
* Runs the subscriber.

View File

@ -30,8 +30,7 @@ final class ExpectationPipeline
*/
public function __construct(
private readonly Closure $closure
) {
}
) {}
/**
* Creates a new instance of Expectation Pipeline with given closure.

View File

@ -64,6 +64,8 @@ final class Exporter
continue;
}
assert(is_array($data));
$result[] = $context->contains($data[$key]) !== false
? '*RECURSION*'
: sprintf('[%s]', $this->shortenedRecursiveExport($data[$key], $context));

View File

@ -16,7 +16,6 @@ final class NullClosure
*/
public static function create(): Closure
{
return Closure::fromCallable(function (): void {
});
return Closure::fromCallable(function (): void {});
}
}

View File

@ -6,5 +6,5 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
//
}

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.32.2.
Pest Testing Framework 2.34.8.
USAGE: pest <file> [options]
@ -55,6 +55,7 @@
--stop-on-notice ............. Stop after first test that triggered a notice
--stop-on-skipped ............................ Stop after first skipped test
--stop-on-incomplete ...................... Stop after first incomplete test
--fail-on-empty-test-suite Signal failure using shell exit code when no tests were run
--fail-on-warning Signal failure using shell exit code when a warning was triggered
--fail-on-risky Signal failure using shell exit code when a test was considered risky
--fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.32.2.
Pest Testing Framework 2.34.8.

View File

@ -511,6 +511,12 @@
✓ passes with strings
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeList
✓ pass
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeLowercase
@ -1167,6 +1173,16 @@
PASS Tests\Hooks\BeforeEachTest
✓ global beforeEach execution order
PASS Tests\Overrides\VersionsTest
✓ versions with dataset "Runner/Filter/NameFilterIterator.php"
✓ versions with dataset "Runner/ResultCache/DefaultResultCache.php"
✓ versions with dataset "Runner/TestSuiteLoader.php"
✓ versions with dataset "TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php"
✓ versions with dataset "TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php"
✓ versions with dataset "TextUI/TestSuiteFilterProcessor.php"
✓ versions with dataset "Event/Value/ThrowableBuilder.php"
✓ versions with dataset "Logging/JUnit/JunitXmlLogger.php"
PASS Tests\PHPUnit\CustomAffixes\InvalidTestName
✓ it runs file names like @#$%^&()-_=+.php
@ -1379,6 +1395,10 @@
PASS Tests\Visual\Help
✓ visual snapshot of help command output
PASS Tests\Visual\JUnit
✓ junit output
✓ junit with parallel
PASS Tests\Visual\Parallel
✓ parallel
✓ a parallel test can extend another test with same name
@ -1404,4 +1424,4 @@
WARN Tests\Visual\Version
- visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 999 passed (2359 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 20 skipped, 1013 passed (2405 assertions)

View File

@ -10,9 +10,7 @@ use Tests\Fixtures\Covers\CoversTrait;
$runCounter = 0;
function testCoversFunction()
{
}
function testCoversFunction() {}
it('uses the correct PHPUnit attribute for class', function () {
$attributes = (new ReflectionClass($this))->getAttributes();

View File

@ -3,8 +3,7 @@
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect(function () {
})->toBeCallable();
expect(function () {})->toBeCallable();
expect(null)->not->toBeCallable();
});

View File

@ -0,0 +1,21 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toBeList();
expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList();
expect('1, 2, 3')->not->toBeList();
});
test('failures', function () {
expect(null)->toBeList();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect(null)->toBeList('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect(['a', 'b', 'c'])->not->toBeList();
})->throws(ExpectationFailedException::class);

View File

@ -4,13 +4,9 @@ use PHPUnit\Framework\ExpectationFailedException;
$object = new class
{
public function foo(): void
{
}
public function foo(): void {}
public function bar(): void
{
}
public function bar(): void {}
};
test('pass', function () use ($object) {

View File

@ -43,9 +43,7 @@ test('pass with `__toString`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function __toString()
{
@ -61,9 +59,7 @@ test('pass with `toString`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toString()
{
@ -97,9 +93,7 @@ test('pass with `toArray`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toArray()
{
@ -125,9 +119,7 @@ test('pass with `toSnapshot`', function () {
$object = new class($this->snapshotable)
{
public function __construct(protected string $snapshotable)
{
}
public function __construct(protected string $snapshotable) {}
public function toSnapshot()
{

View File

@ -2,9 +2,7 @@
use PHPUnit\Framework\ExpectationFailedException;
class CustomException extends Exception
{
}
class CustomException extends Exception {}
test('passes', function () {
expect(function () {
@ -15,15 +13,13 @@ test('passes', function () {
})->toThrow(Exception::class);
expect(function () {
throw new RuntimeException();
})->toThrow(function (RuntimeException $e) {
});
})->toThrow(function (RuntimeException $e) {});
expect(function () {
throw new RuntimeException('actual message');
})->toThrow(function (Exception $e) {
expect($e->getMessage())->toBe('actual message');
});
expect(function () {
})->not->toThrow(Exception::class);
expect(function () {})->not->toThrow(Exception::class);
expect(function () {
throw new RuntimeException('actual message');
})->toThrow('actual message');
@ -35,22 +31,18 @@ test('passes', function () {
})->toThrow(RuntimeException::class, 'actual message');
expect(function () {
throw new RuntimeException('actual message');
})->toThrow(function (RuntimeException $e) {
}, 'actual message');
})->toThrow(function (RuntimeException $e) {}, 'actual message');
expect(function () {
throw new CustomException('foo');
})->toThrow(new CustomException('foo'));
});
test('failures 1', function () {
expect(function () {
})->toThrow(RuntimeException::class);
expect(function () {})->toThrow(RuntimeException::class);
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 2', function () {
expect(function () {
})->toThrow(function (RuntimeException $e) {
});
expect(function () {})->toThrow(function (RuntimeException $e) {});
})->throws(ExpectationFailedException::class, 'Exception "'.RuntimeException::class.'" not thrown.');
test('failures 3', function () {
@ -77,8 +69,7 @@ test('failures 5', function () {
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' [ASCII](length: 14) contains "expected message" [ASCII](length: 16).');
test('failures 6', function () {
expect(function () {
})->toThrow('actual message');
expect(function () {})->toThrow('actual message');
})->throws(ExpectationFailedException::class, 'Exception with message "actual message" not thrown');
test('failures 7', function () {
@ -106,15 +97,11 @@ test('not failures', function () {
})->throws(ExpectationFailedException::class);
test('closure missing parameter', function () {
expect(function () {
})->toThrow(function () {
});
expect(function () {})->toThrow(function () {});
})->throws(InvalidArgumentException::class, 'The given closure must have a single parameter type-hinted as the class string.');
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.');
it('can handle a non-defined exception', function () {

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
class InvokableClass
{
public function __invoke(): void
{
}
public function __invoke(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsInvokable;
class ParentInvokableClass
{
public function __invoke(): void
{
}
public function __invoke(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToBeInvokable\IsNotInvokable;
class IsNotInvokableClass
{
public function handle(): void
{
}
public function handle(): void {}
}

View File

@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\Attributes;
use Attribute;
#[Attribute()]
class AsAttribute
{
}
class AsAttribute {}

View File

@ -7,6 +7,4 @@ namespace Tests\Fixtures\Arch\ToHaveAttribute\HaveAttribute;
use Tests\Fixtures\Arch\ToHaveAttribute\Attributes\AsAttribute;
#[AsAttribute]
class HaveAttributeClass
{
}
class HaveAttributeClass {}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveAttribute\NotHaveAttribute;
class NotHaveAttributeClass
{
}
class NotHaveAttributeClass {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveConstructor\HasConstructor;
class HasConstructor
{
public function __construct()
{
}
public function __construct() {}
}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveConstructor\HasNoConstructor;
class HasNoConstructor
{
}
class HasNoConstructor {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveDestructor\HasDestructor;
class HasDestructor
{
public function __destruct()
{
}
public function __destruct() {}
}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveDestructor\HasNoDestructor;
class HasNoDestructor
{
}
class HasNoDestructor {}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
class HasMethod
{
public function foo(): void
{
}
public function foo(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
trait HasMethodTrait
{
public function foo(): void
{
}
public function foo(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasMethod;
class ParentHasMethodClass
{
public function foo(): void
{
}
public function foo(): void {}
}

View File

@ -6,8 +6,5 @@ namespace Tests\Fixtures\Arch\ToHaveMethod\HasNoMethod;
class HasNoMethodClass
{
public function bar(): void
{
}
public function bar(): void {}
}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHavePrefix\HasNoPrefix;
class ClassWithout
{
}
class ClassWithout {}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHavePrefix\HasPrefix;
class PrefixClassWith
{
}
class PrefixClassWith {}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasNoSuffix;
class ClassWithout
{
}
class ClassWithout {}

View File

@ -4,6 +4,4 @@ declare(strict_types=1);
namespace Tests\Fixtures\Arch\ToHaveSuffix\HasSuffix;
class ClassWithSuffix
{
}
class ClassWithSuffix {}

View File

@ -4,7 +4,5 @@ namespace Tests\Fixtures\Covers;
class CoversClass1
{
public function foo()
{
}
public function foo() {}
}

View File

@ -2,6 +2,4 @@
namespace Tests\Fixtures\Covers;
class CoversClass2
{
}
class CoversClass2 {}

View File

@ -2,6 +2,4 @@
namespace Tests\Fixtures\Covers;
class CoversClass3
{
}
class CoversClass3 {}

View File

@ -2,6 +2,4 @@
namespace Tests\Fixtures\Covers;
trait CoversTrait
{
}
trait CoversTrait {}

View File

@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
use Pest\Bootstrappers\BootOverrides;
test('versions', function (string $vendorPath, string $expectedHash) {
expect(hash_file('sha256', $vendorPath))->toBe($expectedHash);
})->with(function () {
foreach (BootOverrides::FILES as $hash => $file) {
$path = implode(DIRECTORY_SEPARATOR, [
dirname(__DIR__, 2),
'vendor/phpunit/phpunit/src',
$file,
]);
yield $file => [$path, $hash];
}
});

View File

@ -50,21 +50,15 @@ it('cannot resolve a parameter without type', function () {
class ClassWithDependency
{
public function __construct(Container $container)
{
}
public function __construct(Container $container) {}
}
class ClassWithSubDependency
{
public function __construct(ClassWithDependency $param)
{
}
public function __construct(ClassWithDependency $param) {}
}
class ClassWithoutTypeParameter
{
public function __construct($param)
{
}
public function __construct($param) {}
}

View File

@ -3,8 +3,7 @@
use Pest\Support\Reflection;
it('gets file name from closure', function () {
$fileName = Reflection::getFileNameFromClosure(function () {
});
$fileName = Reflection::getFileNameFromClosure(function () {});
expect($fileName)->toBe(__FILE__);
});

View File

@ -19,8 +19,7 @@ it('does not allow to add the same test description twice', function () {
it('alerts users about tests with arguments but no input', function () {
$testSuite = new TestSuite(getcwd(), 'tests');
$method = new TestCaseMethodFactory('foo', 'bar', function (int $arg) {
});
$method = new TestCaseMethodFactory('foo', 'bar', function (int $arg) {});
$testSuite->tests->set($method);
})->throws(

79
tests/Visual/JUnit.php Normal file
View File

@ -0,0 +1,79 @@
<?php
use Symfony\Component\Process\Process;
$run = function () {
$junitLogFile = tempnam(sys_get_temp_dir(), 'junit');
$process = new Process(
array_merge(['php', 'bin/pest', '--log-junit', $junitLogFile], func_get_args()),
dirname(__DIR__, 2),
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
);
$process->run();
$rawXmlContent = file_get_contents($junitLogFile);
unlink($junitLogFile);
// convert xml to array
try {
$xml = new SimpleXMLElement(preg_replace("/(<\/?)(\w+):([^>]*>)/", '$1$2$3', $rawXmlContent));
return json_decode(json_encode((array) $xml), true);
} catch (Exception $exception) {
throw new XmlParseException($exception->getMessage(), $exception->getCode(), $exception->getPrevious());
}
};
$normalizedPath = function (string $path) {
return str_replace('/', DIRECTORY_SEPARATOR, $path);
};
test('junit output', function () use ($normalizedPath, $run) {
$result = $run('tests/.tests/SuccessOnly.php');
expect($result['testsuite']['@attributes'])
->name->toBe('Tests\tests\SuccessOnly')
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php'))
->tests->toBe('2')
->assertions->toBe('2')
->errors->toBe('0')
->failures->toBe('0')
->skipped->toBe('0');
expect($result['testsuite']['testcase'])
->toHaveCount(2);
expect($result['testsuite']['testcase'][0]['@attributes'])
->name->toBe('it can pass with comparison')
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php::it can pass with comparison'))
->class->toBe('Tests\tests\SuccessOnly')
->classname->toBe('Tests.tests.SuccessOnly')
->assertions->toBe('1')
->time->toStartWith('0.0');
});
test('junit with parallel', function () use ($normalizedPath, $run) {
$result = $run('tests/.tests/SuccessOnly.php', '--parallel', '--processes=1', '--filter', 'can pass with comparison');
expect($result['testsuite']['@attributes'])
->name->toBe('Tests\tests\SuccessOnly')
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php'))
->tests->toBe('1')
->assertions->toBe('1')
->errors->toBe('0')
->failures->toBe('0')
->skipped->toBe('0');
expect($result['testsuite']['testcase'])
->toHaveCount(1);
expect($result['testsuite']['testcase']['@attributes'])
->name->toBe('it can pass with comparison')
->file->toBe($normalizedPath('tests/.tests/SuccessOnly.php::it can pass with comparison'))
->class->toBe('Tests\tests\SuccessOnly')
->classname->toBe('Tests.tests.SuccessOnly')
->assertions->toBe('1')
->time->toStartWith('0.0');
});

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 986 passed (2340 assertions)')
->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 16 skipped, 998 passed (2358 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();