2018-08-03 17:19:45 +02:00
|
|
|
<?php
|
2018-08-03 19:11:45 +02:00
|
|
|
|
2018-08-03 17:19:45 +02:00
|
|
|
namespace Helper;
|
|
|
|
|
|
|
|
// here you can define custom actions
|
2018-08-03 19:11:45 +02:00
|
|
|
// all public methods declared in helper class will be available in $t
|
2018-08-03 17:19:45 +02:00
|
|
|
|
|
|
|
class Acceptance extends \Codeception\Module
|
|
|
|
{
|
2018-08-03 19:23:55 +02:00
|
|
|
/**
|
|
|
|
* Imposta il valore di un select gestito dal framework Select2.
|
|
|
|
*
|
|
|
|
* @param $selector
|
|
|
|
* @param $option
|
|
|
|
* @param int $timeout seconds. Default to 1
|
|
|
|
*/
|
2019-01-02 14:15:16 +01:00
|
|
|
public function select2($selector, $option, $timeout = null)
|
2018-08-03 19:11:45 +02:00
|
|
|
{
|
|
|
|
$select2 = $this->getModule('\Helper\Select2');
|
|
|
|
|
|
|
|
$select2->openSelect2($selector);
|
|
|
|
$select2->selectOptionForSelect2($selector, $option, $timeout);
|
|
|
|
$select2->closeSelect2($selector);
|
|
|
|
}
|
|
|
|
|
2018-10-13 12:16:26 +02:00
|
|
|
/**
|
|
|
|
* Imposta il valore di un select gestito dal framework Select2.
|
|
|
|
*
|
|
|
|
* @param $selector
|
|
|
|
* @param $option
|
|
|
|
* @param int $timeout seconds. Default to 1
|
|
|
|
*/
|
2019-01-02 14:15:16 +01:00
|
|
|
public function select2ajax($selector, $option, $timeout = null)
|
2018-10-13 12:16:26 +02:00
|
|
|
{
|
|
|
|
$select2 = $this->getModule('\Helper\Select2Ajax');
|
2019-02-23 16:18:34 +01:00
|
|
|
$t = $this->getAcceptanceModule();
|
2018-10-13 12:16:26 +02:00
|
|
|
|
2019-02-23 16:18:34 +01:00
|
|
|
$select2->openSelect2($selector);
|
|
|
|
$t->wait(1);
|
|
|
|
$select2->selectByPosition($selector, $option, $timeout);
|
|
|
|
$select2->closeSelect2($selector);
|
2018-10-13 12:16:26 +02:00
|
|
|
}
|
|
|
|
|
2018-11-22 15:34:44 +01:00
|
|
|
public function seePageHasElement($element)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->getAcceptanceModule()->seeElement($element);
|
2019-07-11 17:20:58 +02:00
|
|
|
} catch (\Exception $f) {
|
2018-11-22 15:34:44 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function expandSidebarLink($link)
|
|
|
|
{
|
|
|
|
$t = $this->getAcceptanceModule();
|
|
|
|
|
|
|
|
if (!$this->seePageHasElement("descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' sidebar ')]/descendant-or-self::*/li[contains(., '".$link."') and @class and contains(concat(' ', normalize-space(@class), ' '), ' menu-open ')]")) {
|
|
|
|
$t->click($link, '.sidebar');
|
|
|
|
$t->wait(1);
|
|
|
|
}
|
|
|
|
}
|
2018-12-29 12:03:22 +01:00
|
|
|
|
|
|
|
protected function getAcceptanceModule()
|
|
|
|
{
|
|
|
|
if (!$this->hasModule('WebDriver')) {
|
|
|
|
throw new \Exception('You must enable the WebDriver module', 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->getModule('WebDriver');
|
|
|
|
}
|
2018-08-03 17:19:45 +02:00
|
|
|
}
|