Load dynamic segments for subscribers listing in listing repository
[MAILPOET-3077]
This commit is contained in:
committed by
Veljko V
parent
cd295c7aec
commit
d7e64b6fd0
@ -7,7 +7,6 @@ use MailPoet\API\JSON\Response as APIResponse;
|
||||
use MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder;
|
||||
use MailPoet\API\JSON\v1\Subscribers;
|
||||
use MailPoet\DI\ContainerWrapper;
|
||||
use MailPoet\DynamicSegments\FreePluginConnectors\AddToSubscribersFilters;
|
||||
use MailPoet\Entities\CustomFieldEntity;
|
||||
use MailPoet\Entities\FormEntity;
|
||||
use MailPoet\Entities\NewsletterEntity;
|
||||
@ -48,6 +47,8 @@ use MailPoet\WP\Functions;
|
||||
use MailPoetVendor\Carbon\Carbon;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||
|
||||
class SubscribersTest extends \MailPoetTest {
|
||||
|
||||
/** @var FormEntity */
|
||||
@ -100,8 +101,7 @@ class SubscribersTest extends \MailPoetTest {
|
||||
$container->get(SubscribersRepository::class),
|
||||
$container->get(SubscribersResponseBuilder::class),
|
||||
$container->get(SubscriberListingRepository::class),
|
||||
$obfuscator,
|
||||
$container->get(AddToSubscribersFilters::class)
|
||||
$obfuscator
|
||||
);
|
||||
$this->obfuscatedEmail = $obfuscator->obfuscate('email');
|
||||
$this->obfuscatedSegments = $obfuscator->obfuscate('segments');
|
||||
@ -322,15 +322,26 @@ class SubscribersTest extends \MailPoetTest {
|
||||
$dynamicSegmentFactory = new DynamicSegment();
|
||||
$dynamicSegment = $dynamicSegmentFactory
|
||||
->withName('Dynamic')
|
||||
->withUserRoleFilter('master_of_universe')
|
||||
->withUserRoleFilter('editor')
|
||||
->create();
|
||||
$dynamicSegment->save();
|
||||
$wpUserEmail = 'wpuserEditor@example.com';
|
||||
wp_insert_user([
|
||||
'user_login' => 'user-role-test1',
|
||||
'user_email' => $wpUserEmail,
|
||||
'role' => 'editor',
|
||||
'user_pass' => '12123154',
|
||||
]);
|
||||
$response = $this->endpoint->listing([
|
||||
'filter' => [
|
||||
'segment' => $dynamicSegment->id,
|
||||
],
|
||||
]);
|
||||
expect($response->meta['filters']['segment'])->contains(['value' => $dynamicSegment->id, 'label' => 'Dynamic (0)']);
|
||||
expect($response->meta['filters']['segment'])->contains(['value' => $dynamicSegment->id, 'label' => 'Dynamic (1)']);
|
||||
$user = get_user_by('email', $wpUserEmail);
|
||||
if ($user) {
|
||||
wp_delete_user($user->ID);
|
||||
}
|
||||
}
|
||||
|
||||
public function testItCanSearchListing() {
|
||||
|
Reference in New Issue
Block a user