From bcd33de9ed0261773fdbe5121b46f7c9eebb86b7 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 10 May 2022 10:02:55 -0300 Subject: [PATCH] Use Doctrine entities and truncate only what is used in SubscriberTest This commit replaces old Paris code with Doctrine entities in SubscriberTest::_after() and it also truncate only the entities that are actually used inside the test class. Before this change, the class was unnecessarily truncating entities that were not used. I'm doing this commit as part of task to remove all usages of the old NewsletterOption model and that is why I'm not touching the remaining models in other methods of this class. [MAILPOET-4150] --- .../integration/Models/SubscriberTest.php | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/mailpoet/tests/integration/Models/SubscriberTest.php b/mailpoet/tests/integration/Models/SubscriberTest.php index 22e803676c..164535c5fb 100644 --- a/mailpoet/tests/integration/Models/SubscriberTest.php +++ b/mailpoet/tests/integration/Models/SubscriberTest.php @@ -3,20 +3,17 @@ namespace MailPoet\Test\Models; use Codeception\Util\Fixtures; +use MailPoet\Entities\SegmentEntity; +use MailPoet\Entities\SubscriberCustomFieldEntity; +use MailPoet\Entities\SubscriberEntity; +use MailPoet\Entities\SubscriberSegmentEntity; use MailPoet\Models\CustomField; -use MailPoet\Models\Newsletter; -use MailPoet\Models\NewsletterOption; -use MailPoet\Models\NewsletterOptionField; -use MailPoet\Models\ScheduledTask; use MailPoet\Models\Segment; -use MailPoet\Models\SendingQueue; use MailPoet\Models\Subscriber; use MailPoet\Models\SubscriberCustomField; use MailPoet\Models\SubscriberSegment; use MailPoet\Settings\SettingsController; -use MailPoet\Settings\SettingsRepository; use MailPoetVendor\Carbon\Carbon; -use MailPoetVendor\Idiorm\ORM; class SubscriberTest extends \MailPoetTest { public $saved; @@ -880,16 +877,9 @@ class SubscriberTest extends \MailPoetTest { } public function _after() { - ORM::raw_execute('TRUNCATE ' . Subscriber::$_table); - ORM::raw_execute('TRUNCATE ' . Segment::$_table); - ORM::raw_execute('TRUNCATE ' . SubscriberSegment::$_table); - ORM::raw_execute('TRUNCATE ' . CustomField::$_table); - ORM::raw_execute('TRUNCATE ' . SubscriberCustomField::$_table); - ORM::raw_execute('TRUNCATE ' . Newsletter::$_table); - ORM::raw_execute('TRUNCATE ' . NewsletterOptionField::$_table); - ORM::raw_execute('TRUNCATE ' . NewsletterOption::$_table); - ORM::raw_execute('TRUNCATE ' . ScheduledTask::$_table); - ORM::raw_execute('TRUNCATE ' . SendingQueue::$_table); - $this->diContainer->get(SettingsRepository::class)->truncate(); + $this->truncateEntity(SubscriberEntity::class); + $this->truncateEntity(SegmentEntity::class); + $this->truncateEntity(SubscriberSegmentEntity::class); + $this->truncateEntity(SubscriberCustomFieldEntity::class); } }