Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73bff3b
commit 74d2933
Showing
5 changed files
with
73 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Spatie\ImageOptimizer\Test; | ||
|
||
use Spatie\ImageOptimizer\OptimizerChain; | ||
use Spatie\ImageOptimizer\Optimizers\Optipng; | ||
use Spatie\ImageOptimizer\Optimizers\Pngquant; | ||
use Spatie\ImageOptimizer\Optimizers\Jpegoptim; | ||
|
||
class OptimizerChainTest extends TestCase | ||
{ | ||
/** @var \Spatie\ImageOptimizer\OptimizerChain; */ | ||
protected $optimizerChain; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->optimizerChain = new OptimizerChain(); | ||
} | ||
|
||
/** @test */ | ||
public function it_will_not_throw_an_exception_when_not_using_a_logger() | ||
{ | ||
$testImage = $this->getTempFilePath('test.jpg'); | ||
|
||
$this->optimizerChain | ||
->addOptimizer(new Jpegoptim()) | ||
->optimize($testImage); | ||
|
||
$this->assertDecreasedFileSize($testImage, $this->getTestFilePath('test.jpg')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_get_all_optimizers() | ||
{ | ||
$this->assertEquals([], $this->optimizerChain->getOptimizers()); | ||
|
||
$this->optimizerChain->addOptimizer(new Jpegoptim()); | ||
|
||
$this->assertInstanceOf(Jpegoptim::class, $this->optimizerChain->getOptimizers()[0]); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_replace_all_optimizers_with_other_ones() | ||
{ | ||
$this->assertEquals([], $this->optimizerChain->getOptimizers()); | ||
|
||
$this->optimizerChain->addOptimizer(new Jpegoptim()); | ||
|
||
$this->optimizerChain->setOptimizers([ | ||
new Optipng(), | ||
new Pngquant(), | ||
]); | ||
|
||
$this->assertCount(2, $this->optimizerChain->getOptimizers()); | ||
$this->assertInstanceOf(Optipng::class, $this->optimizerChain->getOptimizers()[0]); | ||
$this->assertInstanceOf(Pngquant::class, $this->optimizerChain->getOptimizers()[1]); | ||
} | ||
} |