-
Notifications
You must be signed in to change notification settings - Fork 27
File Export
This is a tutorial for using the FileExport PHPUnit extension.
Unit testing can be painful. Building robust tests is time consuming, particularly when looking at large data structures. If only there was some way to automate the building of assert statements. This extension may help you. Rather than trying to break apart a large object or array, you can simply make the call:
$this->assertExportCompare($whatever);
This will compare the var_export of the element against a previously saved file.
To use the file export class, extend the abstract class:
require_once('YOUR-PATH/PHPUnit/Extensions/FileExport/FileExportCompare.php')
class Example_uut extends PHPUnit_FileExport_TestCase {
}
There are two command-line options for saving the export files:
- --save-exports - save the export files for one method
- --save-all-exports - save all the export files for all methods
It's recommended that you use --save-exports so that you can carefully compare you results. Saving all the exports at one time could allow you to overlook any issues.
When you