-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getting table name when the table schema is an empty string (#617)
- Loading branch information
1 parent
0e5091b
commit a38edf4
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\EntityAuditBundle\Tests; | ||
|
||
use Doctrine\ORM\Mapping\ClassMetadata; | ||
use PHPUnit\Framework\TestCase; | ||
use SimpleThings\EntityAudit\AuditConfiguration; | ||
use Sonata\EntityAuditBundle\Tests\Fixtures\Core\ArticleAudit; | ||
|
||
final class AuditConfigurationTest extends TestCase | ||
{ | ||
public function testItReturnsCorrectTableNameWhenTableSchemaIsNull(): void | ||
{ | ||
$auditConfig = new AuditConfiguration(); | ||
|
||
$metadata = new ClassMetadata(ArticleAudit::class); | ||
$metadata->setPrimaryTable([ | ||
'name' => 'foo', | ||
'schema' => null, | ||
]); | ||
|
||
static::assertSame('foo_audit', $auditConfig->getTableName($metadata)); | ||
} | ||
|
||
public function testItReturnsCorrectTableNameWhenTableSchemaIsEmptyString(): void | ||
{ | ||
$auditConfig = new AuditConfiguration(); | ||
|
||
$metadata = new ClassMetadata(ArticleAudit::class); | ||
$metadata->setPrimaryTable([ | ||
'name' => 'foo', | ||
'schema' => '', | ||
]); | ||
|
||
static::assertSame('foo_audit', $auditConfig->getTableName($metadata)); | ||
} | ||
|
||
public function testItReturnsCorrectTableNameWhenTableSchemaIsSet(): void | ||
{ | ||
$auditConfig = new AuditConfiguration(); | ||
|
||
$metadata = new ClassMetadata(ArticleAudit::class); | ||
$metadata->setPrimaryTable([ | ||
'name' => 'foo', | ||
'schema' => 'xyz', | ||
]); | ||
|
||
static::assertSame('xyz.foo_audit', $auditConfig->getTableName($metadata)); | ||
} | ||
} |