Completed
Push — master ( fb2513...9da24f )
by Toni
8s
created
src/Context/MultilingualContext.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@
 block discarded – undo
63 63
         if(isset($this->translations[$target][$this->multilingual_parameters['language']])){
64 64
             $target = $this->translations[$target][$this->multilingual_parameters['language']];
65 65
             return $target;
66
-        }
67
-        elseif (isset($this->translations[$target])) {
66
+        } elseif (isset($this->translations[$target])) {
68 67
             return $target;
68
+        } else {
69
+            throw new \Exception ("The text '$target'' is not defined in '$translations' translation file.");
69 70
         }
70
-        else throw new \Exception ("The text '$target'' is not defined in '$translations' translation file.");
71 71
     }
72 72
 
73 73
     /**
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
         $file_path = $base_path.$this->multilingual_parameters['translations'];
44 44
         $yaml = file_get_contents($file_path);
45 45
         $yaml_parse_array_check = Yaml::parse($yaml);
46
-        if(is_array($yaml_parse_array_check)) {
46
+        if (is_array($yaml_parse_array_check)) {
47 47
             $this->translations = $yaml_parse_array_check;
48 48
         }
49 49
     }
50 50
 
51 51
     public function initializeMultilanguage() {
52
-        if(isset($this->multilingual_parameters['language'])&&isset($this->multilingual_parameters['translations'])) {
52
+        if (isset($this->multilingual_parameters['language'])&&isset($this->multilingual_parameters['translations'])) {
53 53
             $this->parseTranslationFile();
54 54
         }
55 55
     }
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 
64 64
     public function localizeTarget($target) {
65 65
         $translations = $this->multilingual_parameters['translations'];
66
-        if(isset($this->translations[$target][$this->multilingual_parameters['language']])){
66
+        if (isset($this->translations[$target][$this->multilingual_parameters['language']])) {
67 67
             $target = $this->translations[$target][$this->multilingual_parameters['language']];
68 68
             return $target;
69 69
         }
70 70
         elseif (isset($this->translations[$target])) {
71 71
             return $target;
72 72
         }
73
-        else throw new \Exception ("The text '$target'' is not defined in '$translations' translation file.");
73
+        else throw new \Exception("The text '$target'' is not defined in '$translations' translation file.");
74 74
     }
75 75
 
76 76
     /**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     public function localizeField($field) {
81 81
         $re = "/(?:[-])(en)(?:[-])/";
82 82
         $language = "-".$this->multilingual_parameters['language']."-";
83
-        $field = preg_replace($re, $language,$field);
83
+        $field = preg_replace($re, $language, $field);
84 84
         return $field;
85 85
     }
86 86
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      *
170 170
      * @When /^I wait for localized text "([^"]*)" to appear with max time "([^"]+)"(?: seconds)?$/
171 171
      */
172
-    public function iWaitForLocalizedTextToAppearWithMaxTime($target, $maxExecutionTime){
172
+    public function iWaitForLocalizedTextToAppearWithMaxTime($target, $maxExecutionTime) {
173 173
         $target = $this->localizeTarget($target);
174 174
         $this->iWaitForTextToAppearWithMaxTime($target, $maxExecutionTime);
175 175
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * @Given I click localized :link in the :rowText row
194 194
      * @Then I (should )see the localized :link in the :rowText row
195 195
      */
196
-    public function assertLocalizedClickInTableRow($link, $rowText){
196
+    public function assertLocalizedClickInTableRow($link, $rowText) {
197 197
         $link = $this->localizeTarget($link);
198 198
         $page = $this->getSession()->getPage();
199 199
         if ($link_element = $this->getTableRow($page, $rowText)->findLink($link)) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      *
223 223
      * @When /^I click on the localized text "([^"]*)" in the "(?P<region>[^"]*)"(?:| region)$/
224 224
      */
225
-    public function iClickOnTheLocalizedTextInRegion($text, $region){
225
+    public function iClickOnTheLocalizedTextInRegion($text, $region) {
226 226
         $text = $this->localizeTarget($text);
227 227
         $this->iClickOnTheTextInRegion($text, $region);
228 228
     }
Please login to merge, or discard this patch.
src/Context/RawMultilingualContext.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $session = $this->getSession();
51 51
         $element = $session->getPage()->find(
52 52
             'xpath',
53
-            $session->getSelectorsHandler()->selectorToXpath('xpath', '//*[contains(text(),"' . $text . '")]'));
53
+            $session->getSelectorsHandler()->selectorToXpath('xpath', '//*[contains(text(),"'.$text.'")]'));
54 54
 
55 55
         if (null === $element) {
56 56
             throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function assertValueInInput($value, $input) {
63 63
 
64
-        if (substr($input,0,1) != "#") {
65
-            $input = "#" . $input;
64
+        if (substr($input, 0, 1) != "#") {
65
+            $input = "#".$input;
66 66
         }
67 67
         $session = $this->getSession();
68 68
         $element = $session->getPage()->find('css', $input);
69 69
         $text = "";
70 70
 
71
-        if(isset($element)) {
71
+        if (isset($element)) {
72 72
             $text = $element->getValue();
73 73
         }
74 74
         else {
75 75
             throw new \Exception(sprintf("Element is null"));
76 76
         }
77 77
 
78
-        if($text === $value) {
78
+        if ($text === $value) {
79 79
             return true;
80 80
         }
81 81
         else {
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 
108 108
         $html = $this->getSession()->getDriver()->getContent();
109 109
         $text = $this->validateTextForSearchInSource($text);
110
-        $regex = '/' . $text . '/';
110
+        $regex = '/'.$text.'/';
111 111
 
112 112
         preg_match($regex, $html, $results);
113 113
 
114 114
         if ($results == null) {
115
-            throw new \Exception('The searched text ' . $text . ' was not found in the source of the page.');
115
+            throw new \Exception('The searched text '.$text.' was not found in the source of the page.');
116 116
         }
117 117
 
118 118
         return true;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
         $session = $this->getSession();
133 133
         $element = $session->getPage()->find('region', $region)->find('xpath', $session->getSelectorsHandler()->selectorToXpath('xpath',
134
-            '//*[contains(text(),"' . $text . '")]'));
134
+            '//*[contains(text(),"'.$text.'")]'));
135 135
 
136 136
         if (null === $element) {
137 137
             throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         $session = $this->getSession();
146 146
         $element = $session->getPage()->find('region', $region)->find('xpath', $session->getSelectorsHandler()->selectorToXpath('xpath',
147
-            '//*[contains(text(),"' . $text . '")]'));
147
+            '//*[contains(text(),"'.$text.'")]'));
148 148
 
149 149
         if (null === $element) {
150 150
             throw new \InvalidArgumentException(sprintf('Cannot find text: "%s"', $text));
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,15 +70,13 @@  discard block
 block discarded – undo
70 70
 
71 71
         if(isset($element)) {
72 72
             $text = $element->getValue();
73
-        }
74
-        else {
73
+        } else {
75 74
             throw new \Exception(sprintf("Element is null"));
76 75
         }
77 76
 
78 77
         if($text === $value) {
79 78
             return true;
80
-        }
81
-        else {
79
+        } else {
82 80
             throw new \Exception(sprintf('Value of input : "%s" does not match the text "%s"', $text, $value));
83 81
         }
84 82
     }
@@ -92,8 +90,7 @@  discard block
 block discarded – undo
92 90
                 $this->iShouldSeeInTheSourceOfThePage($text);
93 91
                 $isTextFound = true;
94 92
                 break;
95
-            }
96
-            catch (\Exception $e) {
93
+            } catch (\Exception $e) {
97 94
                 sleep(1);
98 95
             }
99 96
         }
Please login to merge, or discard this patch.