Create a Data Tester¶
From a PHPUnit test case you simply create a new Draw\DataTester\Tester instance:
<?php
namespace Your\Project\Name;
use PHPUnit\Framework\TestCase;
use Draw\DataTester\Tester;
class ExampleTest extends TestCase
{
public function test()
{
$dataToTest = 'A string value';
$tester = new Tester($dataToTest);
$tester
->assertInternalType('string')
->assertSame('A string value');
}
}
The Tester use a fluent interface by returning himself on all of the assert* methods and most of his methods. This allow to easily make multiple test on the same data.
If you don’t need a reference to the tester you can be even more concise:
(new Tester('A string value'))
->assertInternalType('string')
->assertSame('A string value');