‪TYPO3CMS  9.5
LockFactoryTest.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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪LockFactoryTest extends UnitTestCase
29 {
33  protected ‪$mockFactory;
34 
38  protected function ‪setUp()
39  {
40  $this->mockFactory = $this->getAccessibleMock(LockFactory::class, ['dummy']);
41  }
42 
47  {
48  $this->mockFactory->addLockingStrategy(DummyLock::class);
49  $this->assertArrayHasKey(DummyLock::class, $this->mockFactory->_get('lockingStrategy'));
50  }
51 
56  {
57  $this->expectException(\InvalidArgumentException::class);
58  $this->expectExceptionCode(1425990198);
59 
60  $this->mockFactory->addLockingStrategy(\stdClass::class);
61  }
62 
66  public function ‪getLockerReturnsExpectedClass()
67  {
68  $this->mockFactory->_set('lockingStrategy', [FileLockStrategy::class => true, DummyLock::class => true]);
70  $this->assertInstanceOf(FileLockStrategy::class, $locker);
71  }
72 
77  {
78  $this->mockFactory->_set('lockingStrategy', [SemaphoreLockStrategy::class => true, DummyLock::class => true]);
79  $locker = $this->mockFactory->createLocker('id');
80  $this->assertInstanceOf(DummyLock::class, $locker);
81  }
82 
87  {
88  $this->expectException(LockCreateException::class);
89  $this->expectExceptionCode(1425990190);
90 
91  $this->mockFactory->createLocker('id', 32);
92  }
93 }
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\$mockFactory
‪LockFactory PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $mockFactory
Definition: LockFactoryTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\getLockerThrowsExceptionIfNoMatchFound
‪getLockerThrowsExceptionIfNoMatchFound()
Definition: LockFactoryTest.php:85
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\setUp
‪setUp()
Definition: LockFactoryTest.php:37
‪TYPO3\CMS\Core\Locking\LockingStrategyInterface
Definition: LockingStrategyInterface.php:25
‪TYPO3\CMS\Core\Locking\LockingStrategyInterface\LOCK_CAPABILITY_EXCLUSIVE
‪const LOCK_CAPABILITY_EXCLUSIVE
Definition: LockingStrategyInterface.php:29
‪TYPO3\CMS\Core\Locking\SemaphoreLockStrategy
Definition: SemaphoreLockStrategy.php:27
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest
Definition: LockFactoryTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\getLockerReturnsClassWithHighestPriority
‪getLockerReturnsClassWithHighestPriority()
Definition: LockFactoryTest.php:75
‪TYPO3\CMS\Core\Locking\LockingStrategyInterface\LOCK_CAPABILITY_SHARED
‪const LOCK_CAPABILITY_SHARED
Definition: LockingStrategyInterface.php:34
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\addLockingStrategyAddsTheClassNameToTheInternalArray
‪addLockingStrategyAddsTheClassNameToTheInternalArray()
Definition: LockFactoryTest.php:45
‪TYPO3\CMS\Core\Tests\Unit\Locking
Definition: FileLockStrategyTest.php:2
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\addLockingStrategyThrowsExceptionIfInterfaceIsNotImplemented
‪addLockingStrategyThrowsExceptionIfInterfaceIsNotImplemented()
Definition: LockFactoryTest.php:54
‪TYPO3\CMS\Core\Locking\Exception\LockCreateException
Definition: LockCreateException.php:21
‪TYPO3\CMS\Core\Tests\Unit\Locking\Fixtures\DummyLock
Definition: DummyLock.php:23
‪TYPO3\CMS\Core\Locking\LockFactory
Definition: LockFactory.php:24
‪TYPO3\CMS\Core\Locking\FileLockStrategy
Definition: FileLockStrategy.php:28
‪TYPO3\CMS\Core\Tests\Unit\Locking\LockFactoryTest\getLockerReturnsExpectedClass
‪getLockerReturnsExpectedClass()
Definition: LockFactoryTest.php:65