matthewbdaly/laravel-golden-master-tests

Package for writing golden master tests

0.0.1 2019-05-15 08:55 UTC

This package is auto-updated.

Last update: 2024-10-15 21:04:47 UTC


README

Class for golden master tests in Laravel.

Installation

$ composer require --dev matthewbdaly/laravel-golden-master-tests

Usage

<?php

namespace Tests\GoldenMaster;

use Matthewbdaly\LaravelGoldenMasterTests\GoldenMasterTestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\User;

class ExampleTest extends GoldenMasterTestCase
{
    use RefreshDatabase;

    /**
     * @dataProvider authDataProvider
     */
    public function testAuthPages($data)
    {
        $user = factory(User::class)->create([
            'email' => 'eric@example.com',
            'name' => 'Eric Smith',
            'password' => 'password'
        ]);
        $this->actingAs($user)
            ->goto($data)
            ->saveHtml()
            ->assertSnapshotsMatch();
    }

    /**
     * @dataProvider nonAuthDataProvider
     */
    public function testNonAuthPages($data)
    {
        $this->goto($data)
            ->saveHtml()
            ->assertSnapshotsMatch();
    }

    public function authDataProvider()
    {
        return [
            ['/'],
        ];
    }

    public function nonAuthDataProvider()
    {
        return [
            ['/register'],
            ['/login'],
        ];
    }
}