Download the PHP package jeroen-g/testassist without Composer
On this page you can find all versions of the php package jeroen-g/testassist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeroen-g/testassist
More information about jeroen-g/testassist
Files in jeroen-g/testassist
Package testassist
Short Description Helpers for testing with PHPUnit
License EUPL-1.1
Homepage https://github.com/Jeroen-G/testAssist
Informations about the package testassist
TestAssist
This package contains some nifty helpers and assertions that are made with Laravel in mind. The majority of functions are found in other packages, tutorials or repositories and credit is given for each function.
Installation
Via Composer
Usage
All helpers are designed as traits and organised in components focused on browser, console and filesystem tests. If you want to have all helpers, simply use the general Assistants that will include all others for you.
General functions
AssertIsCalled
use JeroenG\TestAssist\Assistants
This function accepts two parameters, the first is the classname that needs to get called, the second is a callback during which the class should be called. And example would be an event listener:
Browser (Laravel Dusk)
ClearCookiesBetweenTests
use JeroenG\TestAssist\Browser\ClearCookiesBetweenTests
Using this trait will make sure that between each test the user is logged out and all (session) cookies are deleted.
The best way to use this is to alter your TestCase's tearDown()
:
Console
OutputAssertions
use JeroenG\TestAssist\Console\OutputAssertions
Contains two functions: seeInConsoleOutput($text)
and 'doNotSeeInConsoleOutput($text)` to check whether or not the (un)expected text appears in the console output.
ExceptionHandling
use JeroenG\TestAssist\Console\ExceptionHandling
Use disableExceptionHandling()
to get the entire stacktrace instead of a error 500
-like message. Use withExceptionHandling()
to reactivate Laravel's error rendering.
Database
FabricateModels
use JeroenG\TestAssist\Database\FabricateModels
Containts two functions as shortcuts to Laravel's factory method to create/make model instances. The shortest use would be as follows:
DataAssertions
use JeroenG\TestAssist\Database\DataAssertions
Containts two methods to assert if an Eloquent model is inserted into the database (technically an alias for assertDatabaseHas()
) or to assert that its row is updated or deleted.
SQLiteRegex
use JeroenG\TestAssist\Database\SQLiteRegex
Add the function below to your SetUpBeforeClass
to give SQLite the ability to use REGEXP
statements.
More information here and credits should go here.
SeedDatabase
use JeroenG\TestAssist\Database\SeedDatabase
Runs your DatabaseSeeder
class if you use the trait. In your testcase's setUp
method you should run this:
If you do not use the whole set of assistants (see top of usage section), place the following code in your setUp()
method to run it only once:
Filesystem
ManageFilesystem
use JeroenG\TestAssist\Filesystem\ManageFilesystem
As the moment this trait has only the function removeDir($path)
to nuke the directory and everything inside of it.
FileAssertions
use JeroenG\TestAssist\Filesystem\FileAssertions
There are several assertions present to work with the (non)existence of files and directories.
The underlying functions such as pathExists()
are of course also available for use.
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Credits
- JeroenG
- All Contributors
License
EUPL-1.1. Please see the license file for more information.