[BUGFIX] Multiple fixes for Locking API and TSFE locking
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Locking / FileLockStrategyTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Locking;
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 use TYPO3\CMS\Core\Locking\FileLockStrategy;
18 use TYPO3\CMS\Core\Tests\UnitTestCase;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 /**
22 * Testcase for \TYPO3\CMS\Core\Locking\FileLockStrategy
23 *
24 * @author Markus Klein <klein.t3@reelworx.at>
25 */
26 class FileLockStrategyTest extends UnitTestCase {
27
28 /**
29 * @test
30 */
31 public function constructorCreatesLockDirectoryIfNotExisting() {
32 GeneralUtility::rmdir(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER, TRUE);
33 new FileLockStrategy('999999999');
34 $this->assertTrue(is_dir(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER));
35 }
36
37 /**
38 * @test
39 */
40 public function constructorSetsFilePathToExpectedValue() {
41 $lock = $this->getAccessibleMock(FileLockStrategy::class, ['dummy'], ['999999999']);
42 $this->assertSame(PATH_site . FileLockStrategy::FILE_LOCK_FOLDER . 'flock_' . md5('999999999'), $lock->_get('filePath'));
43 }
44
45 }