X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2Fsrc%2FCore%2FLock%2FDatabaseLockDriverTest.php;h=5f3ef13c128e7de90e9c021aed061dbc92fd235e;hb=bc5a1e5acee9ceb61cd08734c554f69850120d76;hp=f55ab0f9e26f54145b9cc28449ac89ed7e087e55;hpb=6cf50a14fae25210a0cdb617c29d549abcfde9ac;p=friendica.git diff --git a/tests/src/Core/Lock/DatabaseLockDriverTest.php b/tests/src/Core/Lock/DatabaseLockDriverTest.php index f55ab0f9e2..5f3ef13c12 100644 --- a/tests/src/Core/Lock/DatabaseLockDriverTest.php +++ b/tests/src/Core/Lock/DatabaseLockDriverTest.php @@ -1,24 +1,62 @@ . + * + */ 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 Psr\Log\NullLogger; class DatabaseLockDriverTest extends LockTest { - protected function getInstance() + use VFSTrait; + use DatabaseTestTrait; + + protected $pid = 123; + + protected function setUp() { - return new DatabaseLockDriver(); + $this->setUpVfsDir(); + + parent::setUp(); } - public function tearDown() + protected function getInstance() { - dba::delete('locks', [ 'id > 0']); - parent::tearDown(); + $logger = new NullLogger(); + $profiler = \Mockery::mock(Profiler::class); + $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 ConfigFileLoader($this->root->url()); + $configCache = $configFactory->createCache($loader); + + $dba = new StaticDatabase($configCache, $profiler, $logger); + + return new DatabaseLock($dba, $this->pid); } }