root = sys_get_temp_dir().'/sealshare-publisher-'.uniqid(); mkdir($this->root.'/captures', 0755, true); }); afterEach(function () { exec('rm -rf '.escapeshellarg($this->root)); }); test('a capture is published as WebP at each width, keeping its aspect ratio', function () { $capture = imagecreatetruecolor(3024, 1964); imagepng($capture, $this->root.'/captures/desktop-light-01-upload.png'); (new Publisher($this->root.'/captures', $this->root.'/site')) ->publish('desktop-light-01-upload', 'desktop', 'light', '01-upload', [1600, 800]); foreach ([1600 => 1039, 800 => 520] as $width => $height) { $path = $this->root."/site/desktop/light/01-upload-{$width}.webp"; expect($path)->toBeFile() ->and(getimagesize($path))->toMatchArray([0 => $width, 1 => $height, 'mime' => 'image/webp']); } }); test('a capture that was not written fails the run', function () { (new Publisher($this->root.'/captures', $this->root.'/site')) ->publish('phone-dark-02-password', 'phone', 'dark', '02-password', [1080]); })->throws(RuntimeException::class, 'The capture [phone-dark-02-password] was not written');