Skip to content

Commit

Permalink
Setting up test db inclusion and cleaning up package.
Browse files Browse the repository at this point in the history
  • Loading branch information
t73biz committed Mar 22, 2024
1 parent 11dc38f commit a8c9176
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 64 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/t73biz/lw-bits/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/t73biz/lw-bits/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/t73biz/lw-bits.svg?style=flat-square)](https://packagist.org/packages/t73biz/lw-bits)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/lw-bits.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/lw-bits)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
Live Wire Bits and Bobs is a package to help you with your Livewire projects. It is a collection of components and utilities that I have found useful in my projects. It is a work in progress and I will be adding to it as I go along.

## Installation

Expand All @@ -23,13 +15,6 @@ You can install the package via composer:
composer require t73biz/lw-bits
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="lw-bits-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@composer run build",
"@php vendor/bin/testbench serve"
],
"analyse": "vendor/bin/phpstan analyse",
"analyze": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
Expand Down
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

41 changes: 41 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace T73biz\LwBits\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
19 changes: 0 additions & 19 deletions database/migrations/create_lw_bits_table.php.stub

This file was deleted.

21 changes: 21 additions & 0 deletions database/migrations/create_users_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
};
2 changes: 1 addition & 1 deletion src/Facades/LwBits.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class LwBits extends Facade
{
protected static function getFacadeAccessor()
protected static function getFacadeAccessor(): string
{
return \T73biz\LwBits\LwBits::class;
}
Expand Down
1 change: 0 additions & 1 deletion src/LwBitsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function configurePackage(Package $package): void
->name('lw-bits')
->hasConfigFile()
->hasViews()
->hasMigration('create_lw-bits_table')
->hasCommand(LwBitsCommand::class);
}
}
46 changes: 46 additions & 0 deletions src/Models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace T73biz\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'is_active',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}
4 changes: 3 additions & 1 deletion tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

it('can test', function () {
expect(true)->toBeTrue();
\Pest\Laravel\artisan('lw-bits')
->expectsOutput('All done')
->assertExitCode(0);
});
9 changes: 3 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ protected function setUp(): void
);
}

protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
LwBitsServiceProvider::class,
];
}

public function getEnvironmentSetUp($app)
public function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'testing');

/*
$migration = include __DIR__.'/../database/migrations/create_lw-bits_table.php.stub';
$migration = include __DIR__.'/../database/migrations/create_users_table.php';
$migration->up();
*/
}
}

0 comments on commit a8c9176

Please sign in to comment.