From a73a0eebc88d57ea5f1ff270adb18938641afbc4 Mon Sep 17 00:00:00 2001 From: Katalam Date: Thu, 19 Jan 2023 13:40:25 +0100 Subject: [PATCH 1/4] Adding a pest test for adding macros to blueprint --- tests/BlueprintMacroTest.php | 42 ++++++++++++++++++++++++++++++++++++ tests/ExampleTest.php | 5 ----- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tests/BlueprintMacroTest.php delete mode 100644 tests/ExampleTest.php diff --git a/tests/BlueprintMacroTest.php b/tests/BlueprintMacroTest.php new file mode 100644 index 0000000..a9d0160 --- /dev/null +++ b/tests/BlueprintMacroTest.php @@ -0,0 +1,42 @@ + 'created_by', + 'updatedBy' => 'updated_by', + 'deletedBy' => 'deleted_by', + 'restoredBy' => 'restored_by', + ] as $functionName => $columnName) { + it('can extend the blueprint for migrations - ' . $functionName, function () use ($functionName, $columnName) { + app()->register(CreatedByServiceProvider::class); + + $blueprint = new Blueprint('test'); + $blueprint->$functionName(); + expect($blueprint->getAddedColumns())->toHaveCount(1); + expect($blueprint->getAddedColumns()[0]->toArray())->toEqual([ + 'type' => 'bigInteger', + 'name' => $columnName, + 'autoIncrement' => false, + 'unsigned' => true, + 'nullable' => true, + 'default' => null, + ]); + }); +} + +it('can extend the blueprint for migrations - restoredAt', function () { + app()->register(CreatedByServiceProvider::class); + + $blueprint = new Blueprint('test'); + $blueprint->restoredAt(); + expect($blueprint->getAddedColumns())->toHaveCount(1); + expect($blueprint->getAddedColumns()[0]->toArray())->toEqual([ + 'type' => 'timestamp', + 'name' => 'restored_at', + 'precision' => 0, + 'nullable' => true, + 'default' => null, + ]); +}); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php deleted file mode 100644 index 5d36321..0000000 --- a/tests/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); From af75e35fb3634556803a9df2e1f6fa048adba193 Mon Sep 17 00:00:00 2001 From: Katalam Date: Thu, 19 Jan 2023 13:42:53 +0100 Subject: [PATCH 2/4] Removes the template command from the package --- src/Commands/.gitkeep | 0 src/Commands/CreatedByCommand.php | 19 ------------------- 2 files changed, 19 deletions(-) create mode 100644 src/Commands/.gitkeep delete mode 100644 src/Commands/CreatedByCommand.php diff --git a/src/Commands/.gitkeep b/src/Commands/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Commands/CreatedByCommand.php b/src/Commands/CreatedByCommand.php deleted file mode 100644 index 77a6b7d..0000000 --- a/src/Commands/CreatedByCommand.php +++ /dev/null @@ -1,19 +0,0 @@ -comment('All done'); - - return self::SUCCESS; - } -} From b6f412e9758f83c453e3866b409666705cd48e5d Mon Sep 17 00:00:00 2001 From: Katalam Date: Thu, 19 Jan 2023 13:43:06 +0100 Subject: [PATCH 3/4] Removes the template config file from the package --- README.md | 13 ------------- config/.gitkeep | 0 config/created-by.php | 6 ------ src/CreatedByServiceProvider.php | 3 +-- 4 files changed, 1 insertion(+), 21 deletions(-) create mode 100644 config/.gitkeep delete mode 100644 config/created-by.php diff --git a/README.md b/README.md index 579d686..79da267 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,6 @@ You can install the package via composer: composer require hyperlink/laravel-created-by ``` -You can publish the config file with: - -```bash -php artisan vendor:publish --tag="laravel-created-by-config" -``` - -This is the contents of the published config file: - -```php -return [ -]; -``` - ## Usage ```php diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/created-by.php b/config/created-by.php deleted file mode 100644 index 76e4963..0000000 --- a/config/created-by.php +++ /dev/null @@ -1,6 +0,0 @@ -name('laravel-created-by') - ->hasConfigFile(); + ->name('laravel-created-by'); } public function packageRegistered(): void From 52503bb694c46879457e95c301f7e99643b10bc4 Mon Sep 17 00:00:00 2001 From: Katalam Date: Thu, 19 Jan 2023 12:43:41 +0000 Subject: [PATCH 4/4] Fix styling --- tests/BlueprintMacroTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/BlueprintMacroTest.php b/tests/BlueprintMacroTest.php index a9d0160..2b95ded 100644 --- a/tests/BlueprintMacroTest.php +++ b/tests/BlueprintMacroTest.php @@ -8,8 +8,8 @@ 'updatedBy' => 'updated_by', 'deletedBy' => 'deleted_by', 'restoredBy' => 'restored_by', - ] as $functionName => $columnName) { - it('can extend the blueprint for migrations - ' . $functionName, function () use ($functionName, $columnName) { +] as $functionName => $columnName) { + it('can extend the blueprint for migrations - '.$functionName, function () use ($functionName, $columnName) { app()->register(CreatedByServiceProvider::class); $blueprint = new Blueprint('test');