Completed
Push — master ( 9da24f...527efe )
by Toni
02:21
created
src/Context/MultilingualContext.php 2 patches
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -4,13 +4,7 @@
 block discarded – undo
4 4
 
5 5
 use Behat\Behat\Context\Context;
6 6
 use Symfony\Component\Yaml\Yaml;
7
-use Drupal\DrupalExtension\Context\DrupalContext;
8
-use Behat\MinkExtension;
9
-use Behat\Behat\Context\TranslatableContext;
10 7
 use Behat\Mink\Element\Element;
11
-use Behat\Gherkin\Node\TableNode;
12
-use Behat\Behat\Hook\Scope\BeforeScenarioScope;
13
-use Behat\MinkExtension\Context\RawMinkContext;
14 8
 
15 9
 /**
16 10
  * This is the file for Multilingual context for Drupal. The context is working based on specifications
Please login to merge, or discard this patch.
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.
src/Context/RawMultilingualContext.php 1 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.