Skip to content

Commit

Permalink
Change test files directory
Browse files Browse the repository at this point in the history
  • Loading branch information
smortexa committed Aug 10, 2022
1 parent f2b88cc commit 162f135
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions src/Console/MakeArkitectRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Mortexa\LaravelArkitect\Console;

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;

class MakeArkitectRule extends GeneratorCommand
{
Expand All @@ -12,18 +13,25 @@ class MakeArkitectRule extends GeneratorCommand

protected $type = 'Arkitect';

protected function getStub()
protected function getStub(): string
{
return __DIR__.'/stubs/arkitect.php.stub';
}

protected function getDefaultNamespace($rootNamespace)
protected function getPath($name): string
{
return $rootNamespace.'\Arkitect';
$name = Str::replaceFirst($this->rootNamespace(), '', $name);

return base_path('tests').str_replace('\\', '/', $name).'.php';
}

protected function getDefaultNamespace($rootNamespace): string
{
return $rootNamespace.'\Architecture';
}

public function handle()
protected function rootNamespace(): string
{
parent::handle();
return 'Tests';
}
}
2 changes: 1 addition & 1 deletion src/Console/TestArchitecture.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestArchitecture extends Command
protected $signature = 'test:arkitect {--stop-on-failure : The process will end immediately after the first violation.}
{--debug : The verbose mode to see every parsed file.}';

protected $description = 'Test the app architecture';
protected $description = 'Run the architectural tests';

public function handle(): int
{
Expand Down
6 changes: 3 additions & 3 deletions src/phparkitect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
return static function (Config $config): void {
$app = CreateApplication::app();

$package_config = $app['config']['arkitect'];
$package_config = $app->make('config')['arkitect'];

$rules = [];

$rules = array_merge($rules, Arr::flatten($package_config['rules']));

foreach (glob($app->path('Arkitect/*.php')) as $file) {
foreach (glob($app->basePath('tests/Architecture/*.php')) as $file) {
$class = basename($file, '.php');
$rules[] = 'App\\Arkitect\\'.$class;
$rules[] = 'Tests\\Architecture\\'.$class;
}

foreach ($rules as $rule) {
Expand Down

0 comments on commit 162f135

Please sign in to comment.