Skip to content

Commit

Permalink
WIP [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
h4kuna committed Nov 27, 2023
1 parent f5ddd0a commit c1db9d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
11 changes: 6 additions & 5 deletions src/Testing/Commands/MakeExpectationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use LaraStrict\Testing\Constants\StubConstants;
use LaraStrict\Testing\Contracts\GetBasePathForStubsActionContract;
use LaraStrict\Testing\Contracts\GetNamespaceForStubsActionContract;
use LaraStrict\Testing\Contracts\SetUpFinderActionContract;
use LaraStrict\Testing\Contracts\FinderFactoryContract;
use LaraStrict\Testing\Entities\AssertFileStateEntity;
use LaraStrict\Testing\Entities\PhpDocEntity;
use LaraStrict\Testing\Enums\PhpType;
Expand Down Expand Up @@ -55,7 +55,7 @@ public function handle(
GetBasePathForStubsActionContract $getBasePathAction,
GetNamespaceForStubsActionContract $getFolderAndNamespaceForStubsAction,
ParsePhpDocAction $parsePhpDocAction,
SetUpFinderActionContract $setUpFinderAction,
FinderFactoryContract $setUpFinderAction,
CacheMeServiceContract $cacheMeService,
): int {
if (class_exists(ClassType::class) === false) {
Expand All @@ -74,9 +74,10 @@ public function handle(
$class = (string) $this->input->getArgument('class');

if ($class === 'all') {
$finder = Finder::create()->files()->name('*.php');
$setUpFinderAction->execute($finder);
$inputClasses = $this->findAllClasses($finder, $cacheMeService);
$inputClasses = $this->findAllClasses(
$setUpFinderAction->create(),
$cacheMeService,
);
} else {
$inClass = $this->normalizeToClass($class, $basePath, $filesystem);
$inputClasses = $inClass === null ? [] : [$inClass];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Symfony\Component\Finder\Finder;

interface SetUpFinderActionContract
interface FinderFactoryContract
{
public function execute(Finder $finder): Finder;
public function create(): Finder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

declare(strict_types=1);

namespace LaraStrict\Testing\Actions;
namespace LaraStrict\Testing\Factories;

use LaraStrict\Testing\Contracts\FinderFactoryContract;
use LaraStrict\Testing\Contracts\GetBasePathForStubsActionContract;
use LaraStrict\Testing\Contracts\SetUpFinderActionContract;
use Symfony\Component\Finder\Finder;

final class SetUpFinderAction implements SetUpFinderActionContract
final class FinderFactory implements FinderFactoryContract
{
public function __construct(
private readonly GetBasePathForStubsActionContract $getBasePathForStubsAction
) {
}

public function execute(Finder $finder): Finder
public function create(): Finder
{
return $finder
return Finder::create()->files()
->name('*.php')
->in($this->getBasePathForStubsAction->execute())
->notPath(['node_modules', 'vendor', 'storage'])
->notName('*.blade.php');
Expand Down
6 changes: 3 additions & 3 deletions src/Testing/TestServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
use LaraStrict\Enums\EnvironmentType;
use LaraStrict\Testing\Actions\GetBasePathForStubsAction;
use LaraStrict\Testing\Actions\GetNamespaceForStubsAction;
use LaraStrict\Testing\Actions\SetUpFinderAction;
use LaraStrict\Testing\Commands\MakeExpectationCommand;
use LaraStrict\Testing\Contracts\GetBasePathForStubsActionContract;
use LaraStrict\Testing\Contracts\GetNamespaceForStubsActionContract;
use LaraStrict\Testing\Contracts\SetUpFinderActionContract;
use LaraStrict\Testing\Contracts\FinderFactoryContract;
use LaraStrict\Testing\Core\Services\NoSleepService;
use LaraStrict\Testing\Factories\FinderFactory;

class TestServiceProvider extends ServiceProvider
{
public array $bindings = [
GetBasePathForStubsActionContract::class => GetBasePathForStubsAction::class,
GetNamespaceForStubsActionContract::class => GetNamespaceForStubsAction::class,
SetUpFinderActionContract::class => SetUpFinderAction::class,
FinderFactoryContract::class => FinderFactory::class,
];

public function register(): void
Expand Down

0 comments on commit c1db9d6

Please sign in to comment.