Fix quality problems
[PREMIUM-38]
This commit is contained in:
@@ -12,7 +12,7 @@ class SubscribersListings {
|
|||||||
if(!isset($data['filter']['segment'])) {
|
if(!isset($data['filter']['segment'])) {
|
||||||
throw new \InvalidArgumentException('Missing segment id');
|
throw new \InvalidArgumentException('Missing segment id');
|
||||||
}
|
}
|
||||||
$segment = Segment::find_one($data['filter']['segment']);
|
$segment = Segment::findOne($data['filter']['segment']);
|
||||||
if($segment) {
|
if($segment) {
|
||||||
$segment = $segment->asArray();
|
$segment = $segment->asArray();
|
||||||
}
|
}
|
||||||
|
6681
package-lock.json
generated
Normal file
6681
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,9 +13,7 @@ use MailPoet\WP\Hooks;
|
|||||||
class SubscribersListingsTest extends \MailPoetTest {
|
class SubscribersListingsTest extends \MailPoetTest {
|
||||||
|
|
||||||
function _before() {
|
function _before() {
|
||||||
\ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
$this->cleanData();
|
||||||
\ORM::raw_execute('TRUNCATE ' . SubscriberSegment::$_table);
|
|
||||||
\ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
|
||||||
$this->segment_1 = Segment::createOrUpdate(array('name' => 'Segment 1', 'type' => 'default'));
|
$this->segment_1 = Segment::createOrUpdate(array('name' => 'Segment 1', 'type' => 'default'));
|
||||||
$this->segment_2 = Segment::createOrUpdate(array('name' => 'Segment 3', 'type' => 'not default'));
|
$this->segment_2 = Segment::createOrUpdate(array('name' => 'Segment 3', 'type' => 'not default'));
|
||||||
$this->subscriber_1 = Subscriber::createOrUpdate(array(
|
$this->subscriber_1 = Subscriber::createOrUpdate(array(
|
||||||
@@ -40,6 +38,16 @@ class SubscribersListingsTest extends \MailPoetTest {
|
|||||||
SubscriberSegment::resubscribeToAllSegments($this->subscriber_2);
|
SubscriberSegment::resubscribeToAllSegments($this->subscriber_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _after() {
|
||||||
|
$this->cleanData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cleanData() {
|
||||||
|
\ORM::raw_execute('TRUNCATE ' . Segment::$_table);
|
||||||
|
\ORM::raw_execute('TRUNCATE ' . SubscriberSegment::$_table);
|
||||||
|
\ORM::raw_execute('TRUNCATE ' . Subscriber::$_table);
|
||||||
|
}
|
||||||
|
|
||||||
function testTryToGetListingsWithoutPassingSegment() {
|
function testTryToGetListingsWithoutPassingSegment() {
|
||||||
$finder = new SubscribersListings();
|
$finder = new SubscribersListings();
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
@@ -75,7 +83,7 @@ class SubscribersListingsTest extends \MailPoetTest {
|
|||||||
expect($listings)->equals('dynamic listings');
|
expect($listings)->equals('dynamic listings');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTryToGetListingsForSegmentWithout() {
|
function testTryToGetListingsForSegmentWithoutHandler() {
|
||||||
$finder = new SubscribersListings();
|
$finder = new SubscribersListings();
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
remove_all_filters('mailpoet_get_subscribers_listings_in_segment_handlers');
|
remove_all_filters('mailpoet_get_subscribers_listings_in_segment_handlers');
|
||||||
|
Reference in New Issue
Block a user