1. Go to this page and download the library: Download alexskrypnyk/snapshot library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alexskrypnyk / snapshot example snippets
use AlexSkrypnyk\Snapshot\Testing\SnapshotTrait;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase {
use SnapshotTrait;
public function testGeneratorOutput(): void {
// Run your code generator
$generator->generate($output_dir);
// Compare against expected output
$this->assertDirectoriesIdentical($expected_dir, $output_dir);
}
}
public function testScenarioA(): void {
$generator->generate($output_dir, ['option' => 'A']);
$this->assertSnapshotMatchesBaseline(
$output_dir, // Actual output
$baseline_dir, // Common baseline
$scenario_a_diffs_dir // Diffs specific to scenario A
);
}
protected function tearDown(): void {
// Updates snapshots when UPDATE_SNAPSHOTS=1 is set
$this->snapshotUpdateOnFailure($snapshots_dir, $actual_dir);
parent::tearDown();
}