From 85d09a1603d2b4d02e1d23930dc14cf40b9c7a35 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Thu, 1 Sep 2022 14:31:25 -0400 Subject: [PATCH] Add integration test --- tests/IntegrationTest.php | 96 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/IntegrationTest.php diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php new file mode 100644 index 0000000..47d4523 --- /dev/null +++ b/tests/IntegrationTest.php @@ -0,0 +1,96 @@ +getFactory(); + + $flou + ->inspector() + ->shouldReceive('getSize') + ->andReturn(['width' => 123, 'height' => 123]); + + $flou + ->glideServer() + ->shouldReceive('makeImage') + ->andReturn('cached.jpg'); + + $this->factory = $flou; + } + + public function test_can_handle_single_image() + { + $image = $this->factory->image('source.jpg'); + + $output = $image->render()->img(); + + $this->assertEquals( + '', + $output + ); + } + + public function test_can_handle_simple_imageset() + { + $set = $this->factory->imageSet([ + 'image' => 'source.jpg', + 'widths' => [400], + ]); + + $output = $set->render()->img(); + + $this->assertEquals( + '', + $output + ); + } + + public function test_can_handle_responsive_imageset() + { + $set = $this->factory->imageSet([ + 'image' => 'source.jpg', + 'widths' => [400, 800, 1200], + 'sizes' => '66vw', + ]); + + $output = $set->render()->img(); + + $this->assertEquals( + '', + $output + ); + } + + public function test_can_handle_multi_imageset() + { + $set = $this->factory->imageSet([ + [ + 'image' => 'source1.jpg', + 'media' => '(max-width: 1023px)', + 'widths' => [400, 800], + ], + [ + 'image' => 'source2.jpg', + 'media' => '(min-width: 1024px)', + 'widths' => [1200, 1600], + ], + ]); + + $output = $set->render()->picture(); + + $this->assertEquals( + '', + $output + ); + } +}