diff options
author | Sergejs Olonkins <sergejs.olonkins@zabbix.com> | 2022-10-31 11:04:57 +0300 |
---|---|---|
committer | Sergejs Olonkins <sergejs.olonkins@zabbix.com> | 2022-10-31 11:04:57 +0300 |
commit | 17948a123a794c2cb669e8bb99b2984c5ef2daa9 (patch) | |
tree | 9ca8a57ee4c9862086775c3feabfdfdc3a61ed5e | |
parent | a5e9fe4ef016121abd22acf00e4f04b46a9ebb98 (diff) |
.......... [DEV-2067] added framework changes to 5.0 release branch
-rw-r--r-- | ui/tests/include/helpers/CDateTimeHelper.php | 19 | ||||
-rw-r--r-- | ui/tests/include/web/elements/CFormElement.php | 11 | ||||
-rw-r--r-- | ui/tests/include/web/elements/CMultiselectElement.php | 4 |
3 files changed, 34 insertions, 0 deletions
diff --git a/ui/tests/include/helpers/CDateTimeHelper.php b/ui/tests/include/helpers/CDateTimeHelper.php index 697c91b557f..ad2fca306fd 100644 --- a/ui/tests/include/helpers/CDateTimeHelper.php +++ b/ui/tests/include/helpers/CDateTimeHelper.php @@ -78,4 +78,23 @@ class CDateTimeHelper { public static function countDays($date = 'now', $period = 'P1Y') { return (new DateTime($date))->diff((new DateTime($date))->sub(new DateInterval($period)))->days; } + + /** + * Get the time difference in months between two moments in time. + * + * @param string|int $from timestamp or string that represents the oldest moments in time + * @param string|int $to timestamp or string that represents the newest moments in time + * + * @return int + */ + public static function countMonthsBetweenDates($from, $to = 'now') { + foreach ([&$from, &$to] as &$moment) { + if (is_string($moment)) { + $moment = strtotime($moment); + } + } + unset($moment); + + return ((date('Y', $to) - date('Y', $from)) * 12) + ((date('m', $to) - date('m', $from))); + } } diff --git a/ui/tests/include/web/elements/CFormElement.php b/ui/tests/include/web/elements/CFormElement.php index 891b7424ddd..7f5bfe89cad 100644 --- a/ui/tests/include/web/elements/CFormElement.php +++ b/ui/tests/include/web/elements/CFormElement.php @@ -464,4 +464,15 @@ class CFormElement extends CElement { } }; } + + /** + * Check if field is marked as required in form. + * + * @param string $label field label text + * + * @return boolean + */ + public function isRequired($label) { + return $this->getLabel($label)->hasClass('form-label-asterisk'); + } } diff --git a/ui/tests/include/web/elements/CMultiselectElement.php b/ui/tests/include/web/elements/CMultiselectElement.php index f3dbece5026..82b37666e1c 100644 --- a/ui/tests/include/web/elements/CMultiselectElement.php +++ b/ui/tests/include/web/elements/CMultiselectElement.php @@ -111,6 +111,10 @@ class CMultiselectElement extends CElement { throw new Exception('Select of multiple labels is not supported in single select mode.'); } + if ($label === '') { + return $this->clear(); + } + $this->edit($context)->query('link:'.$label)->one()->click()->waitUntilNotPresent(); return $this; |