Files
piratepoet/tests/acceptance/DisplayFormBellowPostCest.php
Rostislav Wolny 82d2784ed0 Get rid of magic _inject in acceptance tests
After updating to Codeception v4 inject doesn't work since services in DI needs WP to be loaded.
Injecting data factories is also not recommended practice since they are not designed to work as singleton and may that test influence each other and cause some flakiness.
[MAILPOET-2973]
2020-08-04 14:33:14 +02:00

48 lines
1.3 KiB
PHP

<?php
namespace MailPoet\Test\Acceptance;
use MailPoet\Test\DataFactories\Form;
use MailPoet\Test\DataFactories\Segment;
class DisplayFormBellowPostCest {
/** @var Segment */
private $segments;
/** @var Form */
private $forms;
public function _before() {
$this->segments = new Segment();
$this->forms = new Form();
}
public function displayForm(\AcceptanceTester $i) {
$i->wantTo('Test form rendering bellow posts');
$segmentName = 'Fancy List';
$segment = $this->segments->withName($segmentName)->create();
$formName = 'My fancy form';
$this->forms->withName($formName)->withSegments([$segment])->create();
$postTitle = 'Lorem';
$i->login();
$i->amOnMailPoetPage('Forms');
$i->waitForText($formName);
$i->clickItemRowActionByItemName($formName, 'Edit');
$i->waitForElement('[data-automation-id="form_title_input"]');
$i->click('.form-sidebar-form-placement-panel');
$i->click('[data-automation-id="form-placement-option-Below pages"]');
$i->checkOption('Display on all posts');
$i->saveFormInEditor();
// see the post
$postUrl = $i->createPost($postTitle, 'Content');
$i->amOnUrl($postUrl);
$i->waitForText($postTitle);
$i->seeElement('[data-automation-id="subscribe-submit-button"]');
}
}