Refactor mailpoet_get_subscribers_listings_in_segment_handlers to direct calls

[MAILPOET-3077]
This commit is contained in:
Rostislav Wolny
2020-09-14 16:37:03 +02:00
committed by Veljko V
parent f9f8428b42
commit 1a56b2534e
6 changed files with 29 additions and 109 deletions

View File

@@ -1,41 +0,0 @@
<?php
namespace MailPoet\DynamicSegments\FreePluginConnectors;
use MailPoet\Models\DynamicSegment;
use MailPoetVendor\Idiorm\ORM;
class SubscribersListingsHandlerFactoryTest extends \MailPoetTest {
public function testItReturnsNullWithUnknownSegment() {
$segment = DynamicSegment::create();
$segment->id = 1;
$segment->name = 'name';
$segment->type = 'unknown';
$listings = new SubscribersListingsHandlerFactory();
$result = $listings->get($segment, ['filter' => ['segment' => null]]);
expect($result)->null();
}
public function testItReturnsDataForDynamicSegment() {
$segment = DynamicSegment::createOrUpdate([
'name' => 'name',
'description' => 'desc',
'type' => DynamicSegment::TYPE_DYNAMIC,
]);
$listings = new SubscribersListingsHandlerFactory();
$result = $listings->get($segment, ['filter' => ['segment' => null]]);
expect($result)->notNull();
}
public function _before() {
$this->cleanData();
}
public function _after() {
$this->cleanData();
}
private function cleanData() {
ORM::raw_execute('TRUNCATE ' . DynamicSegment::$_table);
}
}