2017 © Pedro Peláez
 

library phpunit-snapshots

Snaphot testing for PHPUnit

image

madewithlove/phpunit-snapshots

Snaphot testing for PHPUnit

  • Friday, December 9, 2016
  • by Anahkiasen
  • Repository
  • 3 Watchers
  • 1 Stars
  • 4,222 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 23 % Grown

The README.md

PHPUnit Snapshots

Build Status Latest Stable Version Total Downloads, (*1)

This trait allows you to use Jest-like snapshot testing in your PHPUnit tests., (*2)

It is a very basic trait and is only meant to snapshot JSON-encodable structures, not complex objects and such., (*3)

Installation

composer require madewithlove/phpunit-snapshots

Usage

Using snapshots in tests

Simply call the assertion on any encodable result (the result of a function, a variable, etc.). You can pass an identifier as second argument which will be used as title of the snapshot in the snapshot file., (*4)

<?php
class MyTestCase extends \PHPUnit_Framework_TestCase
{
    use \Madewithlove\PhpunitSnapshots\SnapshotAssertions;

    public function testSomething()
    {
        $this->assertEqualsSnapshot($this->someComplexOperation());
        $this->assertEqualsSnapshot($this->someComplexOperation(), 'Compute something');
    }
}

This will generate a snapshot if we didn't have one for this test, else it will assert that the current results match the ones in the snapshot., (*5)

Updating all snapshots

You can update all snapshots in your tests by running the following:, (*6)

$ phpunit -d --update

Testing

bash $ composer test, (*7)

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

09/12 2016

dev-master

9999999-dev

Snaphot testing for PHPUnit

  Sources   Download

MIT

The Development Requires

by Madewithlove

phpunit snapshot

09/12 2016

0.1.2

0.1.2.0

Snaphot testing for PHPUnit

  Sources   Download

MIT

The Development Requires

by Madewithlove

phpunit snapshot

08/12 2016

0.1.1

0.1.1.0

Snaphot testing for PHPUnit

  Sources   Download

MIT

The Development Requires

by Madewithlove

phpunit snapshot

08/12 2016

0.1.0

0.1.0.0

Snaphot testing for PHPUnit

  Sources   Download

MIT

The Development Requires

by Madewithlove

phpunit snapshot