[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Service / CoreUpdateServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Service;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class CoreUpdateServiceTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
21 {
22 /**
23 * @test
24 */
25 public function getMessagesReturnsPreviouslySetMessage()
26 {
27 /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\Components\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
28 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
29 $aMessage = $this->getUniqueId('message_');
30 $instance->_set('messages', $aMessage);
31 $this->assertSame($aMessage, $instance->getMessages());
32 }
33
34 /**
35 * @test
36 */
37 public function isCoreUpdateEnabledReturnsTrueForEnvironmentVariableNotSet()
38 {
39 if (defined('TYPO3_COMPOSER_MODE') && TYPO3_COMPOSER_MODE) {
40 $this->markTestSkipped('This test is only available in Non-Composer mode.');
41 }
42 /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\Components\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
43 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
44 putenv('TYPO3_DISABLE_CORE_UPDATER');
45 putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER');
46 $this->assertTrue($instance->isCoreUpdateEnabled());
47 }
48
49 /**
50 * @test
51 */
52 public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet()
53 {
54 /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\Components\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
55 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
56 putenv('TYPO3_DISABLE_CORE_UPDATER=1');
57 putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER');
58 $this->assertFalse($instance->isCoreUpdateEnabled());
59 }
60
61 /**
62 * @test
63 */
64 public function isCoreUpdateEnabledReturnsFalseFor_REDIRECT_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet()
65 {
66 /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\Components\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
67 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
68 putenv('TYPO3_DISABLE_CORE_UPDATER');
69 putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER=1');
70 $this->assertFalse($instance->isCoreUpdateEnabled());
71 }
72
73 /**
74 * @test
75 */
76 public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_COMPOSER_MODE_EnvironmentVariableSet()
77 {
78 if (!defined('TYPO3_COMPOSER_MODE')) {
79 putenv('TYPO3_COMPOSER_MODE=1');
80 }
81 /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\Components\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
82 $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
83 $this->assertFalse($instance->isCoreUpdateEnabled());
84 }
85 }