Skip to content

Commit

Permalink
[TASK] Code cleanup: Move isComposerMode() function to EnvironmentUti…
Browse files Browse the repository at this point in the history
…lity

And add some unit tests for this
  • Loading branch information
einpraegsam committed Aug 4, 2024
1 parent 48682e0 commit afc99d9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Classes/UserFunc/EnableStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

use Doctrine\DBAL\Exception as ExceptionDbal;
use In2code\Lux\Domain\Model\Visitor;
use In2code\Lux\Utility\ConfigurationUtility;
use In2code\Lux\Utility\DatabaseUtility;
use In2code\Lux\Utility\EnvironmentUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand All @@ -23,8 +23,8 @@ class EnableStatus
public function showEnableStatus(): string
{
$variables = [
'status' => ConfigurationUtility::isComposerMode() && ExtensionManagementUtility::isLoaded('lux'),
'composerMode' => ConfigurationUtility::isComposerMode(),
'status' => EnvironmentUtility::isComposerMode() && ExtensionManagementUtility::isLoaded('lux'),
'composerMode' => EnvironmentUtility::isComposerMode(),
'enabled' => [
'lux' => ExtensionManagementUtility::isLoaded('lux'),
'luxenterprise' => ExtensionManagementUtility::isLoaded('luxenterprise'),
Expand Down
5 changes: 0 additions & 5 deletions Classes/Utility/ConfigurationUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ public static function isWorkflowModuleDisabled(): bool
return $extensionConfig['disableWorkflowModule'] === '1';
}

public static function isComposerMode(): bool
{
return defined('TYPO3_COMPOSER_MODE');
}

/**
* Get extension configuration from LocalConfiguration.php
*
Expand Down
5 changes: 5 additions & 0 deletions Classes/Utility/EnvironmentUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ public static function isCli(): bool
{
return Environment::isCli();
}

public static function isComposerMode(): bool
{
return defined('TYPO3_COMPOSER_MODE');
}
}
48 changes: 48 additions & 0 deletions Tests/Unit/Utility/EnvironmentUtilityTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace In2code\Lux\Tests\Unit\Utility;

use In2code\Lux\Utility\EnvironmentUtility;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* @coversDefaultClass \In2code\Lux\Utility\EnvironmentUtility
*/
class EnvironmentUtilityTest extends UnitTestCase
{
/**
* @return void
* @covers ::isFrontend
*/
public function testIsFrontend(): void
{
self::assertFalse(EnvironmentUtility::isFrontend());
}

/**
* @return void
* @covers ::isBackend
*/
public function testIsBackend(): void
{
self::assertFalse(EnvironmentUtility::isBackend());
}

/**
* @return void
* @covers ::isCli
*/
public function testIsCli(): void
{
self::assertTrue(EnvironmentUtility::isCli());
}

/**
* @return void
* @covers ::isComposerMode
*/
public function testIsComposerMode(): void
{
self::assertTrue(EnvironmentUtility::isComposerMode());
}
}

0 comments on commit afc99d9

Please sign in to comment.