Skip to content

Commit

Permalink
Merge pull request #19 from netlogix/automated-apply-coding-standards
Browse files Browse the repository at this point in the history
  • Loading branch information
saschanowak authored Dec 5, 2023
2 parents cdc3c79 + 454f2a0 commit 793eafc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
5 changes: 2 additions & 3 deletions Classes/EventListener/WebpCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Netlogix\Nximageoptimizer\EventListener;

use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
use TYPO3\CMS\Core\Resource\Event\AfterFileProcessingEvent;
use TYPO3\CMS\Core\Resource\ProcessedFile;
Expand Down Expand Up @@ -37,9 +38,7 @@ public function createWebpVersion(AfterFileProcessingEvent $event): void
$this->createWebpImage($event->getProcessedFile(), $event->getDriver());
}

/**
* @codeCoverageIgnore This method is only used for substitution in tests
*/
#[CodeCoverageIgnore]
protected function isCwebpInstalled(): bool
{
return (bool) CommandUtility::checkCommand('cwebp');
Expand Down
8 changes: 5 additions & 3 deletions Tests/Unit/EventListener/ImageOptimizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class ImageOptimizerTest extends UnitTestCase
{
public function tearDown(): void
protected function tearDown(): void
{
unset($GLOBALS['TYPO3_REQUEST']);
parent::tearDown();
Expand All @@ -31,7 +31,7 @@ public function tearDown(): void
public function constructShouldSetConfiguration(): void
{
$configuration = [
'disableAutomaticWebpCreation' => 0
'disableAutomaticWebpCreation' => 0,
];

$container = $this->initContainer();
Expand Down Expand Up @@ -192,7 +192,9 @@ public function execShouldLogOutputToErrorLog(): void
$logger = $this->createMock(LoggerInterface::class);
$logger->expects(self::once())
->method('error')
->with('sample output', ['command' => 'echo "sample output"']);
->with('sample output', [
'command' => 'echo "sample output"',
]);

$subject = $this->getAccessibleMock(ImageOptimizer::class, null);
$subject->setLogger($logger);
Expand Down
15 changes: 6 additions & 9 deletions Tests/Unit/EventListener/WebpCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function createWebpVersionShouldNotCreateWebpImageIfDisabledViaConfigurat
{
$container = $this->initContainer();
$container->set(ExtensionConfiguration::class, $this->getExtensionConfigurationMock([
'disableAutomaticWebpCreation' => 1
'disableAutomaticWebpCreation' => 1,
]));

$subject = $this->getAccessibleMock(WebpCreator::class, ['createWebpImage']);
Expand All @@ -48,7 +48,7 @@ public function createWebpVersionShouldNotCreateWebpImageIfNotEnabled(): void
{
$container = $this->initContainer();
$container->set(ExtensionConfiguration::class, $this->getExtensionConfigurationMock([
'disableAutomaticWebpCreation' => 0
'disableAutomaticWebpCreation' => 0,
]));

$subject = $this->getAccessibleMock(WebpCreator::class, ['isEnabled', 'createWebpImage']);
Expand Down Expand Up @@ -76,7 +76,7 @@ public function createWebpVersionShouldNotCreateWebpImageIfSourceImageTypeIsNotS
{
$container = $this->initContainer();
$container->set(ExtensionConfiguration::class, $this->getExtensionConfigurationMock([
'disableAutomaticWebpCreation' => 0
'disableAutomaticWebpCreation' => 0,
]));

$subject = $this->getAccessibleMock(WebpCreator::class, ['isEnabled', 'createWebpImage']);
Expand Down Expand Up @@ -110,7 +110,7 @@ public function createWebpVersionShouldNotCreateWebpImageIfCwebpIsNotInstalled(s
{
$container = $this->initContainer();
$container->set(ExtensionConfiguration::class, $this->getExtensionConfigurationMock([
'disableAutomaticWebpCreation' => 0
'disableAutomaticWebpCreation' => 0,
]));

$subject = $this->getAccessibleMock(WebpCreator::class, ['isEnabled', 'createWebpImage', 'isCwebpInstalled']);
Expand Down Expand Up @@ -155,7 +155,7 @@ public function createWebpVersionShouldCreateWebpImage(string $mimeType): void
{
$container = $this->initContainer();
$container->set(ExtensionConfiguration::class, $this->getExtensionConfigurationMock([
'disableAutomaticWebpCreation' => 0
'disableAutomaticWebpCreation' => 0,
]));

$subject = $this->getAccessibleMock(WebpCreator::class, ['isEnabled', 'createWebpImage', 'isCwebpInstalled']);
Expand Down Expand Up @@ -192,10 +192,7 @@ public function createWebpVersionShouldCreateWebpImage(string $mimeType): void

public static function mimeTypeDataProvider(): array
{
return [
['image/jpeg'],
['image/png']
];
return [['image/jpeg'], ['image/png']];
}

private function getExtensionConfigurationMock(array $configuration): ExtensionConfiguration
Expand Down
2 changes: 0 additions & 2 deletions Tests/Unit/Service/ImageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

use Netlogix\Nximageoptimizer\Service\ImageService;
use PHPUnit\Framework\Attributes\Test;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Extbase\Service\EnvironmentService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class ImageServiceTest extends UnitTestCase
Expand Down

0 comments on commit 793eafc

Please sign in to comment.