]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Lock/SemaphoreLockTest.php
Merge pull request #7515 from nupplaphil/task/console_lock
[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                 $dice = \Mockery::mock(Dice::class)->makePartial();
16
17                 $app = \Mockery::mock(App::class);
18                 $app->shouldReceive('getHostname')->andReturn('friendica.local');
19                 $dice->shouldReceive('create')->with(App::class)->andReturn($app);
20
21                 $configMock = \Mockery::mock(Configuration::class);
22                 $configMock
23                         ->shouldReceive('get')
24                         ->with('system', 'temppath', NULL, false)
25                         ->andReturn('/tmp/');
26                 $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
27
28                 // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
29                 BaseObject::setDependencyInjection($dice);
30
31                 parent::setUp();
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 }