Skip to content

Commit

Permalink
use platform-specific directory separator in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil committed Sep 6, 2019
1 parent a3e5247 commit a46d1e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/Framework/Assert.snapshot.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use Tester\Snapshot;

require __DIR__ . '/../bootstrap.php';

Snapshot::$snapshotDir = __DIR__ . '/fixtures';
Snapshot::$snapshotDir = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures';

Assert::snapshot('existingSnapshot', ['answer' => 42]);

Expand Down
16 changes: 8 additions & 8 deletions tests/Framework/Assert.snapshot.update.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ use Tester\Snapshot;
require __DIR__ . '/../bootstrap.php';

putenv(Environment::UPDATE_SNAPSHOTS . '=1');
Snapshot::$snapshotDir = __DIR__ . '/snapshots';
Snapshot::$snapshotDir = __DIR__ . DIRECTORY_SEPARATOR . 'snapshots';
Helpers::purge(Snapshot::$snapshotDir);

// newly created

Assert::false(file_exists(Snapshot::$snapshotDir . '/Assert.snapshot.update.newSnapshot.phps'));
Assert::false(file_exists(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.newSnapshot.phps'));
Assert::snapshot('newSnapshot', ['answer' => 42]);
Assert::true(file_exists(Snapshot::$snapshotDir . '/Assert.snapshot.update.newSnapshot.phps'));
Assert::contains('42', file_get_contents(Snapshot::$snapshotDir . '/Assert.snapshot.update.newSnapshot.phps'));
Assert::true(file_exists(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.newSnapshot.phps'));
Assert::contains('42', file_get_contents(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.newSnapshot.phps'));

// existing

file_put_contents(
Snapshot::$snapshotDir . '/Assert.snapshot.update.updatedSnapshot.phps',
Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.updatedSnapshot.phps',
'<?php return array(\'answer\' => 43);' . PHP_EOL
);

Assert::true(file_exists(Snapshot::$snapshotDir . '/Assert.snapshot.update.updatedSnapshot.phps'));
Assert::true(file_exists(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.updatedSnapshot.phps'));
Assert::snapshot('updatedSnapshot', ['answer' => 42]);
Assert::true(file_exists(Snapshot::$snapshotDir . '/Assert.snapshot.update.updatedSnapshot.phps'));
Assert::contains('42', file_get_contents(Snapshot::$snapshotDir . '/Assert.snapshot.update.updatedSnapshot.phps'));
Assert::true(file_exists(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.updatedSnapshot.phps'));
Assert::contains('42', file_get_contents(Snapshot::$snapshotDir . DIRECTORY_SEPARATOR . 'Assert.snapshot.update.updatedSnapshot.phps'));

// Snapshot::$updatedSnapshots

Expand Down

0 comments on commit a46d1e4

Please sign in to comment.