Improve table prefixing to allow Doctrine entities for WP tables

WordPress tables use only the DB prefix, but MailPoet tables use
DB prefix + plugin prefix (mailpoet).

This commit changes TablePrefixMetadataFactory to be able to distiguish
WP table for posts and adds proper prefix.
[MAILPOET-5646]
This commit is contained in:
Rostislav Wolny
2023-11-06 16:49:38 +01:00
committed by Aschepikov
parent 1565151179
commit c9c7146ef1
3 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
<?php declare(strict_types = 1);
namespace MailPoet\Doctrine;
use MailPoet\Entities\NewsletterEntity;
use MailPoet\Entities\WpPostEntity;
class TablePrefixMetadataFactoryTest extends \MailPoetTest {
public function testItPrefixTablesCorrectly() {
$wpPostMetadata = $this->entityManager->getClassMetadata(WpPostEntity::class);
$newslettersMetadata = $this->entityManager->getClassMetadata(NewsletterEntity::class);
verify($wpPostMetadata->getTableName())->equals('mp_posts');
verify($newslettersMetadata->getTableName())->equals('mp_mailpoet_newsletters');
}
}