matthewbdaly / laravel-golden-master-tests by matthewbdaly

Package for writing golden master tests
39
1
3
Package Data
Maintainer Username: matthewbdaly
Maintainer Contact: matthewbdaly@gmail.com (Matthew Daly)
Package Create Date: 2019-05-14
Package Last Update: 2019-05-15
Language: PHP
License: MIT
Last Refreshed: 2024-12-15 15:20:29
Package Statistics
Total Downloads: 39
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 1
Total Watchers: 3
Total Forks: 1
Total Open Issues: 0

laravel-golden-master-tests

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