PHP code example of spatie / pest-expectations

1. Go to this page and download the library: Download spatie/pest-expectations 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/ */

    

spatie / pest-expectations example snippets


it('can only run well on github actions', function () {
    // your test
})->whenGitHubActions();

expect(new YourValidationRule())->toPassWith($value);

expect(new YourValidationRule()->not()->toPassWith($value);

expect(new YourValidationRule())->toFailWith($value);

expect(new YourValidationRule())->toFailWith($value, 'This value is not valid.');

expect($model)->toBeModel($anotherModel);

expect(MyJob::class)->toBeScheduled('0 * * * *');

expect(MyArtisanCommand::class)->toBeScheduled(function (Event $event) {
    expect($event->getExpression())->toBe('0 0 * * *');
    expect($event->getSummaryForDisplay())->toBe('Foo');
});

$response = $this->get('/');

expect($response)->toHaveJsonApiPagination();

it('can only run well on github actions', function () {
    // your test
})->whenGitHubActions();

class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
    use CustomAssertions;

    protected function setUp(): void
    {
        parent::setUp();

        $this->registerCustomAssertions();
    }

$this
    ->get('/')
    ->assertHasJsonApiPagination();