Skip to content

Commit 9b2cd8b

Browse files
freekmurzegithub-actions[bot]
authored andcommitted
Fix styling
1 parent b4e62e4 commit 9b2cd8b

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

src/Drivers/HtmlDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function serialize($data): string
1515
throw new CantBeSerialized('Only strings can be serialized to html');
1616
}
1717

18-
if ('' === $data) {
18+
if ($data === '') {
1919
return "\n";
2020
}
2121

src/Drivers/ImageDriver.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class ImageDriver implements Driver
1313
public function __construct(
1414
protected float $threshold = 0.1,
1515
protected bool $includeAa = true,
16-
)
17-
{
16+
) {
1817
}
1918

2019
public function serialize($data): string
@@ -31,10 +30,10 @@ public function match($expected, $actual)
3130
{
3231
$tempPath = sys_get_temp_dir();
3332

34-
$expectedTempPath = $tempPath . '/expected.png';
33+
$expectedTempPath = $tempPath.'/expected.png';
3534
file_put_contents($expectedTempPath, $expected);
3635

37-
$actualTempPath = $tempPath . '/actual.png';
36+
$actualTempPath = $tempPath.'/actual.png';
3837
file_put_contents($actualTempPath, $actual);
3938

4039
$pixelMatch = Pixelmatch::new($expectedTempPath, $actualTempPath)
@@ -44,8 +43,7 @@ public function match($expected, $actual)
4443
try {
4544
$result = $pixelMatch->matches();
4645
} catch (CouldNotCompare $exception) {
47-
throw new
48-
ExpectationFailedException($exception->getMessage());
46+
throw new ExpectationFailedException($exception->getMessage());
4947
}
5048

5149
Assert::assertTrue($result);

src/MatchesSnapshots.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function markTestIncompleteIfSnapshotsHaveChanged()
5151

5252
public function assertMatchesSnapshot($actual, Driver $driver = null): void
5353
{
54-
if (!is_null($driver)) {
54+
if (! is_null($driver)) {
5555
$this->doSnapshotAssertion($actual, $driver);
5656

5757
return;
@@ -68,7 +68,7 @@ public function assertMatchesSnapshot($actual, Driver $driver = null): void
6868

6969
public function assertMatchesFileHashSnapshot(string $filePath): void
7070
{
71-
if (!file_exists($filePath)) {
71+
if (! file_exists($filePath)) {
7272
$this->fail('File does not exist');
7373
}
7474

@@ -116,8 +116,7 @@ public function assertMatchesImageSnapshot(
116116
$actual,
117117
float $threshold = 0.1,
118118
bool $includeAa = true
119-
): void
120-
{
119+
): void {
121120
$this->assertMatchesSnapshot($actual, new ImageDriver(
122121
$threshold,
123122
$includeAa,
@@ -131,8 +130,8 @@ public function assertMatchesImageSnapshot(
131130
*/
132131
protected function getFileSnapshotDirectory(): string
133132
{
134-
return $this->getSnapshotDirectory() .
135-
DIRECTORY_SEPARATOR .
133+
return $this->getSnapshotDirectory().
134+
DIRECTORY_SEPARATOR.
136135
'files';
137136
}
138137

@@ -161,7 +160,7 @@ protected function shouldUpdateSnapshots(): bool
161160
*/
162161
protected function shouldCreateSnapshots(): bool
163162
{
164-
return !in_array('--without-creating-snapshots', $_SERVER['argv'], true)
163+
return ! in_array('--without-creating-snapshots', $_SERVER['argv'], true)
165164
&& getenv('CREATE_SNAPSHOTS') !== 'false';
166165
}
167166

@@ -175,7 +174,7 @@ protected function doSnapshotAssertion(mixed $actual, Driver $driver)
175174
$driver
176175
);
177176

178-
if (!$snapshot->exists()) {
177+
if (! $snapshot->exists()) {
179178
$this->assertSnapshotShouldBeCreated($snapshot->filename());
180179

181180
$this->createSnapshotAndMarkTestIncomplete($snapshot, $actual);
@@ -203,7 +202,7 @@ protected function doSnapshotAssertion(mixed $actual, Driver $driver)
203202

204203
protected function doFileSnapshotAssertion(string $filePath): void
205204
{
206-
if (!file_exists($filePath)) {
205+
if (! file_exists($filePath)) {
207206
$this->fail('File does not exist');
208207
}
209208

@@ -217,7 +216,7 @@ protected function doFileSnapshotAssertion(string $filePath): void
217216

218217
$this->snapshotIncrementor++;
219218

220-
$snapshotId = $this->getSnapshotId() . '.' . $fileExtension;
219+
$snapshotId = $this->getSnapshotId().'.'.$fileExtension;
221220
$snapshotId = Filename::cleanFilename($snapshotId);
222221

223222
// If $filePath has a different file extension than the snapshot, the test should fail
@@ -240,13 +239,13 @@ protected function doFileSnapshotAssertion(string $filePath): void
240239
$this->fail("File did not match the snapshot file extension (expected: {$expectedExtension}, was: {$fileExtension})");
241240
}
242241

243-
$failedSnapshotId = $snapshotId . '_failed.' . $fileExtension;
242+
$failedSnapshotId = $snapshotId.'_failed.'.$fileExtension;
244243

245244
if ($fileSystem->has($failedSnapshotId)) {
246245
$fileSystem->delete($failedSnapshotId);
247246
}
248247

249-
if (!$fileSystem->has($snapshotId)) {
248+
if (! $fileSystem->has($snapshotId)) {
250249
$this->assertSnapshotShouldBeCreated($failedSnapshotId);
251250

252251
$fileSystem->copy($filePath, $snapshotId);
@@ -256,7 +255,7 @@ protected function doFileSnapshotAssertion(string $filePath): void
256255
return;
257256
}
258257

259-
if (!$fileSystem->fileEquals($filePath, $snapshotId)) {
258+
if (! $fileSystem->fileEquals($filePath, $snapshotId)) {
260259
if ($this->shouldUpdateSnapshots()) {
261260
$fileSystem->copy($filePath, $snapshotId);
262261

@@ -289,8 +288,8 @@ protected function updateSnapshotAndMarkTestIncomplete(Snapshot $snapshot, $actu
289288

290289
protected function rethrowExpectationFailedExceptionWithUpdateSnapshotsPrompt($exception): void
291290
{
292-
$newMessage = $exception->getMessage() . "\n\n" .
293-
'Snapshots can be updated by passing ' .
291+
$newMessage = $exception->getMessage()."\n\n".
292+
'Snapshots can be updated by passing '.
294293
'`-d --update-snapshots` through PHPUnit\'s CLI arguments.';
295294

296295
$exceptionReflection = new ReflectionObject($exception);
@@ -314,9 +313,9 @@ protected function assertSnapshotShouldBeCreated(string $snapshotFileName): void
314313
}
315314

316315
$this->fail(
317-
"Snapshot \"$snapshotFileName\" does not exist.\n" .
318-
'You can automatically create it by removing ' .
319-
'the `CREATE_SNAPSHOTS=false` env var, or ' .
316+
"Snapshot \"$snapshotFileName\" does not exist.\n".
317+
'You can automatically create it by removing '.
318+
'the `CREATE_SNAPSHOTS=false` env var, or '.
320319
'`-d --without-creating-snapshots` of PHPUnit\'s CLI arguments.'
321320
);
322321
}

tests/Unit/Drivers/ImageDriverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public function setUp(): void
1414

1515
$this->driver = new ImageDriver();
1616

17-
$this->pathToImageA = __DIR__ . '/../test_files/testA.png';
18-
$this->pathToImageB = __DIR__ . '/../test_files/testB.png';
19-
$this->pathToImageWithDifferentDimensions = __DIR__ . '/../test_files/testC.png';
17+
$this->pathToImageA = __DIR__.'/../test_files/testA.png';
18+
$this->pathToImageB = __DIR__.'/../test_files/testB.png';
19+
$this->pathToImageWithDifferentDimensions = __DIR__.'/../test_files/testC.png';
2020

2121
}
2222

0 commit comments

Comments
 (0)