subscriber_email = 'test-form@example.com'; } function _before() { $settings = new Settings(); $settings ->withConfirmationEmailSubject() ->withConfirmationEmailBody() ->withConfirmationEmailEnabled(); } function subscriptionFormWidget(\AcceptanceTester $I) { $form_name = 'Subscription Acceptance Test Form'; $form_factory = new Form(); $form = $form_factory->withName($form_name)->create(); $I->wantTo('Subscribe using form widget'); $I->cli('widget add mailpoet_form sidebar-1 2 --form=' . $form->id . ' --title="Subscribe to Our Newsletter" --allow-root'); //login to avoid time limit for subscribing $I->login(); $I->amOnPage('/'); $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); $I->click('.mailpoet_submit'); $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); $I->seeNoJSErrors(); $I->cli('widget reset sidebar-1 --allow-root'); } function subscriptionFormShortcode(\AcceptanceTester $I) { $I->wantTo('Subscribe using form shortcode'); $I->amOnPage('/form-test'); $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); $I->scrollTo('.mailpoet_submit'); $I->click('.mailpoet_submit'); $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); $I->seeNoJSErrors(); $I->seeCurrentUrlEquals('/form-test/'); } function subscriptionFormIframe(\AcceptanceTester $I) { $I->wantTo('Subscribe using iframe form'); $I->amOnPage('/form-test'); $I->switchToIframe('mailpoet_form_iframe'); $I->fillField('[data-automation-id="form_email"]', $this->subscriber_email); $I->click('.mailpoet_submit'); $I->waitForText('Check your inbox or spam folder to confirm your subscription.', self::CONFIRMATION_MESSAGE_TIMEOUT, '.mailpoet_validate_success'); $I->seeNoJSErrors(); } /** * @depends subscriptionFormWidget */ function subscriptionConfirmation(\AcceptanceTester $I) { $I->amOnMailboxAppPage(); $I->click(Locator::contains('span.subject', 'Confirm your subscription')); $I->switchToIframe('preview-html'); $I->click('Click here to confirm your subscription'); $I->switchToNextTab(); $I->see('You have subscribed'); $I->seeNoJSErrors(); $I->amOnUrl(\AcceptanceTester::WP_URL); $I->login(); $I->amOnMailpoetPage('Subscribers'); $I->waitForText($this->subscriber_email); $I->see('Subscribed', Locator::contains('tr', $this->subscriber_email)); } function _after(\AcceptanceTester $I) { $I->cli('db query "TRUNCATE TABLE mp_mailpoet_subscriber_ips" --allow-root'); } }