|
19 | 19 |
|
20 | 20 | /** |
21 | 21 | * Class ActionObject |
| 22 | + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
22 | 23 | */ |
23 | 24 | class ActionObject |
24 | 25 | { |
@@ -62,6 +63,7 @@ class ActionObject |
62 | 63 | const FUNCTION_CLOSURE_ACTIONS = ['waitForElementChange', 'performOn']; |
63 | 64 | const MERGE_ACTION_ORDER_AFTER = 'after'; |
64 | 65 | const MERGE_ACTION_ORDER_BEFORE = 'before'; |
| 66 | + const ACTION_ATTRIBUTE_TIMEZONE = 'timezone'; |
65 | 67 | const ACTION_ATTRIBUTE_URL = 'url'; |
66 | 68 | const ACTION_ATTRIBUTE_SELECTOR = 'selector'; |
67 | 69 | const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/'; |
@@ -256,6 +258,7 @@ public function resolveReferences() |
256 | 258 | $this->resolveSelectorReferenceAndTimeout(); |
257 | 259 | $this->resolveUrlReference(); |
258 | 260 | $this->resolveDataInputReferences(); |
| 261 | + $this->validateTimezoneAttribute(); |
259 | 262 | if ($this->getType() == "deleteData") { |
260 | 263 | $this->validateMutuallyExclusiveAttributes(self::DELETE_DATA_MUTUAL_EXCLUSIVE_ATTRIBUTES); |
261 | 264 | } |
@@ -599,6 +602,28 @@ private function validateUrlAreaAgainstActionType($obj) |
599 | 602 | } |
600 | 603 | } |
601 | 604 |
|
| 605 | + /** |
| 606 | + * Validates that the timezone attribute contains a valid value. |
| 607 | + * |
| 608 | + * @return void |
| 609 | + * @throws TestReferenceException |
| 610 | + */ |
| 611 | + private function validateTimezoneAttribute() |
| 612 | + { |
| 613 | + $attributes = $this->getCustomActionAttributes(); |
| 614 | + if (isset($attributes[self::ACTION_ATTRIBUTE_TIMEZONE])) { |
| 615 | + $timezone = $attributes[self::ACTION_ATTRIBUTE_TIMEZONE]; |
| 616 | + try { |
| 617 | + new \DateTimeZone($timezone); |
| 618 | + } catch (\Exception $e) { |
| 619 | + throw new TestReferenceException( |
| 620 | + "Timezone '{$timezone}' is not a valid timezone", |
| 621 | + ["stepKey" => $this->getStepKey(), self::ACTION_ATTRIBUTE_TIMEZONE => $timezone] |
| 622 | + ); |
| 623 | + } |
| 624 | + } |
| 625 | + } |
| 626 | + |
602 | 627 | /** |
603 | 628 | * Gets the object's dataByName with given $match, differentiating behavior between <array> and <data> nodes. |
604 | 629 | * @param string $obj |
|
0 commit comments