From ee32f25485dc0e1597f01ba47476d0bfa2a666de Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 4 Jul 2024 00:53:58 +0100 Subject: [PATCH] feat: `pr` and `issue` --- bin/pest | 68 +++++++++++++++- src/ArchPresets/Laravel.php | 14 ++-- src/Concerns/Testable.php | 80 +++++++++++++------ src/Configuration.php | 8 ++ src/Configuration/Context.php | 67 ++++++++++++++++ src/Expectation.php | 8 +- src/Expectations/OppositeExpectation.php | 6 +- src/Factories/TestCaseMethodFactory.php | 14 ++++ src/PendingCalls/DescribeCall.php | 19 ++++- src/PendingCalls/TestCall.php | 42 ++++++++++ src/Plugins/Concerns/HandleArguments.php | 2 +- src/Plugins/Help.php | 12 +++ src/Plugins/Parallel.php | 2 +- src/Support/Coverage.php | 2 + .../IssueTestCaseFilter.php | 27 +++++++ .../NotesTestCaseFilter.php | 2 +- .../PrTestCaseFilter.php | 27 +++++++ .../TodoTestCaseFilter.php | 5 +- ...isual_snapshot_of_help_command_output.snap | 3 + tests/.snapshots/success.txt | 17 +++- tests/Features/After.php | 2 +- tests/Features/Issue.php | 15 ++++ tests/Features/Pr.php | 15 ++++ tests/Features/Ticket.php | 15 ++++ tests/Pest.php | 2 + tests/Visual/Parallel.php | 2 +- 26 files changed, 423 insertions(+), 53 deletions(-) create mode 100644 src/Configuration/Context.php create mode 100644 src/TestCaseMethodFilters/IssueTestCaseFilter.php create mode 100644 src/TestCaseMethodFilters/PrTestCaseFilter.php create mode 100644 tests/Features/Issue.php create mode 100644 tests/Features/Pr.php create mode 100644 tests/Features/Ticket.php diff --git a/bin/pest b/bin/pest index 875bb9a5..79d897c8 100755 --- a/bin/pest +++ b/bin/pest @@ -4,7 +4,9 @@ use Pest\Kernel; use Pest\Panic; use Pest\TestCaseFilters\GitDirtyTestCaseFilter; +use Pest\TestCaseMethodFilters\IssueTestCaseFilter; use Pest\TestCaseMethodFilters\NotesTestCaseFilter; +use Pest\TestCaseMethodFilters\PrTestCaseFilter; use Pest\TestCaseMethodFilters\TodoTestCaseFilter; use Pest\TestSuite; use Symfony\Component\Console\Input\ArgvInput; @@ -21,6 +23,7 @@ use Symfony\Component\Console\Output\ConsoleOutput; $notes = false; foreach ($arguments as $key => $value) { + if ($value === '--compact') { $_SERVER['COLLISION_PRINTER_COMPACT'] = 'true'; unset($arguments[$key]); @@ -31,8 +34,14 @@ use Symfony\Component\Console\Output\ConsoleOutput; unset($arguments[$key]); } - if (str_contains($value, '--test-directory')) { + if (str_contains($value, '--test-directory=')) { unset($arguments[$key]); + } else if ($value === '--test-directory') { + unset($arguments[$key]); + + if (isset($arguments[$key + 1])) { + unset($arguments[$key + 1]); + } } if ($value === '--dirty') { @@ -50,6 +59,46 @@ use Symfony\Component\Console\Output\ConsoleOutput; unset($arguments[$key]); } + if (str_contains($value, '--issue=')) { + unset($arguments[$key]); + } else if ($value === '--issue') { + unset($arguments[$key]); + + if (isset($arguments[$key + 1])) { + unset($arguments[$key + 1]); + } + } + + if (str_contains($value, '--ticket=')) { + unset($arguments[$key]); + } else if ($value === '--ticket') { + unset($arguments[$key]); + + if (isset($arguments[$key + 1])) { + unset($arguments[$key + 1]); + } + } + + if (str_contains($value, '--pr=')) { + unset($arguments[$key]); + } else if ($value === '--pr') { + unset($arguments[$key]); + + if (isset($arguments[$key + 1])) { + unset($arguments[$key + 1]); + } + } + + if (str_contains($value, '--pull-request=')) { + unset($arguments[$key]); + } else if ($value === '--pull-request') { + unset($arguments[$key]); + + if (isset($arguments[$key + 1])) { + unset($arguments[$key + 1]); + } + } + if (str_contains($value, '--teamcity')) { unset($arguments[$key]); $arguments[] = '--no-output'; @@ -57,6 +106,7 @@ use Symfony\Component\Console\Output\ConsoleOutput; } } + // Used when Pest is required using composer. $vendorPath = dirname(__DIR__, 4).'/vendor/autoload.php'; @@ -92,6 +142,22 @@ use Symfony\Component\Console\Output\ConsoleOutput; $testSuite->tests->addTestCaseMethodFilter(new NotesTestCaseFilter()); } + if ($issue = $input->getParameterOption('--issue')) { + $testSuite->tests->addTestCaseMethodFilter(new IssueTestCaseFilter((int) $issue)); + } + + if ($issue = $input->getParameterOption('--ticket')) { + $testSuite->tests->addTestCaseMethodFilter(new IssueTestCaseFilter((int) $issue)); + } + + if ($pr = $input->getParameterOption('--pr')) { + $testSuite->tests->addTestCaseMethodFilter(new PrTestCaseFilter((int) $pr)); + } + + if ($pr = $input->getParameterOption('--pull-request')) { + $testSuite->tests->addTestCaseMethodFilter(new PrTestCaseFilter((int) $pr)); + } + $isDecorated = $input->getParameterOption('--colors', 'always') !== 'never'; $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated); diff --git a/src/ArchPresets/Laravel.php b/src/ArchPresets/Laravel.php index 0a2a1a2f..ad059ec2 100644 --- a/src/ArchPresets/Laravel.php +++ b/src/ArchPresets/Laravel.php @@ -50,7 +50,7 @@ final class Laravel extends AbstractPreset ->classes() ->toHaveMethod('handle'); - $this->expectations[] = expect('App\Models') + $this->expectations[] = expect('App\Models') // @phpstan-ignore-line ->classes() ->toExtend('Illuminate\Database\Eloquent\Model') ->not->toHaveSuffix('Model'); @@ -62,7 +62,7 @@ final class Laravel extends AbstractPreset $this->expectations[] = expect('App\Http\Requests') ->classes() ->toHaveSuffix('Request') - ->toExtend('Illuminate\Foundation\Http\FormRequest') // @phpstan-ignore-line + ->toExtend('Illuminate\Foundation\Http\FormRequest') ->toHaveMethod('rules'); $this->expectations[] = expect('App') @@ -72,7 +72,7 @@ final class Laravel extends AbstractPreset $this->expectations[] = expect('App\Console\Commands') ->classes() ->toHaveSuffix('Command') - ->toExtend('Illuminate\Console\Command') // @phpstan-ignore-line + ->toExtend('Illuminate\Console\Command') ->toHaveMethod('handle'); $this->expectations[] = expect('App') @@ -81,7 +81,7 @@ final class Laravel extends AbstractPreset $this->expectations[] = expect('App\Mail') ->classes() - ->toExtend('Illuminate\Mail\Mailable'); // @phpstan-ignore-line + ->toExtend('Illuminate\Mail\Mailable'); $this->expectations[] = expect('App') ->not->toExtend('Illuminate\Mail\Mailable') @@ -101,7 +101,7 @@ final class Laravel extends AbstractPreset ->toHaveMethod('handle'); $this->expectations[] = expect('App\Notifications') - ->toExtend('Illuminate\Notifications\Notification'); // @phpstan-ignore-line + ->toExtend('Illuminate\Notifications\Notification'); $this->expectations[] = expect('App') ->not->toExtend('Illuminate\Notifications\Notification') @@ -109,10 +109,10 @@ final class Laravel extends AbstractPreset $this->expectations[] = expect('App\Providers') // @phpstan-ignore-line ->toHaveSuffix('ServiceProvider') - ->toExtend('Illuminate\Support\ServiceProvider') // @phpstan-ignore-line + ->toExtend('Illuminate\Support\ServiceProvider') ->not->toBeUsed(); - $this->expectations[] = expect('App') + $this->expectations[] = expect('App') // @phpstan-ignore-line ->not->toExtend('Illuminate\Support\ServiceProvider') ->not->toHaveSuffix('ServiceProvider') ->ignoring('App\Providers'); diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index a204b728..f2090169 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -29,15 +29,29 @@ trait Testable */ private string $__description; + /** + * The test's latest description. + */ + private static string $__latestDescription; + /** * The test's notes. */ private static array $__latestNotes = []; /** - * The test's latest description. + * The test's issues. + * + * @var array */ - private static string $__latestDescription; + private static array $__latestIssues = []; + + /** + * The test's PRs. + * + * @var array + */ + private static array $__latestPrs = []; /** * The test's describing, if any. @@ -79,27 +93,6 @@ trait Testable */ private array $__snapshotChanges = []; - /** - * Adds a new "note" to the Test Case. - */ - public function note(array|string $note): self - { - $note = is_array($note) ? $note : [$note]; - - self::$__latestNotes = array_merge(self::$__latestNotes, $note); - - return $this; - } - - /** - * Resets the test case static properties. - */ - public static function flush(): void - { - self::$__beforeAll = null; - self::$__afterAll = null; - } - /** * Creates a new Test Case instance. */ @@ -113,11 +106,34 @@ trait Testable $method = $test->getMethod($name); $this->__description = self::$__latestDescription = $method->description; self::$__latestNotes = $method->notes; + self::$__latestIssues = $method->issues; + self::$__latestPrs = $method->prs; $this->__describing = $method->describing; $this->__test = $method->getClosure($this); } } + /** + * Resets the test case static properties. + */ + public static function flush(): void + { + self::$__beforeAll = null; + self::$__afterAll = null; + } + + /** + * Adds a new "note" to the Test Case. + */ + public function note(array|string $note): self + { + $note = is_array($note) ? $note : [$note]; + + self::$__latestNotes = array_merge(self::$__latestNotes, $note); + + return $this; + } + /** * Adds a new "setUpBeforeClass" to the Test Case. */ @@ -243,6 +259,8 @@ trait Testable $this->__description = self::$__latestDescription = $description; self::$__latestNotes = $method->notes; + self::$__latestIssues = $method->issues; + self::$__latestPrs = $method->prs; parent::setUp(); @@ -432,4 +450,20 @@ trait Testable { return self::$__latestNotes; } + + /** + * The latest printable test case issues. + */ + public static function getPrintableTestCaseMethodIssues(): array + { + return self::$__latestIssues; + } + + /** + * The latest printable test case PRs. + */ + public static function getPrintableTestCaseMethodPrs(): array + { + return self::$__latestPrs; + } } diff --git a/src/Configuration.php b/src/Configuration.php index f4c291fc..55fb589d 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -75,4 +75,12 @@ final class Configuration { return new Configuration\Theme(); } + + /** + * Gets the context configuration. + */ + public function context(): Configuration\Context + { + return new Configuration\Context(); + } } diff --git a/src/Configuration/Context.php b/src/Configuration/Context.php new file mode 100644 index 00000000..0bec19ff --- /dev/null +++ b/src/Configuration/Context.php @@ -0,0 +1,67 @@ +|class-string $interfaces + * @param array|string $interfaces */ public function toOnlyImplement(array|string $interfaces): ArchExpectation { @@ -704,7 +702,7 @@ final class Expectation /** * Asserts that the given expectation target to implement the given interfaces. * - * @param array|class-string $interfaces + * @param array|string $interfaces */ public function toImplement(array|string $interfaces): ArchExpectation { @@ -888,8 +886,6 @@ final class Expectation /** * Asserts that the given expectation target to have the given attribute. - * - * @param class-string $attribute */ public function toHaveAttribute(string $attribute): ArchExpectation { diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index 9e5d67f3..8f3b45cf 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -226,8 +226,6 @@ final class OppositeExpectation /** * Asserts that the given expectation target to be not subclass of the given class. - * - * @param class-string $class */ public function toExtend(string $class): ArchExpectation { @@ -288,7 +286,7 @@ final class OppositeExpectation /** * Asserts that the given expectation target not to implement the given interfaces. * - * @param array|string $interfaces + * @param array|string $interfaces */ public function toImplement(array|string $interfaces): ArchExpectation { @@ -421,8 +419,6 @@ final class OppositeExpectation /** * Asserts that the given expectation target not to have the given attribute. - * - * @param class-string $attribute */ public function toHaveAttribute(string $attribute): ArchExpectation { diff --git a/src/Factories/TestCaseMethodFactory.php b/src/Factories/TestCaseMethodFactory.php index 299e9bae..11d30039 100644 --- a/src/Factories/TestCaseMethodFactory.php +++ b/src/Factories/TestCaseMethodFactory.php @@ -49,6 +49,20 @@ final class TestCaseMethodFactory */ public bool $todo = false; + /** + * The associated issue numbers. + * + * @var array + */ + public array $issues = []; + + /** + * The associated PRs numbers. + * + * @var array + */ + public array $prs = []; + /** * The test's notes. * diff --git a/src/PendingCalls/DescribeCall.php b/src/PendingCalls/DescribeCall.php index dc8e5e4f..267c875a 100644 --- a/src/PendingCalls/DescribeCall.php +++ b/src/PendingCalls/DescribeCall.php @@ -18,6 +18,11 @@ final class DescribeCall */ private static ?string $describing = null; + /** + * The describe "before each" call. + */ + private ?BeforeEachCall $currentBeforeEachCall = null; + /** * Creates a new Pending Call. */ @@ -43,6 +48,8 @@ final class DescribeCall */ public function __destruct() { + unset($this->currentBeforeEachCall); + self::$describing = $this->description; try { @@ -57,14 +64,18 @@ final class DescribeCall * * @param array $arguments */ - public function __call(string $name, array $arguments): BeforeEachCall + public function __call(string $name, array $arguments): self { $filename = Backtrace::file(); - $beforeEachCall = new BeforeEachCall(TestSuite::getInstance(), $filename); + if (! $this->currentBeforeEachCall instanceof \Pest\PendingCalls\BeforeEachCall) { + $this->currentBeforeEachCall = new BeforeEachCall(TestSuite::getInstance(), $filename); - $beforeEachCall->describing = $this->description; + $this->currentBeforeEachCall->describing = $this->description; + } - return $beforeEachCall->{$name}(...$arguments); // @phpstan-ignore-line + $this->currentBeforeEachCall->{$name}(...$arguments); // @phpstan-ignore-line + + return $this; } } diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 2ae319cf..b5e1a82f 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -364,6 +364,48 @@ final class TestCall return $this; } + /** + * Associates the test with the given issue(s). + * + * @param array|string|int $number + */ + public function issue(array|string|int $number): self + { + $number = is_array($number) ? $number : [$number]; + + $number = array_map(fn (string|int $number): int => (int) ltrim((string) $number, '#'), $number); + + $this->testCaseMethod->issues = array_merge($this->testCaseMethod->issues, $number); + + return $this; + } + + /** + * Associates the test with the given ticket(s). (Alias for `issue`) + * + * @param array|string|int $number + */ + public function ticket(array|string|int $number): self + { + return $this->issue($number); + } + + /** + * Associates the test with the given pull request(s). + * + * @param array|string|int $number + */ + public function pr(array|string|int $number): self + { + $number = is_array($number) ? $number : [$number]; + + $number = array_map(fn (string|int $number): int => (int) ltrim((string) $number, '#'), $number); + + $this->testCaseMethod->prs = array_merge($this->testCaseMethod->issues, $number); + + return $this; + } + /** * Adds a note to the test. * diff --git a/src/Plugins/Concerns/HandleArguments.php b/src/Plugins/Concerns/HandleArguments.php index bc686942..9cf5e606 100644 --- a/src/Plugins/Concerns/HandleArguments.php +++ b/src/Plugins/Concerns/HandleArguments.php @@ -21,7 +21,7 @@ trait HandleArguments return true; } - if (str_starts_with((string) $arg, "$argument=")) { + if (str_starts_with((string) $arg, "$argument=")) { // @phpstan-ignore-line return true; } } diff --git a/src/Plugins/Help.php b/src/Plugins/Help.php index b7d48d62..b8422808 100644 --- a/src/Plugins/Help.php +++ b/src/Plugins/Help.php @@ -126,6 +126,18 @@ final class Help implements HandlesArguments ], [ 'arg' => '--notes', 'desc' => 'Output to standard output tests with notes', + ], [ + ], [ + 'arg' => '--issue', + 'desc' => 'Output to standard output tests with the given issue number', + ], [ + ], [ + 'arg' => '--pr', + 'desc' => 'Output to standard output tests with the given pull request number', + ], [ + ], [ + 'arg' => '--pull-request', + 'desc' => 'Output to standard output tests with the given pull request number (alias for --pr)', ], [ 'arg' => '--retry', 'desc' => 'Run non-passing tests first and stop execution upon first error or failure', diff --git a/src/Plugins/Parallel.php b/src/Plugins/Parallel.php index 81fa4d6c..a7090566 100644 --- a/src/Plugins/Parallel.php +++ b/src/Plugins/Parallel.php @@ -34,7 +34,7 @@ final class Parallel implements HandlesArguments /** * @var string[] */ - private const UNSUPPORTED_ARGUMENTS = ['--todo', '--todos', '--retry', '--notes']; + private const UNSUPPORTED_ARGUMENTS = ['--todo', '--todos', '--retry', '--notes', '--issue', '--pr', '--pull-request']; /** * Whether the given command line arguments indicate that the test suite should be run in parallel. diff --git a/src/Support/Coverage.php b/src/Support/Coverage.php index 869d7df2..7eaf786b 100644 --- a/src/Support/Coverage.php +++ b/src/Support/Coverage.php @@ -198,6 +198,8 @@ final class Coverage $array = []; foreach (array_filter($file->lineCoverageData(), is_array(...)) as $line => $tests) { + assert(is_array($tests)); + $array = $eachLine($array, $tests, $line); } diff --git a/src/TestCaseMethodFilters/IssueTestCaseFilter.php b/src/TestCaseMethodFilters/IssueTestCaseFilter.php new file mode 100644 index 00000000..5dfd336b --- /dev/null +++ b/src/TestCaseMethodFilters/IssueTestCaseFilter.php @@ -0,0 +1,27 @@ +number, $factory->issues, true); + } +} diff --git a/src/TestCaseMethodFilters/NotesTestCaseFilter.php b/src/TestCaseMethodFilters/NotesTestCaseFilter.php index cd33edec..592fc600 100644 --- a/src/TestCaseMethodFilters/NotesTestCaseFilter.php +++ b/src/TestCaseMethodFilters/NotesTestCaseFilter.php @@ -7,7 +7,7 @@ namespace Pest\TestCaseMethodFilters; use Pest\Contracts\TestCaseMethodFilter; use Pest\Factories\TestCaseMethodFactory; -final class NotesTestCaseFilter implements TestCaseMethodFilter +final readonly class NotesTestCaseFilter implements TestCaseMethodFilter { public function accept(TestCaseMethodFactory $factory): bool { diff --git a/src/TestCaseMethodFilters/PrTestCaseFilter.php b/src/TestCaseMethodFilters/PrTestCaseFilter.php new file mode 100644 index 00000000..7905b5ae --- /dev/null +++ b/src/TestCaseMethodFilters/PrTestCaseFilter.php @@ -0,0 +1,27 @@ +number, $factory->prs, true); + } +} diff --git a/src/TestCaseMethodFilters/TodoTestCaseFilter.php b/src/TestCaseMethodFilters/TodoTestCaseFilter.php index 401666dc..a9d66acd 100644 --- a/src/TestCaseMethodFilters/TodoTestCaseFilter.php +++ b/src/TestCaseMethodFilters/TodoTestCaseFilter.php @@ -7,8 +7,11 @@ namespace Pest\TestCaseMethodFilters; use Pest\Contracts\TestCaseMethodFilter; use Pest\Factories\TestCaseMethodFactory; -final class TodoTestCaseFilter implements TestCaseMethodFilter +final readonly class TodoTestCaseFilter implements TestCaseMethodFilter { + /** + * Filter the test case methods. + */ public function accept(TestCaseMethodFactory $factory): bool { return $factory->todo; diff --git a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap index 5d03115e..06844d25 100644 --- a/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap +++ b/tests/.pest/snapshots/Visual/Help/visual_snapshot_of_help_command_output.snap @@ -22,6 +22,9 @@ --bail ........................... Stop execution upon first not-passed test --todos ........................ Output to standard output the list of todos --notes ......................... Output to standard output tests with notes + --issue ........ Output to standard output tests with the given issue number + --pr .... Output to standard output tests with the given pull request number + --pull-request Output to standard output tests with the given pull request number (alias for --pr) --retry Run non-passing tests first and stop execution upon first error or failure --list-suites ................................... List available test suites --testsuite [name] ......... Only run tests from the specified test suite(s) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index eb212ade..4def52d9 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -991,6 +991,11 @@ ✓ it is not incompleted because of test with assertions … a "describe" group of tests → it is incompleted + PASS Tests\Features\Issue + ✓ it may be associated with an issue #1, #2 + ✓ nested → it may be associated with an issue #1, #4, #5, #6, #3 + // an note between an the issue + PASS Tests\Features\It ✓ it is a test ✓ it is a higher order message test @@ -1027,6 +1032,11 @@ ! notice → This is a notice description // tests/Features/Notices.php:4 ! a "describe" group of tests → notice → This is a notice description // tests/Features/Notices.php:11 + PASS Tests\Features\Pr + ✓ it may be associated with an pr #2 + ✓ nested → it may be associated with an pr #3 + // an note between an the pr + PASS Tests\Features\Repeat ✓ once ✓ multiple times @ repetition 1 of 5 @@ -1212,6 +1222,11 @@ ✓ it allows performing no expectations without being risky ✓ a "describe" group of tests → it allows performing no expectations without being risky + PASS Tests\Features\Ticket + ✓ it may be associated with an ticket #1, #2 + ✓ nested → it may be associated with an ticket #1, #4, #5, #6, #3 + // an note between an the ticket + PASS Tests\Features\Todo - 3 todos ↓ something todo later ↓ something todo later chained @@ -1501,4 +1516,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 1057 passed (2588 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 24 skipped, 1063 passed (2602 assertions) \ No newline at end of file diff --git a/tests/Features/After.php b/tests/Features/After.php index bab46c25..a64c5710 100644 --- a/tests/Features/After.php +++ b/tests/Features/After.php @@ -119,7 +119,7 @@ describe('something 2', function () { $this->count++; })->after(function () { - expect($this->count)->toBe(4); + expect($this->count)->toBe(6); $this->count++; }); diff --git a/tests/Features/Issue.php b/tests/Features/Issue.php new file mode 100644 index 00000000..958d5271 --- /dev/null +++ b/tests/Features/Issue.php @@ -0,0 +1,15 @@ +toBeTrue(); +})->issue(1); + +it('may be associated with an issue', function () { + expect(true)->toBeTrue(); +})->issue(2); + +describe('nested', function () { + it('may be associated with an issue', function () { + expect(true)->toBeTrue(); + })->issue('#3'); +})->issue(4)->note('an note between an the issue')->issue([5, 6]); diff --git a/tests/Features/Pr.php b/tests/Features/Pr.php new file mode 100644 index 00000000..42c7ee14 --- /dev/null +++ b/tests/Features/Pr.php @@ -0,0 +1,15 @@ +toBeTrue(); +})->pr(1); + +it('may be associated with an pr', function () { + expect(true)->toBeTrue(); +})->pr(2); + +describe('nested', function () { + it('may be associated with an pr', function () { + expect(true)->toBeTrue(); + })->pr('#3'); +})->pr(4)->note('an note between an the pr')->pr(['#5', 6]); diff --git a/tests/Features/Ticket.php b/tests/Features/Ticket.php new file mode 100644 index 00000000..3413e4b4 --- /dev/null +++ b/tests/Features/Ticket.php @@ -0,0 +1,15 @@ +toBeTrue(); +})->ticket(1); + +it('may be associated with an ticket', function () { + expect(true)->toBeTrue(); +})->ticket(2); + +describe('nested', function () { + it('may be associated with an ticket', function () { + expect(true)->toBeTrue(); + })->ticket(3); +})->ticket(4)->note('an note between an the ticket')->ticket([5, 6]); diff --git a/tests/Pest.php b/tests/Pest.php index f7cf1c9b..9df1981f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -7,6 +7,8 @@ error_reporting(E_ALL); $GLOBALS['__PEST_INTERNAL_TEST_SUITE'] = true; +pest()->context()->github('pestphp/pest'); + pest()->in('PHPUnit/CustomTestCaseInSubFolders/SubFolder/SubFolder')->use(CustomTestCaseInSubFolder::class); // test case for all the directories inside PHPUnit/GlobPatternTests/SubFolder/ diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 51ad3d6d..52eebf40 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1043 passed (2556 assertions)') + ->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 1049 passed (2570 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();