2017 © Pedro Peláez
 

library testing-tools

Laravel-specific testing helpers and asserts.

image

illuminated/testing-tools

Laravel-specific testing helpers and asserts.

  • Monday, July 23, 2018
  • by dmitry-ivanov
  • Repository
  • 3 Watchers
  • 48 Stars
  • 5,294 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 74 Versions
  • 10 % Grown

The README.md

Laravel-specific Testing Helpers and Assertions, (*1)

Laravel Testing Tools

Buy me a coffee, (*2)

StyleCI Build Status Coverage Status, (*3)

Packagist Version Packagist Stars Packagist Downloads Packagist License, (*4)

Laravel-specific Testing Helpers and Assertions., (*5)

Laravel Testing Tools
11.x Support
10.x 10.x
9.x 9.x
8.x 8.x
7.x 7.x
6.x 6.x
5.8.* 5.8.*
5.7.* 5.7.*
5.6.* 5.6.*
5.5.* 5.5.*
5.4.* 5.4.*
5.3.* 5.3.*
5.2.* 5.2.*
5.1.* 5.1.*

Usage

  1. Install the package via Composer:, (*6)

    shell script composer require --dev illuminated/testing-tools, (*7)

  2. Use Illuminated\Testing\TestingTools trait:, (*8)

    use Illuminated\Testing\TestingTools;
    
    abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
    {
        use TestingTools;
    
        // ...
    }
    
  3. Use any of the provided helpers and assertions in your tests:, (*9)

    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 🤟'],
            ]);
        }
    }
    

Available helpers

Feel free to contribute., (*10)

Available assertions

Feel free to contribute., (*11)

Helpers

ApplicationHelpers

emulateLocal()

Emulate that application is running on the local environment:, (*12)

$this->emulateLocal();

emulateProduction()

Emulate that application is running on the production environment:, (*13)

$this->emulateProduction();

emulateEnvironment()

Emulate that application is running on the given environment:, (*14)

$this->emulateEnvironment('demo');

Assertions

CollectionAsserts

assertCollectionsEqual()

Assert that the given collections are equal based on the specified key:, (*15)

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

assertCollectionsNotEqual()

Assert that the given collections are not equal based on the specified key:, (*16)

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

DatabaseAsserts

assertDatabaseHasTable()

Assert that the database has the given table:, (*17)

$this->assertDatabaseHasTable('users');

assertDatabaseMissingTable()

Assert that the database doesn't have the given table:, (*18)

$this->assertDatabaseMissingTable('unicorns');

assertDatabaseHasMany()

Assert that the database has all the given rows:, (*19)

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

assertDatabaseMissingMany()

Assert that the database doesn't have all the given rows:, (*20)

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

FilesystemAsserts

assertDirectoryEmpty()

Assert that the given directory is empty:, (*21)

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

assertDirectoryNotEmpty()

Assert that the given directory is not empty:, (*22)

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

assertFilesCount()

Assert that directory has the given number of files:, (*23)

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

assertNotFilesCount()

Assert that directory doesn't have the given number of files:, (*24)

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

LogFileAsserts

seeLogFile()

Assert that the given log file exists., (*25)

The path is relative to the storage/logs folder:, (*26)

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

dontSeeLogFile()

Assert that the given log file doesn't exist., (*27)

The path is relative to the storage/logs folder:, (*28)

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

seeInLogFile()

Assert that the log file contains the given message., (*29)

The path is relative to the storage/logs folder:, (*30)

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

Also, you can specify an array of messages:, (*31)

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

You can use these placeholders in messages: - %datetime% - any datetime string., (*32)

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

dontSeeInLogFile()

Assert that the log file doesn't contain the given message., (*33)

The path is relative to the storage/logs folder:, (*34)

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

Also, you can specify an array of messages:, (*35)

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

ScheduleAsserts

seeScheduleCount()

Assert that schedule count equals to the given value:, (*36)

$this->seeScheduleCount(3);

dontSeeScheduleCount()

Assert that schedule count doesn't equal to the given value:, (*37)

$this->dontSeeScheduleCount(5);

seeInSchedule()

Assert that the given command is scheduled:, (*38)

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

Also, you can use cron expressions:, (*39)

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

dontSeeInSchedule()

Assert that the given command is not scheduled:, (*40)

$this->dontSeeInSchedule('foobarbaz');

Sponsors

Laravel Idea
Material Theme UI Plugin
, (*41)

License

Laravel Testing Tools is open-sourced software licensed under the MIT license., (*42)

Buy me a coffee , (*43)

The Versions

23/07 2018

5.6.x-dev

5.6.9999999.9999999-dev

Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.6.4

5.6.4.0

Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

dev-master

9999999-dev

Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.5.x-dev

5.5.9999999.9999999-dev

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.4.x-dev

5.4.9999999.9999999-dev

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.3.x-dev

5.3.9999999.9999999-dev

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.2.x-dev

5.2.9999999.9999999-dev

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/07 2018

5.1.x-dev

5.1.9999999.9999999-dev

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

14/07 2018

5.6.3

5.6.3.0

Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

14/07 2018

5.6.2

5.6.2.0

Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

18/02 2018

5.6.1

5.6.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

18/02 2018

5.6.0

5.6.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

24/01 2018

5.5.5

5.5.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2018

5.5.4

5.5.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2018

5.4.2

5.4.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2018

5.3.2

5.3.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2018

5.2.2

5.2.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2018

5.1.2

5.1.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

12/01 2018

5.5.3

5.5.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

12/01 2018

5.4.1

5.4.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

12/01 2018

5.3.1

5.3.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

12/01 2018

5.2.1

5.2.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

12/01 2018

5.1.1

5.1.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.5.2

5.5.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.5.1

5.5.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.5.0

5.5.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.4.0

5.4.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.3.0

5.3.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.2.0

5.2.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

07/09 2017

5.1.0

5.1.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

08/08 2017

0.6.6

0.6.6.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

03/04 2017

0.6.5

0.6.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

27/03 2017

0.6.4

0.6.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

22/03 2017

0.6.3

0.6.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

17/03 2017

0.6.2

0.6.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

17/03 2017

0.6.1

0.6.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

17/03 2017

0.6.0

0.6.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

16/03 2017

0.5.11

0.5.11.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

16/03 2017

0.5.10

0.5.10.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

16/03 2017

0.5.9

0.5.9.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/03 2017

0.5.8

0.5.8.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/03 2017

0.5.7

0.5.7.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/03 2017

0.5.6

0.5.6.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

06/03 2017

0.5.5

0.5.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

06/03 2017

0.5.4

0.5.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

20/02 2017

0.5.3

0.5.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/02 2017

0.5.2

0.5.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

30/01 2017

0.5.1

0.5.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

30/01 2017

0.5.0

0.5.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2017

0.4.5

0.4.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2017

0.4.4

0.4.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

19/01 2017

0.4.3

0.4.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

30/12 2016

0.4.2

0.4.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

30/12 2016

0.4.1

0.4.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

27/12 2016

0.4.0

0.4.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

24/12 2016

0.3.4

0.3.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

24/12 2016

0.3.3

0.3.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

24/12 2016

0.3.2

0.3.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/12 2016

0.3.1

0.3.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

23/12 2016

0.3.0

0.3.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

22/12 2016

0.2.6

0.2.6.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

22/12 2016

0.2.5

0.2.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

22/12 2016

0.2.4

0.2.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

22/12 2016

0.2.3

0.2.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

17/12 2016

0.2.2

0.2.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/12 2016

0.2.1

0.2.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/12 2016

0.2.0

0.2.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

15/12 2016

0.1.6

0.1.6.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

13/12 2016

0.1.5

0.1.5.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

13/12 2016

0.1.4

0.1.4.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

10/12 2016

0.1.3

0.1.3.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

09/12 2016

0.1.2

0.1.2.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

09/12 2016

0.1.1

0.1.1.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts

08/12 2016

0.1.0

0.1.0.0

Provides Laravel-specific testing helpers and asserts.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Ivanov

laravel helpers testing asserts