Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Jul 28, 2024
1 parent 26b19f2 commit c8cf12d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 38 deletions.
27 changes: 0 additions & 27 deletions src/Auditor/ForeignKeyReferencedColumnExistenceMysqlAuditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,12 @@

namespace Orisai\DbAudit\Auditor;

use Dibi\Connection as DibiConnection;
use Generator;
use Nextras\Dbal\Connection as NextrasConnection;
use Orisai\DbAudit\Dbal\DibiAdapter;
use Orisai\DbAudit\Dbal\NextrasAdapter;
use Orisai\DbAudit\Report\ColumnViolationSource;
use Orisai\DbAudit\Report\Violation;
use Tests\Orisai\DbAudit\Helper\MysqlConnectionConfig;

final class ForeignKeyReferencedColumnExistenceMysqlAuditor extends ForeignKeyReferencedColumnExistenceAuditor
{

public function provide(): Generator
{
$config = new MysqlConnectionConfig(
'127.0.0.1',
'root',
'root',
(int) '3306',
);

yield [
new DibiAdapter(new DibiConnection($config->toDibi())),
];

yield [
new NextrasAdapter(new NextrasConnection($config->toNextras())),
];
}

/**
* @dataProvider provide
*/
public function analyse(): array
{
$records = $this->getRecords();
Expand Down
25 changes: 14 additions & 11 deletions tests/Integration/Dbal/DbalAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use DateTime;
use DateTimeImmutable;
use Dibi\Connection as DibiConnection;
use Generator;
use Nextras\Dbal\Connection as NextrasConnection;
use Orisai\DbAudit\Dbal\DbalAdapter;
use Orisai\DbAudit\Dbal\DibiAdapter;
Expand All @@ -16,28 +15,32 @@
final class DbalAdapterTest extends TestCase
{

public function provide(): Generator
private function getConfig(): MysqlConnectionConfig
{
$config = new MysqlConnectionConfig(
return new MysqlConnectionConfig(
'127.0.0.1',
'root',
'root',
(int) '3306',
);
}

yield [
new DibiAdapter(new DibiConnection($config->toDibi())),
];
public function testDibi(): void
{
$dbal = new DibiAdapter(new DibiConnection($this->getConfig()->toDibi()));
$this->testInternal($dbal);
}

yield [
new NextrasAdapter(new NextrasConnection($config->toNextras())),
];
public function testNextras(): void
{
$dbal = new NextrasAdapter(new NextrasConnection($this->getConfig()->toNextras()));
$this->testInternal($dbal);
}

/**
* @dataProvider provide
* Workaround for code coverage not working in providers
*/
public function test(DbalAdapter $dbal): void
private function testInternal(DbalAdapter $dbal): void
{
$query = $dbal->query('SELECT version() as version;');

Expand Down

0 comments on commit c8cf12d

Please sign in to comment.