2017 © Pedro Peláez
 

library package-testing-utils

image

sven/package-testing-utils

  • Wednesday, September 6, 2017
  • by svenluijten
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

laravel-testing-utils, (*1)

Laravel Testing Utils

Latest Version on Packagist Total Downloads Software License [Build Status][link-tests] ![StyleCI][ico-styleci] PhpStan, (*2)

This package adds various Laravel-related assertions so you won't have to write them yourself in every new application., (*3)

Index

Installation

You will have to follow a couple of steps to install this package., (*4)

Downloading

Via Composer:, (*5)

$ composer require sven/laravel-testing-utils:^1.0 --dev

Or add the package to your development dependencies in composer.json and run composer update on the command line to download the package:, (*6)

{
    "require-dev": {
        "sven/laravel-testing-utils": "^1.0"
    }
}

Usage

You will now have access to several traits and macros to use in your test classes., (*7)

InteractsWithViews

This trait adds several view-related assertions. They are used as follows:, (*8)

<?php

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

TestCollectionMacros

This set of macros adds some assertions to Laravel collections: assertContains and assertNotContains. They are used as follows:, (*9)

<?php

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

Contributing

All contributions (pull requests, issues and feature requests) are welcome. Make sure to read through the CONTRIBUTING.md first, though. See the contributors page for all contributors., (*10)

License

sven/laravel-testing-utils is licensed under the MIT License (MIT). Please see the license file for more information., (*11)

The Versions

06/09 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

05/09 2017

dev-analysis-8K2MB9

dev-analysis-8K2MB9

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires