PHP code example of sven / laravel-testing-utils

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

    

sven / laravel-testing-utils example snippets




use Sven\LaravelTestingUtils\InteractsWithViews;
use Illuminate\Foundation\Testing\TestCase;

class ServiceTest extends TestCase
{
    use InteractsWithViews;

    /** @test */
    public function it_creates_a_view()
    {
        // ...
        
        $this->assertViewExists('some.view-file');
    }
    
    /** @test */
    public function it_does_not_create_a_view()
    {
        // ...
        
        $this->assertViewNotExists('some.view-file');
    }
    
    /** @test */
    public function the_view_equals()
    {
        // ...
        
        $this->assertViewEquals('The Expected Contents', 'index');
    }
    
    /** @test */
    public function the_view_does_not_equal()
    {
        // ...
        
        $this->assertViewNotEquals('This Is Not The Content You\'re Looking For', 'index');
    }
}



use Sven\LaravelTestingUtils\Collections\TestCollectionMacros;
use Illuminate\Foundation\Testing\TestCase;

class ServiceTest extends TestCase
{
    protected function setUp()
    {
        parent::setUp();
        TestCollectionMacros::enable();
    }
        
    /** @test */
    public function it_fetches_some_data()
    {
        // ...
        
        $collection->assertContains('some-item');
        $collection->assertNotContains('some-other-item');
    }
}