2018-07-04 23:37:22 +02:00
|
|
|
<?php
|
|
|
|
|
2018-07-05 20:57:31 +02:00
|
|
|
namespace Friendica\Test\src\Core\Lock;
|
2018-07-04 23:37:22 +02:00
|
|
|
|
2019-08-03 20:48:56 +02:00
|
|
|
use Dice\Dice;
|
|
|
|
use Friendica\App;
|
|
|
|
use Friendica\BaseObject;
|
|
|
|
use Friendica\Core\Config\Configuration;
|
2018-07-04 23:37:22 +02:00
|
|
|
use Friendica\Core\Lock\SemaphoreLockDriver;
|
|
|
|
|
|
|
|
class SemaphoreLockDriverTest extends LockTest
|
|
|
|
{
|
2019-01-30 20:26:17 +01:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2019-08-03 20:48:56 +02:00
|
|
|
$dice = \Mockery::mock(Dice::class)->makePartial();
|
2019-02-07 20:44:03 +01:00
|
|
|
|
2019-08-03 20:48:56 +02:00
|
|
|
$app = \Mockery::mock(App::class);
|
|
|
|
$app->shouldReceive('getHostname')->andReturn('friendica.local');
|
|
|
|
$dice->shouldReceive('create')->with(App::class)->andReturn($app);
|
|
|
|
|
|
|
|
$configMock = \Mockery::mock(Configuration::class);
|
|
|
|
$configMock
|
2019-02-07 20:44:03 +01:00
|
|
|
->shouldReceive('get')
|
2019-08-03 20:48:56 +02:00
|
|
|
->with('system', 'temppath', NULL, false)
|
2019-02-07 20:44:03 +01:00
|
|
|
->andReturn('/tmp/');
|
2019-08-03 20:48:56 +02:00
|
|
|
$dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
|
|
|
|
|
|
|
|
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
|
|
|
|
BaseObject::setDependencyInjection($dice);
|
2019-01-30 20:26:17 +01:00
|
|
|
}
|
|
|
|
|
2018-07-04 23:37:22 +02:00
|
|
|
protected function getInstance()
|
|
|
|
{
|
2018-09-05 22:16:23 +02:00
|
|
|
return new SemaphoreLockDriver();
|
2018-07-04 23:37:22 +02:00
|
|
|
}
|
2018-07-07 19:46:16 +02:00
|
|
|
|
|
|
|
function testLockTTL()
|
|
|
|
{
|
|
|
|
// Semaphore doesn't work with TTL
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-07 16:15:03 +02:00
|
|
|
}
|