thytanium / tester
Testing Laravel packages it was never so easy.
Requires
- php: >=7.0
- laravel/laravel: ^5.0.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is not auto-updated.
Last update: 2020-05-04 15:42:52 UTC
README
Laravel Package Tester
Testing Laravel packages it was never so easy.
Motivation
Testing is essential when developing Laravel third-party packages. An issue arises when you need real services from Laravel (like database or queues, for example) because your package may provide migrations or interact with a queue, and more importantly you want your package to behave like a library and not like a Laravel project, mainly because you want to use it in many Laravel projects.
This package addresses this issue by requiring larave/laravel
package and providing a TestCase
to help you build your PHPUnit tests.
Install
composer require --dev thytanium/tester
This package doesn't offer any service providers, there's no need for auto-discovery or to manually add a service provider in your
config/app.php
Usage
In your tests, extend the class Thytanium\Tests\TestCase
and you're good to go.
<?php namespace Tests; use Thytanium\Tests\TestCase; class ExampleTest extends TestCase { }
Migrations
To run your package's migrations use Thytanium\Tests\DatabaseMigrations
trait.
<?php namespace Tests; use Thytanium\Tests\DatabaseMigrations; use Thytanium\Tests\TestCase; class ExampleTest extends TestCase { use DatabaseMigrations; }
By default, migrations will be looked up in database/migrations
from your package root directory.
You can change the default migrations path with the MIGRATIONS_PATH
envvar.
Testing
It's weird to test a package aimed to testing. And actually there isn't much to test that isn't already tested in Laravel.
Contributing
Please feel free to notify issues and send PR to improve this package.