dev-analysis-8K2MB9
dev-analysis-8K2MB9
MIT
The Requires
- php ^7.1
The Development Requires
by Sven Luijten
Wallogit.com
2017 © Pedro Peláez
, (*1)
[
][link-tests]
![StyleCI][ico-styleci]
, (*2)
This package adds various Laravel-related assertions so you won't have to write them yourself in every new application., (*3)
You will have to follow a couple of steps to install this package., (*4)
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"
}
}
You will now have access to several traits and macros to use in your test classes., (*7)
InteractsWithViewsThis 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');
}
}
TestCollectionMacrosThis 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');
}
}
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)
sven/laravel-testing-utils is licensed under the MIT License (MIT). Please see the
license file for more information., (*11)
MIT