mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 04:05:16 +02:00
Replace api.yml to api.fixture.php
- Remove yaml dependency - Add PHP array based fixture possibility
This commit is contained in:
parent
b08ac3c0a7
commit
df9ebf5e8e
7 changed files with 278 additions and 281 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Friendica\Test;
|
||||
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Test\Util\Database\StaticDatabase;
|
||||
|
||||
/**
|
||||
|
@ -30,4 +31,30 @@ abstract class DatabaseTest extends MockedTest
|
|||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a given DB fixture for this DB test
|
||||
*
|
||||
* @param string $fixture The path to the fixture
|
||||
* @param Database $dba The DB connection
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function loadFixture(string $fixture, Database $dba)
|
||||
{
|
||||
$this->assertFileExists($fixture);
|
||||
|
||||
$data = include $fixture;
|
||||
|
||||
foreach ($data as $tableName => $rows) {
|
||||
if (!is_array($rows)) {
|
||||
$dba->p('TRUNCATE TABLE `' . $tableName . '``');
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$dba->insert($tableName, $row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue