Skip to content

Commit

Permalink
Adds --arch and --exclude-arch CLI args.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeraymonddowning committed Dec 4, 2023
1 parent 7cc2579 commit 28519b7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ parameters:
ignoreErrors:
- "#has a nullable return type declaration.#"
- "# with a nullable type declaration.#"
- "#has parameter \\$closure with null as default value.#"
11 changes: 6 additions & 5 deletions src/Autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
declare(strict_types=1);

use Pest\Arch\Concerns\Architectable;
use Pest\Concerns\Expectable;
use Pest\PendingCalls\TestCall;
use Pest\Plugin;
use PHPUnit\Framework\TestCase;
use Pest\Support\HigherOrderTapProxy;

Plugin::uses(Architectable::class);

Expand All @@ -15,11 +14,13 @@
* Adds the given closure as an architecture test. The first
* argument is the test description; the second argument
* is a closure that contains the test expectations.
*
* @return Expectable|TestCall|TestCase|mixed
*/
function arch(string $description, Closure $closure = null): TestCall
{
return test($description, $closure)->group('arch');
$test = test($description, $closure);

assert(! $test instanceof HigherOrderTapProxy);

return $test->group('arch');
}
}
20 changes: 9 additions & 11 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<?php

declare(strict_types=1);

namespace Pest\Arch;

use Pest\Arch\Support\CommandArgumentMode;
use Pest\Contracts\Plugins\Bootable;
use Pest\Contracts\Plugins\HandlesArguments;
use Pest\Plugins\Concerns\HandleArguments;

/**
* @internal
*/
final class Plugin implements HandlesArguments, Bootable
final class Plugin implements HandlesArguments
{
use HandleArguments;

private CommandArgumentMode $mode;

public function handleArguments(array $arguments): array
{
if (! $this->hasArgument('--arch', $arguments)) {
return $arguments;
if ($this->hasArgument('--arch', $arguments)) {
return $this->pushArgument('--group=arch', $this->popArgument('--arch', $arguments));
}

return $this->popArgument('--arch', $arguments);
}
if ($this->hasArgument('--exclude-arch', $arguments)) {
return $this->pushArgument('--exclude-group=arch', $this->popArgument('--exclude-arch', $arguments));
}

public function boot(): void
{
return $arguments;
}
}
10 changes: 0 additions & 10 deletions src/Support/CommandArgumentMode.php

This file was deleted.

0 comments on commit 28519b7

Please sign in to comment.