PHP code example of srlabs / laravel-testing-utilities
1. Go to this page and download the library: Download srlabs/laravel-testing-utilities library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
srlabs / laravel-testing-utilities example snippets
use SRLabs\Utilities\Traits\TestingDatabaseTrait;
class FooTest extends TestCase {
use TestingDatabaseTrait;
public function setUp()
{
parent::setUp();
$this->prepareDatabase('staging', 'testing');
}
public function testSomethingIsTrue()
{
$this->assertTrue(true);
}
}
define('ARTISAN_PATH', realpath(__DIR__ . '/../artisan'));
/*
|--------------------------------------------------------------------------
| Check for new migrations and reseed if necessary
|--------------------------------------------------------------------------
|
*/
passthru('(php '.ARTISAN_PATH.' migrate:status --database='.(getenv('DB_CONNECTION') ?: 'testing').' | grep -q "| N |") && php '.ARTISAN_PATH.' utility:testdb');
/*
|--------------------------------------------------------------------------
| Include Standard Autoload File
|--------------------------------------------------------------------------
|
*/
xml
<phpunit ...
bootstrap="bootstrap/testing.php"
...
>
...
<php>
...
<!-- Change this to your connection name (if customized) -->
<env name="DB_CONNECTION" value="testing"/>
</php>
</phpunit>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.