-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorder folder structure Improve publish and register migration file Signed-off-by: asciito <ayax.cordova@aydev.mx>
- Loading branch information
Showing
10 changed files
with
239 additions
and
85 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
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
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
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
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,76 @@ | ||
<?php | ||
|
||
use Asciito\LaravelPackage\Package\Package; | ||
use function Pest\Laravel\artisan; | ||
use function Pest\Laravel\assertDatabaseCount; | ||
|
||
trait PackageRegisterMigrationTest | ||
{ | ||
protected function configurePackage(Package $package): void | ||
{ | ||
$package | ||
->setName('package') | ||
->withMigration($package->getMigrationPath('extra/create_package_test_three_table.php')) | ||
->withMigration([$package->getMigrationPath('extra/create_package_test_four_table.php')]); | ||
} | ||
} | ||
|
||
uses(PackageRegisterMigrationTest::class); | ||
|
||
test('package has registered files from folder', function () { | ||
expect($this->package) | ||
->getPublishableMigration() | ||
->toHaveCount(4) | ||
->getRegisteredMigration() | ||
->toHaveCount(4); | ||
}); | ||
|
||
test('package register migration files without publishing it', function () { | ||
expect(database_path('migrations/create_package_test_one_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_two_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_three_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_four_table.php')) | ||
->not->toBeFile(); | ||
|
||
artisan('migrate') | ||
->assertSuccessful(); | ||
|
||
assertDatabaseCount('package_test_one', 0); | ||
assertDatabaseCount('package_test_two', 0); | ||
assertDatabaseCount('package_test_three', 0); | ||
assertDatabaseCount('package_test_four', 0); | ||
}); | ||
|
||
it('publish package migration files', function () { | ||
expect(database_path('migrations/create_package_test_one_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_two_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_three_table.php')) | ||
->not->toBeFile() | ||
->and(database_path('migrations/create_package_test_four_table.php')) | ||
->not->toBeFile(); | ||
|
||
artisan('vendor:publish', ['--tag' => 'package-migrations']); | ||
|
||
expect(database_path('migrations/create_package_test_one_table.php')) | ||
->toBeFile() | ||
->and(database_path('migrations/create_package_test_two_table.php')) | ||
->toBeFile() | ||
->and(database_path('migrations/create_package_test_three_table.php')) | ||
->toBeFile() | ||
->and(database_path('migrations/create_package_test_four_table.php')) | ||
->toBeFile(); | ||
|
||
artisan('migrate'); | ||
|
||
assertDatabaseCount('package_test_one', 0); | ||
assertDatabaseCount('package_test_two', 0); | ||
assertDatabaseCount('package_test_three', 0); | ||
assertDatabaseCount('package_test_four', 0); | ||
}); | ||
|
||
|
Oops, something went wrong.