TYPO3 CMS  TYPO3_8-7
CoreUpdateServiceTest.php
Go to the documentation of this file.
1 <?php
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 
20 class CoreUpdateServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
25  public function getMessagesReturnsPreviouslySetMessage()
26  {
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 
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  }
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 
52  public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet()
53  {
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 
64  public function isCoreUpdateEnabledReturnsFalseFor_REDIRECT_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet()
65  {
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 
76  public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_COMPOSER_MODE_EnvironmentVariableSet()
77  {
78  if (!defined('TYPO3_COMPOSER_MODE')) {
79  putenv('TYPO3_COMPOSER_MODE=1');
80  }
82  $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
83  $this->assertFalse($instance->isCoreUpdateEnabled());
84  }
85 }