-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Remove dependency from constant TYPO3_MODE in page renderer hook
- Loading branch information
1 parent
c6d02c5
commit b8ef367
Showing
4 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Brotkrueml\Schema\Context; | ||
|
||
class Typo3Mode | ||
{ | ||
/** @var string */ | ||
private $mode; | ||
|
||
public function __construct() | ||
{ | ||
$this->mode = \defined('TYPO3_MODE') ? TYPO3_MODE : ''; | ||
} | ||
|
||
public function isInBackendMode(): bool | ||
{ | ||
return $this->mode === 'BE'; | ||
} | ||
|
||
public function isInFrontendMode(): bool | ||
{ | ||
return $this->mode === 'FE'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Brotkrueml\Schema\Tests\Unit\Context; | ||
|
||
use Brotkrueml\Schema\Context\Typo3Mode; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @runTestsInSeparateProcesses | ||
* @coversDefaultClass \Brotkrueml\Schema\Context\Typo3Mode | ||
*/ | ||
class Typo3ModeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @covers ::isInBackendMode | ||
*/ | ||
public function isInBackendModeReturnsFalseWhenConstantIsNotDefined(): void | ||
{ | ||
$subject = new Typo3Mode(); | ||
|
||
self::assertFalse($subject->isInBackendMode()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::isInBackendMode | ||
*/ | ||
public function isInBackendModeReturnsFalseWhenConstantIsSetToFE(): void | ||
{ | ||
\define('TYPO3_MODE', 'FE'); | ||
|
||
$subject = new Typo3Mode(); | ||
|
||
self::assertFalse($subject->isInBackendMode()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::isInBackendMode | ||
*/ | ||
public function isInBackendModeReturnsTrueWhenConstantIsSetToBE(): void | ||
{ | ||
\define('TYPO3_MODE', 'BE'); | ||
|
||
$subject = new Typo3Mode(); | ||
|
||
self::assertTrue($subject->isInBackendMode()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::isInFrontendMode | ||
*/ | ||
public function isInFrontendModeReturnsFalseWhenConstantIsNotDefined(): void | ||
{ | ||
$subject = new Typo3Mode(); | ||
|
||
self::assertFalse($subject->isInFrontendMode()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::isInFrontendMode | ||
*/ | ||
public function isInFrontendModeReturnsFalseWhenConstantIsSetToBE(): void | ||
{ | ||
\define('TYPO3_MODE', 'BE'); | ||
|
||
$subject = new Typo3Mode(); | ||
|
||
self::assertFalse($subject->isInFrontendMode()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::isInFrontendMode | ||
*/ | ||
public function isInFrontendModeReturnsTrueWhenConstantIsSetToFE(): void | ||
{ | ||
\define('TYPO3_MODE', 'FE'); | ||
|
||
$subject = new Typo3Mode(); | ||
|
||
self::assertTrue($subject->isInFrontendMode()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters