Compare commits

...

25 Commits

Author SHA1 Message Date
d39e4f15fe release: v2.5.2 2023-04-19 09:53:08 +01:00
1a05df14d0 chore: bumps dependencies 2023-04-19 09:49:26 +01:00
5c0df87f52 release: v2.5.1 2023-04-18 00:47:56 +01:00
ec6a81735a chore: bumps phpunit dependency 2023-04-18 00:45:41 +01:00
2ea37f3424 Merge pull request #772 from MaurizioMoreo/pcov_fix
Add PCOV availability check
2023-04-16 14:11:05 +01:00
2e4206cb97 tests: adjusts snapshots 2023-04-15 16:17:22 +01:00
72b3cdaab4 Merge pull request #770 from ganyicz/2.x
Update stub extensions
2023-04-15 16:12:16 +01:00
9744b9848e Merge pull request #783 from fabio-ivona/fix-comments-in-test-name
fix comments in dokblocks
2023-04-15 11:26:06 +01:00
e1143d2cfc remove ->only() 2023-04-15 11:52:07 +02:00
5861b0498a fix comments in dokblocks 2023-04-15 10:45:51 +02:00
f6d9aa51bd chore: bump dependencies 2023-04-14 11:50:44 +01:00
9070b12377 release: v2.5.0 2023-04-14 11:13:56 +01:00
dab68d6d85 Fixes caret 2023-04-14 11:12:32 +01:00
40de54ecd5 Merge pull request #780 from pestphp/chore/phpunit10-1-support
[2.x] Adds `phpunit/phpunit@10.1` support
2023-04-14 11:02:06 +01:00
6d8b926df3 chore: adjusts for parallel testing 2023-04-14 11:01:54 +01:00
d6c3f3522b chore: fix caret 2023-04-13 12:51:19 +01:00
41cdb5f01b chore: skips parallel testing 2023-04-13 12:23:17 +01:00
0064f3fdff chore: phpunit ^10.1 support 2023-04-13 11:03:29 +01:00
518035514e Add PHPDBG availability check 2023-04-09 09:27:52 +02:00
81cdb7a300 chore: refacto 2023-04-08 12:23:10 +01:00
97dbda92e6 Update stub extensions 2023-04-08 01:24:00 +02:00
4520fe918a Add PCOV availability check 2023-04-07 17:19:34 +02:00
f73e6aebcb Merge pull request #763 from gehrisandro/fix-typos
[2.x] fix: various typos fixed
2023-04-03 08:11:53 +01:00
3b9ca8853f fix: various typos fixed 2023-04-03 07:50:25 +02:00
cbc26faeb9 docs: updates changelog 2023-04-02 21:13:55 +01:00
37 changed files with 125 additions and 66 deletions

View File

@ -43,4 +43,4 @@ jobs:
- name: Unit Tests in Parallel
run: composer test:parallel
if: startsWith(matrix.os, 'windows') != true

View File

@ -2,17 +2,32 @@
## Unreleased
## [v2.3.0 (2023-04-03)](https://github.com/pestphp/pest/compare/v2.3.0...v2.4.0)
## [v2.5.2 (2023-04-19)](https://github.com/pestphp/pest/compare/v2.5.1...v2.5.2)
### Chore
- Removes `myclabs/php-enuma` dependency ([1a05df1](https://github.com/pestphp/pest/commit/1a05df14d0ce7d12583df26ff716807db6f81f13))
## [v2.5.1 (2023-04-18)](https://github.com/pestphp/pest/compare/v2.5.0...v2.5.1)
### Chore
- Bumps PHPUnit to `^10.1.1` ([ec6a817](https://github.com/pestphp/pest/commit/ec6a81735af19f5463d24545df97535d77697ec6))
## [v2.5.0 (2023-04-14)](https://github.com/pestphp/pest/compare/v2.4.0...v2.5.0)
### Chore
- Bumps PHPUnit to `^10.1.0` ([#780](https://github.com/pestphp/pest/pull/780))
## [v2.4.0 (2023-04-03)](https://github.com/pestphp/pest/compare/v2.3.0...v2.4.0)
### Added
- `skipOnWindows()`, `skipOnMac()`, and `skipOnLinux()` ([#757](https://github.com/pestphp/pest/pull/757))
- source architecture testing violation ([#1](https://github.com/pestphp/pest-plugin-arch/pull/1))((8e66263)[https://github.com/pestphp/pest-plugin-arch/commit/8e66263104304e99e3d6ceda25c7ed679b27fb03])
- source architecture testing violation ([#1](https://github.com/pestphp/pest-plugin-arch/pull/1))([8e66263](https://github.com/pestphp/pest-plugin-arch/commit/8e66263104304e99e3d6ceda25c7ed679b27fb03))
- `toHaveProperties` may now also check values ([#760](https://github.com/pestphp/pest/pull/760))
### Fixed
- Tests on `tests/Helpers` directory not being executed ([#753](https://github.com/pestphp/pest/pull/753))
- Teamcity count ([#747](https://github.com/pestphp/pest/pull/747))
- Parallel executation when class extends class with same name ([#748](https://github.com/pestphp/pest/pull/748))
- Parallel execution when class extends class with same name ([#748](https://github.com/pestphp/pest/pull/748))
- Wording on `uses()` hint ([#745](https://github.com/pestphp/pest/pull/745/files))
## [v2.3.0 (2023-03-28)](https://github.com/pestphp/pest/compare/v2.2.3...v2.3.0)
@ -29,14 +44,14 @@
## [v2.2.3 (2023-03-24)](https://github.com/pestphp/pest/compare/v2.2.2...v2.2.3)
### Fixed
- Unnecessary dataset on dataset arguments missmatch ([#736](https://github.com/pestphp/pest/pull/736))
- Unnecessary dataset on dataset arguments mismatch ([#736](https://github.com/pestphp/pest/pull/736))
- Parallel arguments on plugins order ([#703](https://github.com/pestphp/pest/pull/703))
- Arch plugin runtime exceptions on bad phpdocs ([2f2b51c](https://github.com/pestphp/pest/commit/2f2b51ce3d1b000be9d6add0e785fd0044931b3b))
## [v2.2.2 (2023-03-23)](https://github.com/pestphp/pest/compare/v2.2.1...v2.2.2)
### Fixed
- Edge case in parallel executation test description ([3ce6408](https://github.com/pestphp/pest/commit/3ce640819541ca6022b250e000f336d87c3e7889))
- Edge case in parallel execution test description ([3ce6408](https://github.com/pestphp/pest/commit/3ce640819541ca6022b250e000f336d87c3e7889))
## [v2.2.1 (2023-03-22)](https://github.com/pestphp/pest/compare/v2.2.0...v2.2.1)

View File

@ -18,16 +18,16 @@
],
"require": {
"php": "^8.1.0",
"brianium/paratest": "^7.1.2",
"nunomaduro/collision": "^7.4.0",
"brianium/paratest": "^7.1.3",
"nunomaduro/collision": "^7.5.0",
"nunomaduro/termwind": "^1.15.1",
"pestphp/pest-plugin": "^2.0.1",
"pestphp/pest-plugin-arch": "^2.1.1",
"phpunit/phpunit": "^10.0.19"
"pestphp/pest-plugin-arch": "^2.1.2",
"phpunit/phpunit": "^10.1.1"
},
"conflict": {
"webmozart/assert": "<1.11.0",
"phpunit/phpunit": ">10.0.19"
"phpunit/phpunit": ">10.1.1"
},
"autoload": {
"psr-4": {

View File

@ -21,9 +21,9 @@
<exclude>./tests/Fixtures/Inheritance</exclude>
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
</source>
</phpunit>

View File

@ -87,7 +87,7 @@ trait Testable
*/
public function __addBeforeAll(?Closure $hook): void
{
if ($hook === null) {
if (! $hook instanceof \Closure) {
return;
}
@ -101,7 +101,7 @@ trait Testable
*/
public function __addAfterAll(?Closure $hook): void
{
if ($hook === null) {
if (! $hook instanceof \Closure) {
return;
}
@ -131,7 +131,7 @@ trait Testable
*/
private function __addHook(string $property, ?Closure $hook): void
{
if ($hook === null) {
if (! $hook instanceof \Closure) {
return;
}

View File

@ -7,7 +7,7 @@ namespace Pest\Contracts;
use Pest\Factories\TestCaseMethodFactory;
/**
* @interal
* @internal
*/
interface AddsAnnotations
{

View File

@ -14,7 +14,17 @@ final class TestDox implements AddsAnnotations
*/
public function __invoke(TestCaseMethodFactory $method, array $annotations): array
{
$annotations[] = "@testdox $method->description";
/*
* escapes docblock according to
* https://manual.phpdoc.org/HTMLframesConverter/default/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#basics.desc
*
* note: '@' escaping is not needed as it cannot be the first character of the line (it always starts with @testdox
*/
assert($method->description !== null);
$methodDescription = str_replace('*/', '{@*}', $method->description);
$annotations[] = "@testdox $methodDescription";
return $annotations;
}

View File

@ -14,7 +14,7 @@ use Pest\Factories\TestCaseMethodFactory;
final class Covers extends Attribute
{
/**
* Determine if the attribute should be placed above the classe instead of above the method.
* Determine if the attribute should be placed above the class instead of above the method.
*/
public static bool $above = true;

View File

@ -217,7 +217,7 @@ final class TestCaseFactory
}
if (! $method->receivesArguments()) {
if ($method->closure === null) {
if (! $method->closure instanceof \Closure) {
throw ShouldNotHappen::fromMessage('The test closure may not be empty.');
}

View File

@ -92,7 +92,7 @@ if (! function_exists('test')) {
*/
function test(string $description = null, Closure $closure = null): HigherOrderTapProxy|TestCall
{
if ($description === null && TestSuite::getInstance()->test !== null) {
if ($description === null && TestSuite::getInstance()->test instanceof \PHPUnit\Framework\TestCase) {
return new HigherOrderTapProxy(TestSuite::getInstance()->test);
}

View File

@ -64,7 +64,7 @@ final class Converter
}
/**
* Gets the exception messsage.
* Gets the exception message.
*/
public function getExceptionMessage(Throwable $throwable): string
{

View File

@ -34,6 +34,7 @@ use PHPUnit\Event\TestSuite\Finished as TestSuiteFinished;
use PHPUnit\Event\TestSuite\Started as TestSuiteStarted;
use PHPUnit\Event\UnknownSubscriberTypeException;
use PHPUnit\TestRunner\TestResult\Facade as TestResultFacade;
use ReflectionClass;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
@ -180,7 +181,7 @@ final class TeamCityLogger
public function testFinished(Finished $event): void
{
if ($this->time === null) {
if (! $this->time instanceof \PHPUnit\Event\Telemetry\HRTime) {
throw ShouldNotHappen::fromMessage('Start time has not been set.');
}
@ -207,13 +208,17 @@ final class TeamCityLogger
$style = new Style($this->output);
$telemetry = $event->telemetryInfo();
if ($this->withoutDuration) {
$reflector = new ReflectionClass($telemetry);
$property = $reflector->getProperty('current');
$property->setAccessible(true);
$snapshot = $property->getValue($telemetry);
assert($snapshot instanceof Snapshot);
$telemetry = new Info(
new Snapshot(
$telemetry->time(),
$telemetry->memoryUsage(),
$telemetry->peakMemoryUsage(),
),
$snapshot,
Duration::fromSecondsAndNanoseconds(1, 0),
$telemetry->memoryUsageSinceStart(),
$telemetry->durationSincePrevious(),

View File

@ -900,7 +900,7 @@ final class Expectation
*/
private function export(mixed $value): string
{
if ($this->exporter === null) {
if (! $this->exporter instanceof \Pest\Support\Exporter) {
$this->exporter = Exporter::default();
}

View File

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

View File

@ -26,11 +26,11 @@ final class Init implements HandlesArguments
* The files that will be created.
*/
private const STUBS = [
'phpunit.xml' => 'phpunit.xml',
'Pest.php' => 'tests/Pest.php',
'TestCase.php' => 'tests/TestCase.php',
'Unit/ExampleTest.php' => 'tests/Unit/ExampleTest.php',
'Feature/ExampleTest.php' => 'tests/Feature/ExampleTest.php',
'phpunit.xml.stub' => 'phpunit.xml',
'Pest.php.stub' => 'tests/Pest.php',
'TestCase.php.stub' => 'tests/TestCase.php',
'Unit/ExampleTest.php.stub' => 'tests/Unit/ExampleTest.php',
'Feature/ExampleTest.php.stub' => 'tests/Feature/ExampleTest.php',
];
/**

View File

@ -7,6 +7,7 @@ namespace Pest\Plugins\Parallel\Support;
use NunoMaduro\Collision\Adapters\Phpunit\State;
use NunoMaduro\Collision\Adapters\Phpunit\Style;
use ParaTest\Options;
use PHPUnit\Event\Telemetry\GarbageCollectorStatus;
use PHPUnit\Event\Telemetry\HRTime;
use PHPUnit\Event\Telemetry\Info;
use PHPUnit\Event\Telemetry\MemoryUsage;
@ -122,11 +123,25 @@ final class CompactPrinter
$snapshotDuration = HRTime::fromSecondsAndNanoseconds((int) $duration->asSeconds(), $nanoseconds);
$telemetryDuration = \PHPUnit\Event\Telemetry\Duration::fromSecondsAndNanoseconds((int) $duration->asSeconds(), $nanoseconds);
$status = gc_status();
$garbageCollectorStatus = new GarbageCollectorStatus(
$status['runs'],
$status['collected'],
$status['threshold'],
$status['roots'],
null,
null,
null,
null,
);
$telemetry = new Info(
new Snapshot(
$snapshotDuration,
MemoryUsage::fromBytes(0),
MemoryUsage::fromBytes(0),
$garbageCollectorStatus,
),
$telemetryDuration,
MemoryUsage::fromBytes(0),

View File

@ -25,7 +25,7 @@ final class Container
*/
public static function getInstance(): self
{
if (self::$instance === null) {
if (! self::$instance instanceof \Pest\Support\Container) {
self::$instance = new self();
}
@ -72,7 +72,7 @@ final class Container
if ($reflectionClass->isInstantiable()) {
$constructor = $reflectionClass->getConstructor();
if ($constructor !== null) {
if ($constructor instanceof \ReflectionMethod) {
$params = array_map(
function (ReflectionParameter $param) use ($id): object|string {
$candidate = Reflection::getParameterClassName($param);
@ -80,7 +80,7 @@ final class Container
if ($candidate === null) {
$type = $param->getType();
/* @phpstan-ignore-next-line */
if ($type !== null && $type->isBuiltin()) {
if ($type instanceof \ReflectionType && $type->isBuiltin()) {
$candidate = $param->getName();
} else {
throw ShouldNotHappen::fromMessage(sprintf('The type of `$%s` in `%s` cannot be determined.', $id, $param->getName()));

View File

@ -42,6 +42,14 @@ final class Coverage
return false;
}
if ($runtime->hasPCOV()) {
return true;
}
if ($runtime->hasPHPDBGCodeCoverage()) {
return true;
}
if (! $runtime->hasXdebug()) {
return true;
}

View File

@ -1,5 +1,5 @@
Pest Testing Framework 2.4.0.
Pest Testing Framework 2.5.2.
USAGE: pest <file> [options]
@ -43,15 +43,19 @@
--enforce-time-limit ................. Enforce time limit based on test 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
--stop-on-defect ... Stop after first error, failure, warning or, risky test
--stop-on-defect ... Stop after first error, failure, warning, or risky test
--stop-on-error ..................................... Stop after first error
--stop-on-failure ................................. Stop after first failure
--stop-on-warning ................................. Stop after first warning
--stop-on-risky ................................ Stop after first risky test
--stop-on-deprecation ... Stop after first test that triggered a deprecation
--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-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
--fail-on-notice Signal failure using shell exit code when a notice was triggered
--fail-on-skipped Signal failure using shell exit code when a test was skipped
--fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete
--cache-result ............................ Write test results to cache file

View File

@ -153,7 +153,7 @@
DEPR Tests\Features\Deprecated
! deprecated → str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated // tests/Features/Deprecated.php:6
! user deprecated → Since foo 1.0: This is a deprecation description // vendor/symfony/deprecation-contracts/function.php:25
user deprecated
PASS Tests\Features\Exceptions
✓ it gives access the the underlying expectException
@ -332,14 +332,14 @@
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeGreatherThan
PASS Tests\Features\Expect\toBeGreaterThan
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeGreatherThanOrEqual
PASS Tests\Features\Expect\toBeGreaterThanOrEqual
✓ passes
✓ passes with DateTime and DateTimeImmutable
✓ failures
@ -977,6 +977,7 @@
✓ Німеччина
✓ Nam Định
✓ 呼和浩特
✓ test /** with comment */ should do
PASS Tests\Unit\TestSuite
✓ it does not allow to add the same test description twice
@ -1016,4 +1017,4 @@
PASS Tests\Visual\Version
✓ visual snapshot of help command output
Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 709 passed (1717 assertions)
Tests: 1 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 14 skipped, 711 passed (1719 assertions)

View File

@ -1,3 +1,3 @@
Pest Testing Framework 2.4.0.
Pest Testing Framework 2.5.2.

View File

@ -85,16 +85,16 @@ it('works with higher order tests')
it('can use the scoped method to lock into the given level for expectations', function () {
expect(new HasMethods())
->attributes()->scoped(fn ($attributes) => $attributes
->name->toBe('Has Methods')
->quantity->toBe(20)
->name->toBe('Has Methods')
->quantity->toBe(20)
)
->name()->toBeString()->toBe('Has Methods')
->newInstance()->newInstance()->scoped(fn ($instance) => $instance
->name()->toBe('Has Methods')
->quantity()->toBe(20)
->attributes()->scoped(fn ($attributes) => $attributes
->name->toBe('Has Methods')
->quantity->toBe(20)
->name()->toBe('Has Methods')
->quantity()->toBe(20)
->attributes()->scoped(fn ($attributes) => $attributes
->name->toBe('Has Methods')
->quantity->toBe(20)
)
);
});

View File

@ -171,19 +171,19 @@ test('pipe works with negated expectation', function () use ($state) {
$state->reset();
expect($char)->not->toBe(new Char('B'))
->and($state)
->runCount->toMatchArray([
'char' => 1,
'number' => 0,
'wildcard' => 0,
'symbol' => 0,
])
->appliedCount->toMatchArray([
'char' => 1,
'number' => 0,
'wildcard' => 0,
'symbol' => 0,
]);
->and($state)
->runCount->toMatchArray([
'char' => 1,
'number' => 0,
'wildcard' => 0,
'symbol' => 0,
])
->appliedCount->toMatchArray([
'char' => 1,
'number' => 0,
'wildcard' => 0,
'symbol' => 0,
]);
});
test('interceptor is applied', function () use ($state) {

View File

@ -61,6 +61,7 @@ $names = [
'Німеччина' => '__pest_evaluable_Німеччина',
'Nam Định' => '__pest_evaluable_Nam_Định',
'呼和浩特' => '__pest_evaluable_呼和浩特',
'test /** with comment */ should do' => '__pest_evaluable_test_____with_comment____should_do',
];
foreach ($names as $name => $methodName) {

View File

@ -18,7 +18,7 @@ $run = function () {
test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 2 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 697 passed (1702 assertions)')
->toContain('Tests: 1 deprecated, 3 warnings, 4 incomplete, 1 notice, 4 todos, 11 skipped, 699 passed (1704 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();