]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Lock/SemaphoreLockTest.php
Rename *CacheDriver to *Cache because they don't act as driver anymore
[friendica.git] / tests / src / Core / Lock / SemaphoreLockTest.php
1 <?php
2
3 namespace Friendica\Test\src\Core\Lock;
4
5 use Dice\Dice;
6 use Friendica\App;
7 use Friendica\BaseObject;
8 use Friendica\Core\Config\Configuration;
9 use Friendica\Core\Lock\SemaphoreLock;
10
11 class SemaphoreLockTest extends LockTest
12 {
13         public function setUp()
14         {
15                 parent::setUp();
16
17                 $dice = \Mockery::mock(Dice::class)->makePartial();
18
19                 $app = \Mockery::mock(App::class);
20                 $app->shouldReceive('getHostname')->andReturn('friendica.local');
21                 $dice->shouldReceive('create')->with(App::class)->andReturn($app);
22
23                 $configMock = \Mockery::mock(Configuration::class);
24                 $configMock
25                         ->shouldReceive('get')
26                         ->with('system', 'temppath', NULL, false)
27                         ->andReturn('/tmp/');
28                 $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
29
30                 // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
31                 BaseObject::setDependencyInjection($dice);
32         }
33
34         protected function getInstance()
35         {
36                 return new SemaphoreLock();
37         }
38
39         function testLockTTL()
40         {
41                 // Semaphore doesn't work with TTL
42                 return true;
43         }
44 }