diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d46bae..14b66c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: extensions: ${{ env.php_extensions }} ini-values: log_errors=On, error_log="${{github.workspace}}/artifacts/php_errors.log" coverage: none - tools: composer:v1 + tools: composer:v2 - name: Get composer cache directory id: composer-cache diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 8934203..46f3ee1 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,27 +1,27 @@ - CodeSniffer ruleset for SilverStripe coding conventions. - - - - - - - - - - - - + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + + + + + + + - + - - - - - - + + + + + + @@ -37,10 +37,30 @@ - + + + + + + + + + + + warning + + + warning + + + warning + + + warning + - - + + ./src ./tests diff --git a/src/Extensions/ImageExtension.php b/src/Extensions/ImageExtension.php index 3c2dc1f..1fefc72 100644 --- a/src/Extensions/ImageExtension.php +++ b/src/Extensions/ImageExtension.php @@ -32,7 +32,7 @@ public function getIsWebP() */ public function getWebP() { - //Do nothing we aleady appear to have a webp + // Do nothing we aleady appear to have a webp if ($this->owner->getIsWebP()) { return $this->owner; } diff --git a/tests/PHPUnit/Bootstrap/GitHubActionsAnnotatorPrinter.php b/tests/PHPUnit/Bootstrap/GitHubActionsAnnotatorPrinter.php index 6e0ab68..a673c5b 100644 --- a/tests/PHPUnit/Bootstrap/GitHubActionsAnnotatorPrinter.php +++ b/tests/PHPUnit/Bootstrap/GitHubActionsAnnotatorPrinter.php @@ -90,7 +90,7 @@ protected function relativePath($path) { $relative = str_replace(getcwd() . DIRECTORY_SEPARATOR, '', $path); - //Normalize + // Normalize $relative = str_replace('\\', '/', $relative); return $relative; diff --git a/tests/PHPUnit/GenerateWebP.php b/tests/PHPUnit/GenerateWebP.php index 74c428e..3a17d41 100644 --- a/tests/PHPUnit/GenerateWebP.php +++ b/tests/PHPUnit/GenerateWebP.php @@ -58,24 +58,24 @@ public function testWebPDetection() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $png **/ $png = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($png); $this->assertNotFalse($png); $this->assertTrue($png->exists()); - //Make srue the image was not detected as a WebP + // Make srue the image was not detected as a WebP $this->assertFalse($png->getIsWebP(), 'Image should not have been a WebP but it was detected as one'); /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $webp **/ $webp = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($webp); $this->assertNotFalse($webp); $this->assertTrue($webp->exists()); - //Make sure the image was detected as a WebP + // Make sure the image was detected as a WebP $this->assertTrue($webp->getIsWebP(), 'Image should have been a WebP but it wasn\'t detected as one'); } @@ -87,18 +87,18 @@ public function testImageGetWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); - //Check to see if the file was generated how we expect + // Check to see if the file was generated how we expect $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); } @@ -110,25 +110,25 @@ public function testDBFileGetWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Create a DBFile of the image + // Create a DBFile of the image /** @var DBFile|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $dbFile **/ $dbFile = $img->File; $this->assertInstanceOf(DBFile::class, $dbFile); $this->assertEquals('folder/wbg-logo-png.png', $dbFile->Filename); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $dbFile->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); - //Check to see if the file was generated how we expect + // Check to see if the file was generated how we expect $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); } @@ -140,26 +140,26 @@ public function testImageResampleGeneratedWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Generate the WebP + // Generate the WebP $generatedWebP = $img->getWebP(); - //Resample the WebP + // Resample the WebP /** @var DBFile|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $resampled **/ $resampled = $generatedWebP->ScaleWidth(100); $this->assertInstanceOf(DBFile::class, $resampled); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ExtRewriteWyJwbmciLCJ3ZWJwIl0_ScaleWidthWzEwMF0', $resampled->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0_ScaleWidthWzEwMF0.webp', $resampled->getURL(false)); } @@ -171,28 +171,28 @@ public function testDBFileResampleGeneratedWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); $dbFile = $img->File; - //Generate the WebP + // Generate the WebP $generatedWebP = $dbFile->getWebP(); - //Resample the WebP + // Resample the WebP /** @var DBFile|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $resampled **/ $resampled = $generatedWebP->ScaleWidth(100); $this->assertInstanceOf(DBFile::class, $resampled); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ExtRewriteWyJwbmciLCJ3ZWJwIl0_ScaleWidthWzEwMF0', $resampled->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0_ScaleWidthWzEwMF0.webp', $resampled->getURL(false)); } @@ -204,34 +204,34 @@ public function testImageResampleResampleGetWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Resample the original + // Resample the original /** @var DBFile|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $resampled **/ $resampled = $img->ScaleWidth(100); $this->assertInstanceOf(DBFile::class, $resampled); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ScaleWidthWzEwMF0', $resampled->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ScaleWidthWzEwMF0.png', $resampled->getURL(false)); - //Generate the WebP + // Generate the WebP $generatedWebP = $resampled->getWebP(); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ScaleWidthWzEwMF0_ExtRewriteWyJwbmciLCJ3ZWJwIl0', $generatedWebP->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ScaleWidthWzEwMF0_ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $generatedWebP->getURL(false)); } @@ -243,7 +243,7 @@ public function testDBFileResampleGetWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); @@ -251,28 +251,28 @@ public function testDBFileResampleGetWebP() $dbFile = $img->File; - //Resample the original + // Resample the original /** @var DBFile|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $resampled **/ $resampled = $dbFile->ScaleWidth(100); $this->assertInstanceOf(DBFile::class, $resampled); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ScaleWidthWzEwMF0', $resampled->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ScaleWidthWzEwMF0.png', $resampled->getURL(false)); - //Generate the WebP + // Generate the WebP $generatedWebP = $resampled->getWebP(); - //Make sure we got a resample back + // Make sure we got a resample back $this->assertEquals('ScaleWidthWzEwMF0_ExtRewriteWyJwbmciLCJ3ZWJwIl0', $generatedWebP->getVariant()); - //Make sure the resample has the name we expect + // Make sure the resample has the name we expect $this->assertEquals('/assets/GenerateWebPTest/folder/wbg-logo-png__ScaleWidthWzEwMF0_ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $generatedWebP->getURL(false)); } @@ -284,15 +284,15 @@ public function testImageGenerateWebPWithWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Generate the WebP + // Generate the WebP $generatedWebP = $img->getWebP(); - //Make sure we got an image back again and that it's the same image + // Make sure we got an image back again and that it's the same image $this->assertInstanceOf(Image::class, $generatedWebP); $this->assertEquals($img->ID, $generatedWebP->ID); $this->assertEquals($img->getURL(), $generatedWebP->getURL()); @@ -306,17 +306,17 @@ public function testDBFileGenerateWebPWithWebP() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); $img = $img->File; - //Generate the WebP + // Generate the WebP $generatedWebP = $img->getWebP(); - //Make sure we got an image back again and that it's the same image + // Make sure we got an image back again and that it's the same image $this->assertInstanceOf(DBFile::class, $generatedWebP); $this->assertEquals($img->getURL(), $generatedWebP->getURL()); } diff --git a/tests/PHPUnit/ImageShortcode.php b/tests/PHPUnit/ImageShortcode.php index 23eae21..294698a 100644 --- a/tests/PHPUnit/ImageShortcode.php +++ b/tests/PHPUnit/ImageShortcode.php @@ -62,53 +62,53 @@ public function testPublishedPNGRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); $this->assertFileExists(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); - //Publish the file + // Publish the file $img->publishSingle(); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png.png', 'Orginal was not moved as expected'); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not moved as expected'); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not removed from the protected path as expected'); - //Make sure the url ends how we'd expect + // Make sure the url ends how we'd expect $webpURL = $generatedWebP->getURL(); $this->assertStringEndsWith('folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $webpURL); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $parsedShortcode = ShortcodeParser::get()->parse('[image id="' . $img->ID . '" width="250" height="250"]'); - //Make sure the picture tag exits + // Make sure the picture tag exits $this->assertStringContainsString('', $parsedShortcode); - //Make sure the source tag exists + // Make sure the source tag exists $this->assertStringContainsString('', $parsedShortcode, 'Could not find the expected tag in the rendered template'); - //Make sure the image tag exists and links to the correct file + // Make sure the image tag exists and links to the correct file $originalURL = $img->getURL(); $this->assertMatchesRegularExpression('/]*) src="' . preg_quote(Convert::raw2att($originalURL), '/') . '"([^>]*)>/', $parsedShortcode, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the WebP file + // Make sure we can hit the WebP file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $webpURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -122,47 +122,47 @@ public function testDraftPNGRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); $this->assertFileExists(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); - //Make sure the url ends how we'd expect + // Make sure the url ends how we'd expect $webpURL = $generatedWebP->getURL(); $this->assertStringEndsWith('/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $webpURL); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $parsedShortcode = ShortcodeParser::get()->parse('[image id="' . $img->ID . '" width="250" height="250"]'); - //Make sure the picture tag exits + // Make sure the picture tag exits $this->assertStringContainsString('', $parsedShortcode); - //Make sure the source tag exists + // Make sure the source tag exists $this->assertStringContainsString('', $parsedShortcode, 'Could not find the expected tag in the rendered template'); - //Make sure the image tag exists and links to the correct file + // Make sure the image tag exists and links to the correct file $originalURL = $img->getURL(); $this->assertMatchesRegularExpression('/]*) src="' . preg_quote(Convert::raw2att($originalURL), '/') . '"([^>]*)>/', $parsedShortcode, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the WebP file + // Make sure we can hit the WebP file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $webpURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -176,38 +176,38 @@ public function testPublishedWebPRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(Image::class, $generatedWebP); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-webp.webp.webp', 'WebP Variant was not generated as expected'); - //Publish the file + // Publish the file $img->publishSingle(); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-webp.webp', 'Orginal was not moved as expected'); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $parsedShortcode = ShortcodeParser::get()->parse('[image id="' . $img->ID . '" width="250" height="250"]'); - //Make sure the picture tag does not exit + // Make sure the picture tag does not exit $this->assertStringNotContainsString('', $parsedShortcode); $this->assertStringNotContainsString(']*)>/', $parsedShortcode, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -221,33 +221,33 @@ public function testDraftWebPRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(Image::class, $generatedWebP); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-webp.webp.webp', 'WebP Variant was not generated as expected'); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $parsedShortcode = ShortcodeParser::get()->parse('[image id="' . $img->ID . '" width="250" height="250"]'); - //Make sure the picture tag does not exit + // Make sure the picture tag does not exit $this->assertStringNotContainsString('', $parsedShortcode); $this->assertStringNotContainsString(']*)>/', $parsedShortcode, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/ImageShortcode/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); diff --git a/tests/PHPUnit/TemplateRendering.php b/tests/PHPUnit/TemplateRendering.php index 76a002e..33b5e7a 100644 --- a/tests/PHPUnit/TemplateRendering.php +++ b/tests/PHPUnit/TemplateRendering.php @@ -61,53 +61,53 @@ public function testPublishedPNGRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); $this->assertFileExists(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); - //Publish the file + // Publish the file $img->publishSingle(); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png.png', 'Orginal was not moved as expected'); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not moved as expected'); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not removed from the protected path as expected'); - //Make sure the url ends how we'd expect + // Make sure the url ends how we'd expect $webpURL = $generatedWebP->getURL(); $this->assertStringEndsWith('folder/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $webpURL); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $renderedTemplate = $img->forTemplate(); - //Make sure the picture tag exits + // Make sure the picture tag exits $this->assertStringContainsString('', $renderedTemplate); - //Make sure the source tag exists + // Make sure the source tag exists $this->assertStringContainsString('', $renderedTemplate, 'Could not find the expected tag in the rendered template'); - //Make sure the image tag exists and links to the correct file + // Make sure the image tag exists and links to the correct file $originalURL = $img->getURL(); $this->assertMatchesRegularExpression('/]+) src="' . preg_quote(Convert::raw2att($originalURL), '/') . '"([^>]+)>/', $renderedTemplate, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the WebP file + // Make sure we can hit the WebP file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $webpURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -121,47 +121,47 @@ public function testDraftPNGRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testpng'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(DBFile::class, $generatedWebP); $this->assertFileExists(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', 'WebP Variant was not generated as expected'); - //Make sure the url ends how we'd expect + // Make sure the url ends how we'd expect $webpURL = $generatedWebP->getURL(); $this->assertStringEndsWith('/wbg-logo-png__ExtRewriteWyJwbmciLCJ3ZWJwIl0.webp', $webpURL); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $renderedTemplate = $img->forTemplate(); - //Make sure the picture tag exits + // Make sure the picture tag exits $this->assertStringContainsString('', $renderedTemplate); - //Make sure the source tag exists + // Make sure the source tag exists $this->assertStringContainsString('', $renderedTemplate, 'Could not find the expected tag in the rendered template'); - //Make sure the image tag exists and links to the correct file + // Make sure the image tag exists and links to the correct file $originalURL = $img->getURL(); $this->assertMatchesRegularExpression('/]+) src="' . preg_quote(Convert::raw2att($originalURL), '/') . '"([^>]+)>/', $renderedTemplate, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the WebP file + // Make sure we can hit the WebP file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $webpURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -175,38 +175,38 @@ public function testPublishedWebPRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(Image::class, $generatedWebP); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-webp.webp.webp', 'WebP Variant was not generated as expected'); - //Publish the file + // Publish the file $img->publishSingle(); $this->assertFileExists(TestAssetStore::base_path() . '/folder/wbg-logo-webp.webp', 'Orginal was not moved as expected'); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $renderedTemplate = $img->forTemplate(); - //Make sure the picture tag does not exit + // Make sure the picture tag does not exit $this->assertStringNotContainsString('', $renderedTemplate); $this->assertStringNotContainsString(']+)>/', $renderedTemplate, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError()); @@ -220,33 +220,33 @@ public function testDraftWebPRender() /** @var Image|\WebbuildersGroup\NextGenImages\Extensions\ImageExtension $img **/ $img = $this->objFromFixture(Image::class, 'testwebp'); - //Sanity Check + // Sanity Check $this->assertNotEmpty($img); $this->assertNotFalse($img); $this->assertTrue($img->exists()); - //Attempt to generate the WebP + // Attempt to generate the WebP $generatedWebP = $img->getWebP(); $this->assertInstanceOf(Image::class, $generatedWebP); $this->assertFileDoesNotExist(TestAssetStore::base_path() . '/.protected/folder/' . substr($img->FileHash, 0, HashFileIDHelper::HASH_TRUNCATE_LENGTH) . '/wbg-logo-webp.webp.webp', 'WebP Variant was not generated as expected'); - //Render the file as if it was being used in the template + // Render the file as if it was being used in the template $renderedTemplate = $img->forTemplate(); - //Make sure the picture tag does not exit + // Make sure the picture tag does not exit $this->assertStringNotContainsString('', $renderedTemplate); $this->assertStringNotContainsString(']+)>/', $renderedTemplate, 'Could not fine the tag pointing to the original image'); - //Make sure we can hit the original file + // Make sure we can hit the original file $response = $this->get(Director::makeRelative(str_replace('/TemplateRendering/', '/', $originalURL))); $this->assertEquals(200, $response->getStatusCode()); $this->assertFalse($response->isError());