-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[migrator] Package will not redefine
make:migrations
anymore, `lara…
…-asp-migrator:raw-migration` should be used instead (#3).
- Loading branch information
1 parent
a171723
commit 3ebb2d4
Showing
4 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Migrator\Commands; | ||
|
||
use Illuminate\Database\Console\Migrations\MigrateMakeCommand; | ||
use Illuminate\Support\Composer; | ||
use LastDragon_ru\LaraASP\Migrator\Extenders\RawMigrationCreator; | ||
use LastDragon_ru\LaraASP\Migrator\Package; | ||
|
||
use function str_replace; | ||
|
||
class RawMigration extends MigrateMakeCommand { | ||
public const Name = Package::Name.':raw-migration'; | ||
|
||
public function __construct(RawMigrationCreator $creator, Composer $composer) { | ||
$this->signature = str_replace('make:migration', static::Name, $this->signature); | ||
|
||
parent::__construct($creator, $composer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Migrator\Commands; | ||
|
||
use LastDragon_ru\LaraASP\Migrator\Package; | ||
use LastDragon_ru\LaraASP\Migrator\Testing\Package\TestCase; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
use function array_keys; | ||
use function iterator_to_array; | ||
use function mkdir; | ||
use function sys_get_temp_dir; | ||
use function tempnam; | ||
use function unlink; | ||
|
||
/** | ||
* @internal | ||
* @coversDefaultClass \LastDragon_ru\LaraASP\Migrator\Commands\RawMigration | ||
*/ | ||
class RawMigrationTest extends TestCase { | ||
/** | ||
* @covers ::handle | ||
*/ | ||
public function testHandle(): void { | ||
$pkg = Package::Name; | ||
$path = tempnam(sys_get_temp_dir(), $pkg); | ||
|
||
unlink($path); | ||
mkdir($path); | ||
|
||
$finder = Finder::create()->in($path); | ||
|
||
$this->assertCount(0, $finder->files()); | ||
|
||
$this->artisan("{$pkg}:raw-migration", [ | ||
'name' => 'RawMigration', | ||
'--path' => $path, | ||
'--realpath' => true, | ||
]); | ||
|
||
$this->assertCount(3, $finder->files()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Migrator; | ||
|
||
final class Package { | ||
public const Name = 'lara-asp-migrator'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters