PHP code example of illuminated / testing-tools

1. Go to this page and download the library: Download illuminated/testing-tools 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/ */

    

illuminated / testing-tools example snippets


    use Illuminated\Testing\TestingTools;

    abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
    {
        use TestingTools;

        // ...
    }
    

    class ExampleTest extends TestCase
    {
        /** @test */
        public function it_has_lots_of_useful_assertions()
        {
            $this->assertDatabaseHasMany('posts', [
                ['title' => 'Awesome!'],
                ['title' => 'Check multiple rows'],
                ['title' => 'In one simple assertion 🤟'],
            ]);
        }
    }
    

$this->emulateLocal();

$this->emulateProduction();

$this->emulateEnvironment('demo');

$this->assertCollectionsEqual($collection1, $collection2, 'id');

$this->assertCollectionsNotEqual($collection1, $collection2, 'id');

$this->assertDatabaseHasTable('users');

$this->assertDatabaseMissingTable('unicorns');

$this->assertDatabaseHasMany('posts', [
    ['title' => 'First Post'],
    ['title' => 'Second Post'],
    ['title' => 'Third Post'],
]);

$this->assertDatabaseMissingMany('posts', [
    ['title' => 'Fourth Post'],
    ['title' => 'Fifth Post'],
]);

$this->assertDirectoryEmpty('./my/dir/');

$this->assertDirectoryNotEmpty('./my/dir/');

$this->assertFilesCount('./my/dir/', 3);

$this->assertNotFilesCount('./my/dir/', 5);

$this->seeLogFile('example.log');

$this->dontSeeLogFile('foobarbaz.log');

$this->seeInLogFile('example.log', 'Sample log message!');

$this->seeInLogFile('example.log', [
    'Sample log message 1!',
    'Sample log message 2!',
    'Sample log message 3!',
]);

$this->seeInLogFile('example.log', '[%datetime%]: Sample log message!');

$this->dontSeeInLogFile('example.log', 'Non-existing log message!');

$this->dontSeeInLogFile('example.log', [
    'Non-existing log message 1!',
    'Non-existing log message 2!',
    'Non-existing log message 3!',
]);

$this->seeScheduleCount(3);

$this->dontSeeScheduleCount(5);

$this->seeInSchedule('foo', 'everyFiveMinutes');
$this->seeInSchedule('bar', 'hourly');
$this->seeInSchedule('baz', 'twiceDaily');

$this->seeInSchedule('foo', '*/5 * * * * *');
$this->seeInSchedule('bar', '0 * * * * *');
$this->seeInSchedule('baz', '0 1,13 * * * *');

$this->dontSeeInSchedule('foobarbaz');