wantTo('Create page with shortcode of one subscriber and segment'); $segmentFactory = new Segment(); $segment = $segmentFactory->withName(self::SUBSCRIBER_LIST_NAME)->create(); $subscriberFactory = new Subscriber(); $subscriberFactory->withSegments([$segment])->create(); $pageContent = self::PAGE_TEXT . " [mailpoet_subscribers_count segments={$segment->getId()}]"; $postUrl = $i->createPost(self::PAGE_TITLE, $pageContent); $i->login(); $i->amOnUrl($postUrl); $i->waitForText(self::PAGE_TITLE); $i->waitForText(self::PAGE_TEXT . " 1"); } public function verifySubscribersShortcodeAllCounts(\AcceptanceTester $i) { $i->wantTo('Create page with shortcode of all subscribers but different statuses'); $segmentFactory = new Segment(); $this->segment1 = $segmentFactory->withName(self::SUBSCRIBERS_LIST_NAME_ONE)->create(); $this->segment2 = $segmentFactory->withName(self::SUBSCRIBERS_LIST_NAME_TWO)->create(); $pageContent = self::PAGE_TEXT . " [mailpoet_subscribers_count] segments={$this->segment1->getId()},{$this->segment2->getId()}]"; $postUrl = $i->createPost(self::PAGE_TITLE, $pageContent); $this->prepareSubscribersData($this->segment1, $this->segment2); $i->login(); $i->amOnUrl($postUrl); $i->waitForText(self::PAGE_TITLE); $i->waitForText(self::PAGE_TEXT . " 10"); $i->wantTo('Remove some subscribers and verify the shortcode rendering once again'); $i->amOnMailpoetPage('Subscribers'); $i->waitForElement('[data-automation-id="listing_filter_segment"]'); $i->selectOption('[data-automation-id="listing_filter_segment"]', self::SUBSCRIBERS_LIST_NAME_TWO); $i->waitForElementVisible('[data-automation-id="listing_filter_segment"]'); $i->click('[data-automation-id="select_all"]'); $i->click('[data-automation-id="action-trash"]'); $i->waitForText('11 subscribers were moved to the trash.'); $i->waitForElement('[data-automation-id="filters_trash"]'); $i->click('[data-automation-id="filters_trash"]'); $i->waitForElement('[data-automation-id="empty_trash"]'); $i->click('[data-automation-id="empty_trash"]'); $i->waitForText('11 subscribers were permanently deleted.'); $i->amOnUrl($postUrl); $i->waitForText(self::PAGE_TITLE); $i->waitForText(self::PAGE_TEXT . " 5"); } private function prepareSubscribersData(SegmentEntity $segment1, SegmentEntity $segment2) { for ($i = 0; $i < self::ACTIVE_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withSegments([$segment1])->create(); } for ($i = 0; $i < self::INACTIVE_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withStatus('inactive')->withSegments([$segment1])->create(); } for ($i = 0; $i < self::UNCONFIRMED_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withStatus('unconfirmed')->withSegments([$segment1])->create(); } for ($i = 0; $i < self::UNSUBSCRIBED_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withStatus('unsubscribed')->withSegments([$segment1])->create(); } for ($i = 0; $i < self::BOUNCED_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withStatus('bounced')->withSegments([$segment1])->create(); } for ($i = 0; $i < self::ACTIVE_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withSegments([$segment2])->create(); } for ($i = 0; $i < self::UNSUBSCRIBED_SUBSCRIBERS_COUNT; $i++) { (new Subscriber())->withStatus('unsubscribed')->withSegments([$segment2])->create(); } } }