Skip to content

Commit

Permalink
Develop (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katalam authored Jan 19, 2023
2 parents b8dd5f1 + 52503bb commit b97f9ca
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 45 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added config/.gitkeep
Empty file.
6 changes: 0 additions & 6 deletions config/created-by.php

This file was deleted.

Empty file added src/Commands/.gitkeep
Empty file.
19 changes: 0 additions & 19 deletions src/Commands/CreatedByCommand.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/CreatedByServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ public function configurePackage(Package $package): void
* More info: https://github.com/spatie/laravel-package-tools
*/
$package
->name('laravel-created-by')
->hasConfigFile();
->name('laravel-created-by');
}

public function packageRegistered(): void
Expand Down
42 changes: 42 additions & 0 deletions tests/BlueprintMacroTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Hyperlink\CreatedBy\CreatedByServiceProvider;
use Illuminate\Database\Schema\Blueprint;

foreach ([
'createdBy' => '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,
]);
});
5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

0 comments on commit b97f9ca

Please sign in to comment.