Refactor dynamic segments listings to doctrine
[MAILPOET-3361]
This commit is contained in:
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\API\JSON\ResponseBuilders;
|
||||||
|
|
||||||
|
use MailPoet\Entities\SegmentEntity;
|
||||||
|
use MailPoet\Entities\SubscriberEntity;
|
||||||
|
use MailPoet\Segments\SegmentSubscribersRepository;
|
||||||
|
use MailPoet\WP\Functions;
|
||||||
|
|
||||||
|
class DynamicSegmentsResponseBuilder {
|
||||||
|
const DATE_FORMAT = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
/** @var SegmentsResponseBuilder */
|
||||||
|
private $segmentsResponseBuilder;
|
||||||
|
|
||||||
|
/** @var Functions */
|
||||||
|
private $wp;
|
||||||
|
|
||||||
|
/** @var SegmentSubscribersRepository */
|
||||||
|
private $segmentSubscriberRepository;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
Functions $wp,
|
||||||
|
SegmentSubscribersRepository $segmentSubscriberRepository,
|
||||||
|
SegmentsResponseBuilder $segmentsResponseBuilder
|
||||||
|
) {
|
||||||
|
$this->segmentsResponseBuilder = $segmentsResponseBuilder;
|
||||||
|
$this->segmentSubscriberRepository = $segmentSubscriberRepository;
|
||||||
|
$this->wp = $wp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildForListing(array $segments): array {
|
||||||
|
$data = [];
|
||||||
|
foreach ($segments as $segment) {
|
||||||
|
$data[] = $this->buildListingItem($segment);
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildListingItem(SegmentEntity $segment): array {
|
||||||
|
$data = $this->segmentsResponseBuilder->build($segment);
|
||||||
|
$data['subscribers_url'] = $this->wp->adminUrl(
|
||||||
|
'admin.php?page=mailpoet-subscribers#/filter[segment=' . $segment->getId() . ']'
|
||||||
|
);
|
||||||
|
$data['count_all'] = $this->segmentSubscriberRepository->getSubscribersCount((int)$segment->getId());
|
||||||
|
$data['count_subscribed'] = $this->segmentSubscriberRepository->getSubscribersCount((int)$segment->getId(), SubscriberEntity::STATUS_SUBSCRIBED);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ namespace MailPoet\API\JSON\v1;
|
|||||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||||
use MailPoet\API\JSON\Error;
|
use MailPoet\API\JSON\Error;
|
||||||
use MailPoet\API\JSON\Response;
|
use MailPoet\API\JSON\Response;
|
||||||
|
use MailPoet\API\JSON\ResponseBuilders\DynamicSegmentsResponseBuilder;
|
||||||
use MailPoet\Config\AccessControl;
|
use MailPoet\Config\AccessControl;
|
||||||
use MailPoet\DynamicSegments\Exceptions\ErrorSavingException;
|
use MailPoet\DynamicSegments\Exceptions\ErrorSavingException;
|
||||||
use MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException;
|
use MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException;
|
||||||
@ -12,11 +13,10 @@ use MailPoet\DynamicSegments\Mappers\DBMapper;
|
|||||||
use MailPoet\DynamicSegments\Mappers\FormDataMapper;
|
use MailPoet\DynamicSegments\Mappers\FormDataMapper;
|
||||||
use MailPoet\DynamicSegments\Persistence\Loading\SingleSegmentLoader;
|
use MailPoet\DynamicSegments\Persistence\Loading\SingleSegmentLoader;
|
||||||
use MailPoet\DynamicSegments\Persistence\Saver;
|
use MailPoet\DynamicSegments\Persistence\Saver;
|
||||||
use MailPoet\Entities\SubscriberEntity;
|
|
||||||
use MailPoet\Listing\BulkActionController;
|
use MailPoet\Listing\BulkActionController;
|
||||||
use MailPoet\Listing\Handler;
|
use MailPoet\Listing\Handler;
|
||||||
use MailPoet\Models\Model;
|
use MailPoet\Models\Model;
|
||||||
use MailPoet\Segments\SegmentSubscribersRepository;
|
use MailPoet\Segments\DynamicSegments\DynamicSegmentsListingRepository;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
class DynamicSegments extends APIEndpoint {
|
class DynamicSegments extends APIEndpoint {
|
||||||
@ -40,13 +40,17 @@ class DynamicSegments extends APIEndpoint {
|
|||||||
/** @var Handler */
|
/** @var Handler */
|
||||||
private $listingHandler;
|
private $listingHandler;
|
||||||
|
|
||||||
/** @var SegmentSubscribersRepository */
|
/** @var DynamicSegmentsListingRepository */
|
||||||
private $segmentSubscriberRepository;
|
private $dynamicSegmentsListingRepository;
|
||||||
|
|
||||||
|
/** @var DynamicSegmentsResponseBuilder */
|
||||||
|
private $segmentsResponseBuilder;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BulkActionController $bulkAction,
|
BulkActionController $bulkAction,
|
||||||
Handler $handler,
|
Handler $handler,
|
||||||
SegmentSubscribersRepository $segmentSubscriberRepository,
|
DynamicSegmentsListingRepository $dynamicSegmentsListingRepository,
|
||||||
|
DynamicSegmentsResponseBuilder $segmentsResponseBuilder,
|
||||||
$mapper = null,
|
$mapper = null,
|
||||||
$saver = null,
|
$saver = null,
|
||||||
$dynamicSegmentsLoader = null
|
$dynamicSegmentsLoader = null
|
||||||
@ -56,7 +60,8 @@ class DynamicSegments extends APIEndpoint {
|
|||||||
$this->mapper = $mapper ?: new FormDataMapper();
|
$this->mapper = $mapper ?: new FormDataMapper();
|
||||||
$this->saver = $saver ?: new Saver();
|
$this->saver = $saver ?: new Saver();
|
||||||
$this->dynamicSegmentsLoader = $dynamicSegmentsLoader ?: new SingleSegmentLoader(new DBMapper());
|
$this->dynamicSegmentsLoader = $dynamicSegmentsLoader ?: new SingleSegmentLoader(new DBMapper());
|
||||||
$this->segmentSubscriberRepository = $segmentSubscriberRepository;
|
$this->dynamicSegmentsListingRepository = $dynamicSegmentsListingRepository;
|
||||||
|
$this->segmentsResponseBuilder = $segmentsResponseBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($data = []) {
|
public function get($data = []) {
|
||||||
@ -192,26 +197,18 @@ class DynamicSegments extends APIEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function listing($data = []) {
|
public function listing($data = []) {
|
||||||
$listingData = $this->listingHandler->get('\MailPoet\Models\DynamicSegment', $data);
|
$definition = $this->listingHandler->getListingDefinition($data);
|
||||||
|
$items = $this->dynamicSegmentsListingRepository->getData($definition);
|
||||||
|
$count = $this->dynamicSegmentsListingRepository->getCount($definition);
|
||||||
|
$filters = $this->dynamicSegmentsListingRepository->getFilters($definition);
|
||||||
|
$groups = $this->dynamicSegmentsListingRepository->getGroups($definition);
|
||||||
|
$segments = $this->segmentsResponseBuilder->buildForListing($items);
|
||||||
|
|
||||||
$data = [];
|
return $this->successResponse($segments, [
|
||||||
foreach ($listingData['items'] as $segment) {
|
'count' => $count,
|
||||||
$segment->subscribersUrl = WPFunctions::get()->adminUrl(
|
'filters' => $filters,
|
||||||
'admin.php?page=mailpoet-subscribers#/filter[segment=' . $segment->id . ']'
|
'groups' => $groups,
|
||||||
);
|
|
||||||
|
|
||||||
$row = $segment->asArray();
|
|
||||||
$row['count_all'] = $this->segmentSubscriberRepository->getSubscribersCount($segment->id);
|
|
||||||
$row['count_subscribed'] = $this->segmentSubscriberRepository->getSubscribersCount($segment->id, SubscriberEntity::STATUS_SUBSCRIBED);
|
|
||||||
$data[] = $row;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->successResponse($data, [
|
|
||||||
'count' => $listingData['count'],
|
|
||||||
'filters' => $listingData['filters'],
|
|
||||||
'groups' => $listingData['groups'],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bulkAction($data = []) {
|
public function bulkAction($data = []) {
|
||||||
|
@ -87,6 +87,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder::class)->setPublic(true);
|
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\FormsResponseBuilder::class);
|
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\FormsResponseBuilder::class);
|
||||||
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\SegmentsResponseBuilder::class)->setPublic(true);
|
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\SegmentsResponseBuilder::class)->setPublic(true);
|
||||||
|
$container->autowire(\MailPoet\API\JSON\ResponseBuilders\DynamicSegmentsResponseBuilder::class)->setPublic(true);
|
||||||
// Automatic emails
|
// Automatic emails
|
||||||
$container->autowire(\MailPoet\AutomaticEmails\AutomaticEmails::class);
|
$container->autowire(\MailPoet\AutomaticEmails\AutomaticEmails::class);
|
||||||
// Config
|
// Config
|
||||||
@ -257,6 +258,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\Segments\SegmentSubscribersRepository::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\SegmentSubscribersRepository::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Segments\SegmentListingRepository::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\SegmentListingRepository::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Segments\SegmentSaveController::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\SegmentSaveController::class)->setPublic(true);
|
||||||
|
$container->autowire(\MailPoet\Segments\DynamicSegments\DynamicSegmentsListingRepository::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Segments\DynamicSegments\FilterHandler::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\DynamicSegments\FilterHandler::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Segments\DynamicSegments\Filters\EmailAction::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\DynamicSegments\Filters\EmailAction::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\Segments\DynamicSegments\Filters\UserRole::class)->setPublic(true);
|
$container->autowire(\MailPoet\Segments\DynamicSegments\Filters\UserRole::class)->setPublic(true);
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Segments\DynamicSegments;
|
||||||
|
|
||||||
|
use MailPoet\Entities\SegmentEntity;
|
||||||
|
use MailPoet\Segments\SegmentListingRepository;
|
||||||
|
|
||||||
|
class DynamicSegmentsListingRepository extends SegmentListingRepository {
|
||||||
|
protected $types = [SegmentEntity::TYPE_DYNAMIC];
|
||||||
|
}
|
@ -15,6 +15,8 @@ class SegmentListingRepository extends ListingRepository {
|
|||||||
/** @var WooCommerce */
|
/** @var WooCommerce */
|
||||||
private $wooCommerce;
|
private $wooCommerce;
|
||||||
|
|
||||||
|
protected $types = [SegmentEntity::TYPE_DEFAULT, SegmentEntity::TYPE_WP_USERS];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $entityManager,
|
EntityManager $entityManager,
|
||||||
WooCommerce $wooCommerce
|
WooCommerce $wooCommerce
|
||||||
@ -50,7 +52,7 @@ class SegmentListingRepository extends ListingRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function applyParameters(QueryBuilder $queryBuilder, array $parameters) {
|
protected function applyParameters(QueryBuilder $queryBuilder, array $parameters) {
|
||||||
$types = [SegmentEntity::TYPE_DEFAULT, SegmentEntity::TYPE_WP_USERS];
|
$types = $this->types;
|
||||||
if ($this->wooCommerce->shouldShowWooCommerceSegment()) {
|
if ($this->wooCommerce->shouldShowWooCommerceSegment()) {
|
||||||
$types[] = SegmentEntity::TYPE_WC_USERS;
|
$types[] = SegmentEntity::TYPE_WC_USERS;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\API\JSON\v1;
|
|||||||
|
|
||||||
use Codeception\Stub;
|
use Codeception\Stub;
|
||||||
use Codeception\Stub\Expected;
|
use Codeception\Stub\Expected;
|
||||||
|
use MailPoet\API\JSON\ResponseBuilders\DynamicSegmentsResponseBuilder;
|
||||||
use MailPoet\DI\ContainerWrapper;
|
use MailPoet\DI\ContainerWrapper;
|
||||||
use MailPoet\DynamicSegments\Exceptions\ErrorSavingException;
|
use MailPoet\DynamicSegments\Exceptions\ErrorSavingException;
|
||||||
use MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException;
|
use MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException;
|
||||||
@ -13,7 +14,7 @@ use MailPoet\Listing\Handler;
|
|||||||
use MailPoet\Models\DynamicSegment;
|
use MailPoet\Models\DynamicSegment;
|
||||||
use MailPoet\Models\DynamicSegmentFilter;
|
use MailPoet\Models\DynamicSegmentFilter;
|
||||||
use MailPoet\Models\Model;
|
use MailPoet\Models\Model;
|
||||||
use MailPoet\Segments\SegmentSubscribersRepository;
|
use MailPoet\Segments\DynamicSegments\DynamicSegmentsListingRepository;
|
||||||
|
|
||||||
class DynamicSegmentsTest extends \MailPoetTest {
|
class DynamicSegmentsTest extends \MailPoetTest {
|
||||||
|
|
||||||
@ -27,14 +28,16 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
|
|
||||||
/** @var Handler */
|
/** @var Handler */
|
||||||
private $listingHandler;
|
private $listingHandler;
|
||||||
|
/** @var DynamicSegmentsListingRepository */
|
||||||
/** @var SegmentSubscribersRepository */
|
private $listingRepository;
|
||||||
private $segmentSubscribersRepository;
|
/** @var DynamicSegmentsResponseBuilder */
|
||||||
|
private $responseBuilder;
|
||||||
|
|
||||||
public function _before() {
|
public function _before() {
|
||||||
$this->bulkAction = ContainerWrapper::getInstance()->get(BulkActionController::class);
|
$this->bulkAction = ContainerWrapper::getInstance()->get(BulkActionController::class);
|
||||||
$this->listingHandler = ContainerWrapper::getInstance()->get(Handler::class);
|
$this->listingHandler = ContainerWrapper::getInstance()->get(Handler::class);
|
||||||
$this->segmentSubscribersRepository = ContainerWrapper::getInstance()->get(SegmentSubscribersRepository::class);
|
$this->listingRepository = ContainerWrapper::getInstance()->get(DynamicSegmentsListingRepository::class);
|
||||||
|
$this->responseBuilder = ContainerWrapper::getInstance()->get(DynamicSegmentsResponseBuilder::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetReturnsResponse() {
|
public function testGetReturnsResponse() {
|
||||||
@ -49,7 +52,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
return $dynamicSegment;
|
return $dynamicSegment;
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, $loader);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, null, null, $loader);
|
||||||
$response = $endpoint->get(['id' => 5]);
|
$response = $endpoint->get(['id' => 5]);
|
||||||
expect($response)->isInstanceOf('\MailPoet\API\JSON\SuccessResponse');
|
expect($response)->isInstanceOf('\MailPoet\API\JSON\SuccessResponse');
|
||||||
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
||||||
@ -69,7 +72,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
throw new \InvalidArgumentException('segment not found');
|
throw new \InvalidArgumentException('segment not found');
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, $loader);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, null, null, $loader);
|
||||||
$response = $endpoint->get(['id' => 5]);
|
$response = $endpoint->get(['id' => 5]);
|
||||||
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
||||||
expect($response->status)->equals(self::SEGMENT_NOT_FOUND_RESPONSE_CODE);
|
expect($response->status)->equals(self::SEGMENT_NOT_FOUND_RESPONSE_CODE);
|
||||||
@ -86,7 +89,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
})]);
|
})]);
|
||||||
$saver = Stub::makeEmpty('\MailPoet\DynamicSegments\Persistence\Saver', ['save' => Expected::once()]);
|
$saver = Stub::makeEmpty('\MailPoet\DynamicSegments\Persistence\Saver', ['save' => Expected::once()]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, $mapper, $saver);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, $mapper, $saver);
|
||||||
$response = $endpoint->save([]);
|
$response = $endpoint->save([]);
|
||||||
expect($response)->isInstanceOf('\MailPoet\API\JSON\SuccessResponse');
|
expect($response)->isInstanceOf('\MailPoet\API\JSON\SuccessResponse');
|
||||||
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
||||||
@ -98,7 +101,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
})]);
|
})]);
|
||||||
$saver = Stub::makeEmpty('\MailPoet\DynamicSegments\Persistence\Saver', ['save' => Expected::never()]);
|
$saver = Stub::makeEmpty('\MailPoet\DynamicSegments\Persistence\Saver', ['save' => Expected::never()]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, $mapper, $saver);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, $mapper, $saver);
|
||||||
$response = $endpoint->save([]);
|
$response = $endpoint->save([]);
|
||||||
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
||||||
expect($response->status)->equals(self::INVALID_DATA_RESPONSE_CODE);
|
expect($response->status)->equals(self::INVALID_DATA_RESPONSE_CODE);
|
||||||
@ -117,7 +120,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
throw new ErrorSavingException('Error saving data', Model::DUPLICATE_RECORD);
|
throw new ErrorSavingException('Error saving data', Model::DUPLICATE_RECORD);
|
||||||
})]);
|
})]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, $mapper, $saver);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, $mapper, $saver);
|
||||||
$response = $endpoint->save([]);
|
$response = $endpoint->save([]);
|
||||||
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse');
|
||||||
expect($response->status)->equals(self::SERVER_ERROR_RESPONSE_CODE);
|
expect($response->status)->equals(self::SERVER_ERROR_RESPONSE_CODE);
|
||||||
@ -136,7 +139,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, $loader);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, null, null, $loader);
|
||||||
$response = $endpoint->trash(['id' => $dynamicSegment->id]);
|
$response = $endpoint->trash(['id' => $dynamicSegment->id]);
|
||||||
|
|
||||||
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
||||||
@ -161,7 +164,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, $loader);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, null, null, $loader);
|
||||||
$response = $endpoint->restore(['id' => $dynamicSegment->id]);
|
$response = $endpoint->restore(['id' => $dynamicSegment->id]);
|
||||||
|
|
||||||
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
||||||
@ -189,7 +192,7 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, $loader);
|
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->listingRepository, $this->responseBuilder, null, null, $loader);
|
||||||
$response = $endpoint->delete(['id' => $dynamicSegment->id]);
|
$response = $endpoint->delete(['id' => $dynamicSegment->id]);
|
||||||
|
|
||||||
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE);
|
||||||
@ -214,7 +217,15 @@ class DynamicSegmentsTest extends \MailPoetTest {
|
|||||||
'segment_id' => $dynamicSegment1->id,
|
'segment_id' => $dynamicSegment1->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$endpoint = new DynamicSegments($this->bulkAction, $this->listingHandler, $this->segmentSubscribersRepository, null, null, null);
|
$endpoint = new DynamicSegments(
|
||||||
|
$this->bulkAction,
|
||||||
|
$this->listingHandler,
|
||||||
|
$this->listingRepository,
|
||||||
|
$this->responseBuilder,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
);
|
||||||
$response = $endpoint->bulkAction([
|
$response = $endpoint->bulkAction([
|
||||||
'action' => 'trash',
|
'action' => 'trash',
|
||||||
'listing' => ['group' => 'all'],
|
'listing' => ['group' => 'all'],
|
||||||
|
Reference in New Issue
Block a user