Skip to content

Commit

Permalink
Merge pull request #175 from dmitryuk/topic/174
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienHarper authored Sep 19, 2023
2 parents a3e5492 + 6d65543 commit a40416e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Provider/Doctrine/Persistence/Schema/SchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public function resolveAuditTableName(string $entity, Configuration $configurati
public function computeAuditTablename(string $entityTableName, Configuration $configuration): ?string
{
return preg_replace(
sprintf('#^([^\.]+\.)?(%s)$#', preg_quote($entityTableName, '#')),
'#^([^.]+\.)?(.+)$#',
sprintf(
'$1%s$2%s',
preg_quote($configuration->getTablePrefix(), '#'),
Expand Down
30 changes: 30 additions & 0 deletions tests/Provider/Doctrine/Issues/Issue174Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace DH\Auditor\Tests\Provider\Doctrine\Issues;

use DH\Auditor\Provider\Doctrine\Configuration;
use DH\Auditor\Provider\Doctrine\Persistence\Schema\SchemaManager;
use DH\Auditor\Tests\Provider\Doctrine\Traits\Schema\DefaultSchemaSetupTrait;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
#[\PHPUnit\Framework\Attributes\Small]
/**
* @internal
*/
final class Issue174Test extends TestCase
{
use DefaultSchemaSetupTrait;

public function testIssue174(): void
{
$configuration = new Configuration(['table_prefix' => 'audit_', 'table_suffix' => '_suffix']);
$manager = new SchemaManager($this->provider);
$result = $manager->computeAuditTablename('schema.entity', $configuration);
self::assertSame('schema.audit_entity_suffix', $result);
}
}

0 comments on commit a40416e

Please sign in to comment.