draw/data-tester

Library base on phpunit to test your data with a fluent interface.

0.4.0 2018-08-13 00:27 UTC

This package is auto-updated.

Last update: 2024-12-06 03:13:53 UTC


README

https://travis-ci.org/mpoiriert/php-data-tester.svg?branch=master

This library is a wrapper around PHPUnit Assert class to be able to use a fluent interface on the data you want to test.

The library can be install via Composer/Packagist.

Here is a quick example of how to use it in a PHPUnit TestCase:

<?php

namespace Your\Project\Name;

use PHPUnit\Framework\TestCase;
use Draw\DataTester\Tester;

class SimpleTest extends TestCase
{
    public function test()
    {
        $data = [
          'key1' => 'value1',
          'key2' => (object)['toto' => 'value']
        ];

        $tester = new Tester($data);
        $tester->assertInternalType('array')
            ->assertCount(2)
            ->path('[key1]')->assertSame('value1');
        $tester->path('[key2].toto')->assertSame('value');
}

There is a lot more features available, just Read the Docs!