X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fsrc%2FCore%2FLock%2FDatabaseLockDriverTest.php;h=c51d153efce13da26fdab419995b02449f07fba6;hb=e6c054c27602a3acadac3c423273bdf748fcee27;hp=f55ab0f9e26f54145b9cc28449ac89ed7e087e55;hpb=5f1b5f82ad6d9b816db5c99ff708f706dc39f0bb;p=friendica.git diff --git a/tests/src/Core/Lock/DatabaseLockDriverTest.php b/tests/src/Core/Lock/DatabaseLockDriverTest.php index f55ab0f9e2..c51d153efc 100644 --- a/tests/src/Core/Lock/DatabaseLockDriverTest.php +++ b/tests/src/Core/Lock/DatabaseLockDriverTest.php @@ -1,24 +1,74 @@ . + * + */ namespace Friendica\Test\src\Core\Lock; -use dba; -use Friendica\Core\Lock\DatabaseLockDriver; -use Friendica\Database\DBStructure; -use PHPUnit\DbUnit\DataSet\YamlDataSet; -use PHPUnit\DbUnit\TestCaseTrait; -use PHPUnit_Extensions_Database_DB_IDatabaseConnection; +use Friendica\Core\Lock\DatabaseLock; +use Friendica\Factory\ConfigFactory; +use Friendica\Test\DatabaseTestTrait; +use Friendica\Test\Util\Database\StaticDatabase; +use Friendica\Test\Util\VFSTrait; +use Friendica\Util\ConfigFileLoader; +use Friendica\Util\Profiler; +use Mockery; +use Psr\Log\NullLogger; class DatabaseLockDriverTest extends LockTest { + use VFSTrait; + use DatabaseTestTrait; + + protected $pid = 123; + + protected function setUp(): void + { + $this->setUpVfsDir(); + + $this->setUpDb(); + + parent::setUp(); + } + protected function getInstance() { - return new DatabaseLockDriver(); + $logger = new NullLogger(); + $profiler = Mockery::mock(Profiler::class); + $profiler->shouldReceive('startRecording'); + $profiler->shouldReceive('stopRecording'); + $profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true); + + // load real config to avoid mocking every config-entry which is related to the Database class + $configFactory = new ConfigFactory(); + $loader = (new ConfigFactory())->createConfigFileLoader($this->root->url(), []); + $configCache = $configFactory->createCache($loader); + + $dba = new StaticDatabase($configCache, $profiler, $logger); + + return new DatabaseLock($dba, $this->pid); } - public function tearDown() + protected function tearDown(): void { - dba::delete('locks', [ 'id > 0']); + $this->tearDownDb(); + parent::tearDown(); } }