Files
piratepoet/tests/_support/AcceptanceTester.php
Michelle Shull 92d0dfc0e1 Merge pull request #1440 from mailpoet/post-notification-template
Acceptance test create post notification template [MQ-38]
2018-07-26 07:39:25 -04:00

91 lines
2.4 KiB
PHP

<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor {
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
public function login() {
$this->amOnPage('/wp-login.php');
if ($this->loadSessionSnapshot('login')) {
return;
}
$this->wait(1);// this needs to be here, Username is not filled properly without this line
$this->fillField('Username', 'admin');
$this->fillField('Password', 'password');
$this->click('Log In');
$this->waitForText('MailPoet', 10);
$this->saveSessionSnapshot('login');
}
/**
* Define custom actions here
*/
public function logOut() {
$I = $this;
$I->amOnPage('/wp-login.php?action=logout');
$I->click('log out');
$I->wait(1);
}
/**
* Navigate to the specified Mailpoet page in the admin.
*
* @param string $page The page to visit e.g. Inbox or Status
*/
public function amOnMailpoetPage($page) {
$I = $this;
$I->amOnPage('/wp-admin');
$I->waitForText('MailPoet', 10);
$I->click('MailPoet');
$I->waitForText($page, 5);
$I->click($page);
$I->waitForText($page, 5);
}
public function clickItemRowActionByItemName($item_name, $link) {
$I = $this;
$I->moveMouseOver(['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']);
$I->click($link, ['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']);
}
/**
* Select a value from select2 input field.
*
* @param string $value
* @param string $element
*/
public function selectOptionInSelect2($value, $element = 'input.select2-search__field') {
$I = $this;
$I->fillField($element, $value);
$I->pressKey($element, \WebDriverKeys::ENTER);
}
/**
* Navigate to the editor for a newsletter.
*
* @param int $id
*/
public function amEditingNewsletter($id) {
$I = $this;
$I->amOnPage('/wp-admin/admin.php?page=mailpoet-newsletter-editor&id=' . $id);
$I->waitForElement('[data-automation-id="newsletter_title"]');
}
}