Skip to content

Commit

Permalink
Add test for setting diff calculator for all further assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Feb 22, 2024
1 parent b71c795 commit 17833ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GDAssertTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function assertNotSimilarGD($expected, $actual, $message = '', $threshold
*/
public function isSimilarGD($expected, $threshold = 0, $diffCalculator = null)
{
return new GDSimilarityConstraint($expected, $threshold, $diffCalculator ?? new RgbaChannels());
return new GDSimilarityConstraint($expected, $threshold, $diffCalculator ?? $this->diffCalculator ?? new RgbaChannels());
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/GDAssertTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ public function testAlternativeDiffCalculator()
$this->assertSimilarGD('./tests/images/transparent-black.gif', './tests/images/transparent-white.gif',
'', 0, new ScaledRgbChannels());
}

public function testSetDiffCalculator()
{
// apply diff calculator on all further assertions
$this->setDiffCalculator(new ScaledRgbChannels());

$this->assertSimilarGD('./tests/images/transparent-black.gif', './tests/images/transparent-white.gif');
}
}

0 comments on commit 17833ef

Please sign in to comment.