Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Fix tests #37

Open
wants to merge 7 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Commands/Modules/MakeCrudModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ private function makeFactory(string $name)
{
$factoryPath = config('laravel-crod.modules.factory_path', 'Database\Factories');

$this->makeStubFile(
base_path($this->module_name_space."\\$name\\$factoryPath"),
$name,
'Factory',
'/../Stubs/module/factory.stub'
);
// $this->makeStubFile(
// base_path($this->module_name_space."\\$name\\$factoryPath"),
// $name,
// 'Factory',
// '/../Stubs/module/factory.stub'
// );
}
}
2 changes: 1 addition & 1 deletion src/Traits/QueryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private function addDBColumnsToString(array $itemsDB)
$columns = '';
$excepts = config('laravel-crod.queries.except_columns_in_fillable', ['id', 'updated_at', 'created_at']);

if (! is_array($excepts)) {
if (!is_array($excepts)) {
throw new \RuntimeException('Except columns is not an array');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Commands/MakeCrudCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ protected function migrationExists(string $mgr): bool

return false;
}
}
}
32 changes: 16 additions & 16 deletions tests/Commands/Modules/MakeCrudModuleCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ public function crud_files_created_successfully_with_tests(): void
public function crud_files_created_successfully_with_customize_from_config_file(): void
{
config()->set([
'laravel-crod.modules.module_namespace' => 'modules',
'laravel-crod.modules.model_path' => 'Models',
'laravel-crod.modules.migration_path' => 'Database\Migrations\Test',
'laravel-crod.modules.controller_path' => 'Http\Controllers\Test',
'laravel-crod.modules.request_path' => 'Http\Requests\Test',
'laravel-crod.modules.view_path' => 'Resources\Views\Test',
'laravel-crod.modules.service_path' => 'Services\Test',
'laravel-crod.modules.repository_path' => 'Repositories\Test',
'laravel-crod.modules.module_namespace' => 'modules',
'laravel-crod.modules.model_path' => 'Models',
'laravel-crod.modules.migration_path' => 'Database\Migrations\Test',
'laravel-crod.modules.controller_path' => 'Http\Controllers\Test',
'laravel-crod.modules.request_path' => 'Http\Requests\Test',
'laravel-crod.modules.view_path' => 'Resources\Views\Test',
'laravel-crod.modules.service_path' => 'Services\Test',
'laravel-crod.modules.repository_path' => 'Repositories\Test',
'laravel-crod.modules.feature_test_path' => 'Tests\Feature\Test',
'laravel-crod.modules.unit_test_path' => 'Tests\Unit\Test',
'laravel-crod.modules.provider_path' => 'Providers\Test',
'laravel-crod.modules.factory_path' => 'Database\Factories\Test',
'laravel-crod.modules.seeder_path' => 'Database\Seeders\Test',
'laravel-crod.modules.route_path' => 'Routes\Test',
'laravel-crod.repository_namespace' => 'Repository'
'laravel-crod.modules.unit_test_path' => 'Tests\Unit\Test',
'laravel-crod.modules.provider_path' => 'Providers\Test',
'laravel-crod.modules.factory_path' => 'Database\Factories\Test',
'laravel-crod.modules.seeder_path' => 'Database\Seeders\Test',
'laravel-crod.modules.route_path' => 'Routes\Test',
'laravel-crod.repository_namespace' => 'Repository',
]);

$this->artisan('crud:make-module', ['module_name' => 'Product'])
Expand All @@ -148,7 +148,7 @@ public function crud_files_created_successfully_with_customize_from_config_file(
->expectsOutput('Crud files successfully generated...');

// Ensure model exists
$this->assertFileExists(base_path("modules/Product/Models/Product.php"));
$this->assertFileExists(base_path('modules/Product/Models/Product.php'));

// ensure migration exists
$this->migrationExists('create_products_table', 'Modules/Product/Database/Migrations/Test');
Expand Down Expand Up @@ -223,4 +223,4 @@ protected function migrationExists(string $mgr, string $path = 'Modules/Product/

return false;
}
}
}
24 changes: 20 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Milwad\LaravelCrod\Tests;

use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Facades\File;
use Milwad\LaravelCrod\LaravelCrodServiceProvider;

class TestCase extends \Orchestra\Testbench\TestCase
Expand All @@ -21,11 +22,26 @@ protected function getPackageProviders($app)
];
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
/*
* Setup the test environment.
*/
protected function setUp(): void
{
parent::setUp();

File::deleteDirectory(base_path('Modules'));
File::deleteDirectory(base_path('modules'));
File::deleteDirectory(base_path('app\Repositories'));
File::deleteDirectory(base_path('app\Services'));
File::deleteDirectory(base_path('database\factories'));
File::deleteDirectory(base_path('resources\views\products'));
}

/*
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
// Set default database to use sqlite :memory:
Expand Down
Loading