Skip to content

Commit a955812

Browse files
committed
test for make migration command
1 parent bd5c75c commit a955812

File tree

7 files changed

+37
-4
lines changed

7 files changed

+37
-4
lines changed

app/Commands/Foundation/Migrations/MigrationCreator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public function __construct(Filesystem $files, $customStubPath = __DIR__ . '/stu
2424
*/
2525
protected function getPath($name, $path)
2626
{
27-
$path = getcwd() . $this->devPath() . '/database/migrations';
27+
$devPath = '';
28+
if (app()->environment() === 'development') {
29+
$devPath = $this->devPath() . '/src';
30+
}
31+
$path = getcwd() . $devPath . '/database/migrations';
2832
if (!$this->files->isDirectory($path)) {
2933
$this->files->makeDirectory($path, 0777, true);
3034
}

app/Commands/Helpers/PackageDetail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function rootNamespace()
4343

4444
public function devPath()
4545
{
46-
return (app()->environment() === 'development') ? '/package/' . $this->getPackageName() . '/src' : '';
46+
return (app()->environment() === 'development') ? '/package/' . $this->getPackageName() . '/' : '';
4747
}
4848

4949
public function getPath($name)

builds/packr

42 Bytes
Binary file not shown.

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
|
2626
*/
2727

28-
'version' => 'v4.7.0',
28+
'version' => 'v4.7.1',
2929

3030
/*
3131
|--------------------------------------------------------------------------

tests/Feature/CrudMakeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function test_it_can_create_a_crud_for_a_json_file()
2222
Artisan::call('crud:make Test');
2323
$this->isFileExists('src/Test.php');
2424
$this->isFileExists('src/database/factories/TestFactory.php');
25+
$this->assertEquals(1, count(glob($this->_testPath() . 'src/database/migrations/*_create_tests_table.php')));
2526
$this->isFileExists('src/Http/controllers/TestController.php');
2627
$this->isFileExists('tests/Feature/TestTest.php');
2728
$this->isFileExists('tests/Unit/TestTest.php');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use Tests\TestCase;
6+
use Tests\RefreshPacker;
7+
use Illuminate\Support\Facades\Artisan;
8+
9+
class MakeMigrationTest extends TestCase
10+
{
11+
use RefreshPacker;
12+
13+
/**
14+
* A basic test example.
15+
*
16+
* @return void
17+
*/
18+
public function test_it_can_test_migration_command()
19+
{
20+
Artisan::call('make:migration CreateTestsTable');
21+
$this->assertEquals(1, count(glob($this->_testPath() . 'src/database/migrations/*_create_tests_table.php')));
22+
}
23+
}

tests/RefreshPacker.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public function tearDown():void
2222

2323
public function isFileExists($filename)
2424
{
25-
return $this->assertFileExists(base_path() . '/package/TestApp/' . $filename);
25+
return $this->assertFileExists($this->_testPath() . $filename);
26+
}
27+
28+
public function _testPath()
29+
{
30+
return base_path() . '/package/TestApp/';
2631
}
2732
}

0 commit comments

Comments
 (0)