Test Setup Failed
Branch master (3b2821)
by Dmitrii
09:55
created
src/connector/TestRailAPIClient.php 1 patch
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
     public function __construct($base_url)
22 22
     {
23
-        $base_url = trim($base_url, '/') . '/';
24
-        $this->_url = $base_url . 'index.php?/api/v2/';
23
+        $base_url = trim($base_url, '/').'/';
24
+        $this->_url = $base_url.'index.php?/api/v2/';
25 25
     }
26 26
 
27 27
     /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     protected function _send_request($method, $uri, $data)
109 109
     {
110 110
         $ch = $this->_create_handle();
111
-        curl_setopt($ch, CURLOPT_URL, $this->_url . $uri);
111
+        curl_setopt($ch, CURLOPT_URL, $this->_url.$uri);
112 112
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
113 113
 
114 114
         if ($method == 'POST')
@@ -163,8 +163,7 @@  discard block
 block discarded – undo
163 163
                     'TestRail API returned HTTP %s (%s)',
164 164
                     $info['http_code'],
165 165
                     isset($result['error']) ?
166
-                        '"' . $result['error'] . '"' :
167
-                        'No additional error message received'
166
+                        '"'.$result['error'].'"' : 'No additional error message received'
168 167
                 )
169 168
             );
170 169
         }
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $this->connector = $connector;
39 39
     }
40 40
 
41
-    public static function create(string $url, string $user, string $password){
41
+    public static function create(string $url, string $user, string $password) {
42 42
         $connector = new TestRailAPIClient($url);
43 43
         $connector->set_user($user);
44 44
         $connector->set_password($password);
@@ -48,68 +48,68 @@  discard block
 block discarded – undo
48 48
     /**
49 49
      * @return string
50 50
      */
51
-    public function getUser(){
51
+    public function getUser() {
52 52
         return $this->connector->get_user();
53 53
     }
54 54
 
55
-    public function projects(){
55
+    public function projects() {
56 56
         return new Projects($this->connector);
57 57
     }
58 58
 
59
-    public function suites(){
59
+    public function suites() {
60 60
         return new Suites($this->connector);
61 61
     }
62 62
 
63
-    public function sections(){
63
+    public function sections() {
64 64
         return new Sections($this->connector);
65 65
     }
66 66
 
67
-    public function cases(){
67
+    public function cases() {
68 68
         return new Cases($this->connector);
69 69
     }
70 70
 
71
-    public function templates(){
71
+    public function templates() {
72 72
         return new Templates($this->connector);
73 73
     }
74 74
 
75
-    public function types(){
75
+    public function types() {
76 76
         return new Types($this->connector);
77 77
     }
78 78
 
79
-    public function fields(){
79
+    public function fields() {
80 80
         return new Fields($this->connector);
81 81
     }
82 82
 
83
-    public function priorities(){
83
+    public function priorities() {
84 84
         return new Priorities($this->connector);
85 85
     }
86 86
 
87
-    public function milestones(){
87
+    public function milestones() {
88 88
         return new Milestones($this->connector);
89 89
     }
90 90
 
91
-    public function plans(){
91
+    public function plans() {
92 92
         return new Plans($this->connector);
93 93
     }
94 94
 
95
-    public function configurations(){
95
+    public function configurations() {
96 96
         return new Configurations($this->connector);
97 97
     }
98 98
 
99
-    public function results(){
99
+    public function results() {
100 100
         return new Results($this->connector);
101 101
     }
102 102
 
103
-    public function statuses(){
103
+    public function statuses() {
104 104
         return new Statuses($this->connector);
105 105
     }
106 106
 
107
-    public function users(){
107
+    public function users() {
108 108
         return new Users($this->connector);
109 109
     }
110 110
 
111
-    public function api($name){
112
-        switch ($name){
111
+    public function api($name) {
112
+        switch ($name) {
113 113
             case 'projects':
114 114
                 return $this->projects();
115 115
             case 'suites':
Please login to merge, or discard this patch.
src/api/Milestones.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     private $cache = [];
15 15
     public function all(int $projectId)
16 16
     {
17
-        if(!isset($this->cache[$projectId])) {
18
-            $this->cache[$projectId] = $this->connector->send_get('get_milestones/' . $this->encodePath($projectId));
17
+        if (!isset($this->cache[$projectId])) {
18
+            $this->cache[$projectId] = $this->connector->send_get('get_milestones/'.$this->encodePath($projectId));
19 19
         }
20 20
         return $this->cache[$projectId];
21 21
     }
22 22
 
23 23
     public function get(int $milestoneId)
24 24
     {
25
-        return $this->connector->send_get('get_milestone/' . $this->encodePath($milestoneId));
25
+        return $this->connector->send_get('get_milestone/'.$this->encodePath($milestoneId));
26 26
     }
27 27
 
28 28
     public function findByName(int $projectId, string $name)
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function create(int $projectId, string $name, string $description = null, \DateTime $dueOn = null)
40 40
     {
41
-        if($dueOn === null){
41
+        if ($dueOn === null) {
42 42
             $dueOn = new \DateTime();
43 43
         }
44 44
         $milestone = $this->connector->send_post('add_milestone/'.$this->encodePath($projectId),
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
      *      @var int        $start_on
59 59
      * }
60 60
      */
61
-    public function update(int $milestoneId, array $parameters = []){
62
-        $milestone = $this->connector->send_post('update_milestone/'.$this->encodePath($milestoneId),$parameters);
61
+    public function update(int $milestoneId, array $parameters = []) {
62
+        $milestone = $this->connector->send_post('update_milestone/'.$this->encodePath($milestoneId), $parameters);
63 63
         $this->cache = [];
64 64
         return $milestone;
65 65
     }
66 66
 
67
-    public function delete(int $milestoneId){
68
-        $this->connector->send_post('delete_milestone/'.$this->encodePath($milestoneId),[]);
67
+    public function delete(int $milestoneId) {
68
+        $this->connector->send_post('delete_milestone/'.$this->encodePath($milestoneId), []);
69 69
         $this->cache = [];
70 70
     }
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/api/Fields.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,46 +14,46 @@  discard block
 block discarded – undo
14 14
     private $cache = null;
15 15
     public function all()
16 16
     {
17
-        if($this->cache === null) {
17
+        if ($this->cache === null) {
18 18
             $this->cache = $this->connector->send_get('get_case_fields');
19 19
         }
20 20
         return $this->cache;
21 21
     }
22 22
 
23
-    public function findByProject(int $projectId){
23
+    public function findByProject(int $projectId) {
24 24
         $fields = $this->all();
25 25
         $resultFields = [];
26
-        foreach($fields as $field){
27
-            if($field['configs'][0]['context']['is_global'] === true){
26
+        foreach ($fields as $field) {
27
+            if ($field['configs'][0]['context']['is_global'] === true) {
28 28
                 $resultFields[] = $field;
29
-            }else if(in_array($projectId,$field['configs'][0]['context']['project_ids'])){
29
+            }else if (in_array($projectId, $field['configs'][0]['context']['project_ids'])) {
30 30
                 $resultFields[] = $field;
31 31
             }
32 32
         }
33 33
         return $resultFields;
34 34
     }
35 35
 
36
-    public function findByName(string $name, int $projectId = null){
37
-        if($projectId === null){
36
+    public function findByName(string $name, int $projectId = null) {
37
+        if ($projectId === null) {
38 38
             $fields = $this->all();
39
-        }else{
39
+        }else {
40 40
             $fields = $this->findByProject($projectId);
41 41
         }
42 42
 
43
-        foreach($fields as $field){
44
-            if($field['system_name'] === $name || $field['name'] === $name){
43
+        foreach ($fields as $field) {
44
+            if ($field['system_name'] === $name || $field['name'] === $name) {
45 45
                 return $field;
46 46
             }
47 47
         }
48 48
         return [];
49 49
     }
50 50
 
51
-    public function findElementId(string $field, string $value, int $projectId = null){
52
-        $field = $this->findByName($field,$projectId);
53
-        if($field !== []){
51
+    public function findElementId(string $field, string $value, int $projectId = null) {
52
+        $field = $this->findByName($field, $projectId);
53
+        if ($field !== []) {
54 54
             preg_match_all('/^([0-9]*),\s([A-Za-z0-9 ]*)/m', $field['configs'][0]['options']['items'], $matches, PREG_SET_ORDER, 0);
55 55
             foreach ($matches as $match) {
56
-                if($match[2] === $value){
56
+                if ($match[2] === $value) {
57 57
                     return (int)$match[1];
58 58
                 }
59 59
             }
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
         return 0;
62 62
     }
63 63
 
64
-    public function findElementNameById(string $field, int $id, int $projectId = null){
65
-        $field = $this->findByName($field,$projectId);
66
-        if($field !== []){
64
+    public function findElementNameById(string $field, int $id, int $projectId = null) {
65
+        $field = $this->findByName($field, $projectId);
66
+        if ($field !== []) {
67 67
             preg_match_all('/^([0-9]*),\s([A-Za-z0-9 ]*)/m', $field['configs'][0]['options']['items'], $matches, PREG_SET_ORDER, 0);
68 68
             foreach ($matches as $match) {
69
-                if((int)$match[1] === $id){
69
+                if ((int)$match[1] === $id) {
70 70
                     return $match[2];
71 71
                 }
72 72
             }
Please login to merge, or discard this patch.
src/api/Suites.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     private $cache = [];
15 15
     public function all(int $projectId)
16 16
     {
17
-        if(!isset($this->cache[$projectId])) {
18
-            $this->cache[$projectId] = $this->connector->send_get('get_suites/' . $this->encodePath($projectId));
17
+        if (!isset($this->cache[$projectId])) {
18
+            $this->cache[$projectId] = $this->connector->send_get('get_suites/'.$this->encodePath($projectId));
19 19
         }
20 20
         return $this->cache[$projectId];
21 21
     }
22 22
 
23 23
     public function get(int $suiteId)
24 24
     {
25
-        return $this->connector->send_get('get_suite/' . $this->encodePath($suiteId));
25
+        return $this->connector->send_get('get_suite/'.$this->encodePath($suiteId));
26 26
     }
27 27
 
28 28
     public function findByName(int $projectId, string $name)
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
     public function create(int $projectId, string $name, string $description = null)
40 40
     {
41
-        $suite =  $this->connector->send_post('add_suite/'.$this->encodePath($projectId),
41
+        $suite = $this->connector->send_post('add_suite/'.$this->encodePath($projectId),
42 42
             ['name' => $name,
43 43
                 'description' => $description]);
44 44
         unset($this->cache[$projectId]);
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
      * }
54 54
      * @return mixed
55 55
      */
56
-    public function update(int $suiteId, array $parameters = []){
57
-        $suite =  $this->connector->send_post('update_suite/'.$this->encodePath($suiteId),$parameters);
56
+    public function update(int $suiteId, array $parameters = []) {
57
+        $suite = $this->connector->send_post('update_suite/'.$this->encodePath($suiteId), $parameters);
58 58
         $this->cache = [];
59 59
         return $suite;
60 60
     }
61 61
 
62
-    public function delete(int $suiteId){
63
-        $this->connector->send_post('delete_suite/'.$this->encodePath($suiteId),[]);
62
+    public function delete(int $suiteId) {
63
+        $this->connector->send_post('delete_suite/'.$this->encodePath($suiteId), []);
64 64
         $this->cache = [];
65 65
     }
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
src/api/Users.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@
 block discarded – undo
13 13
 {
14 14
     private $cache = null;
15 15
 
16
-    public function all(){
17
-        if($this->cache === null) {
18
-            $this->cache =  $this->connector->send_get('get_users');
16
+    public function all() {
17
+        if ($this->cache === null) {
18
+            $this->cache = $this->connector->send_get('get_users');
19 19
         }
20 20
         return $this->cache;
21 21
     }
22 22
 
23
-    public function find(string $name){
23
+    public function find(string $name) {
24 24
         $users = $this->all();
25 25
         foreach ($users as $user) {
26 26
             if ($user['name'] === $name || $user['email'] === $name) {
Please login to merge, or discard this patch.
src/api/Cases.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function all(int $projectId, int $suiteId, int $sectionId = null)
15 15
     {
16
-        return $this->connector->send_get('get_cases/' . $this->encodePath($projectId) . '&suite_id=' . $this->encodePath($suiteId) . '&section_id=' . $this->encodePath($sectionId));
16
+        return $this->connector->send_get('get_cases/'.$this->encodePath($projectId).'&suite_id='.$this->encodePath($suiteId).'&section_id='.$this->encodePath($sectionId));
17 17
     }
18 18
 
19
-    public function findBySection(int $projectId, int $suiteId, int $sectionId = null){
20
-        $cases = $this->all($projectId,$suiteId,$sectionId);
19
+    public function findBySection(int $projectId, int $suiteId, int $sectionId = null) {
20
+        $cases = $this->all($projectId, $suiteId, $sectionId);
21 21
         $resultCases = [];
22 22
         foreach ($cases as $case) {
23
-            if($case['section_id'] === $sectionId){
23
+            if ($case['section_id'] === $sectionId) {
24 24
                 $resultCases[] = $case;
25 25
             }
26 26
         }
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 
30 30
     public function get(int $caseId)
31 31
     {
32
-        return $this->connector->send_get('get_case/' . $this->encodePath($caseId));
32
+        return $this->connector->send_get('get_case/'.$this->encodePath($caseId));
33 33
     }
34 34
 
35
-    public function findByField(int $projectId, int $suiteId, string $field, string $value,int $sectionId = null){
36
-        $allCases = $this->all($projectId,$suiteId, $sectionId);
35
+    public function findByField(int $projectId, int $suiteId, string $field, string $value, int $sectionId = null) {
36
+        $allCases = $this->all($projectId, $suiteId, $sectionId);
37 37
         foreach ($allCases as $case) {
38 38
             if ($case[$field] === $value) {
39 39
                 return $case;
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
      * }
70 70
      * @return mixed
71 71
      */
72
-    public function update(int $caseId, array $parameters = []){
73
-        $case = $this->connector->send_post('update_case/'.$this->encodePath($caseId),$parameters);
72
+    public function update(int $caseId, array $parameters = []) {
73
+        $case = $this->connector->send_post('update_case/'.$this->encodePath($caseId), $parameters);
74 74
         return $case;
75 75
     }
76 76
 
77
-    public function delete(int $caseId){
78
-        $this->connector->send_post('delete_case/'.$this->encodePath($caseId),[]);
77
+    public function delete(int $caseId) {
78
+        $this->connector->send_post('delete_case/'.$this->encodePath($caseId), []);
79 79
     }
80 80
 }
81 81
\ No newline at end of file
Please login to merge, or discard this patch.
src/api/Sections.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,20 +14,20 @@  discard block
 block discarded – undo
14 14
     private $cache = [];
15 15
     public function all(int $projectId, int $suiteId)
16 16
     {
17
-        if(!isset($this->cache[$projectId][$suiteId])) {
18
-            $this->cache[$projectId][$suiteId] = $this->connector->send_get('get_sections/' . $this->encodePath($projectId) . '&suite_id=' . $this->encodePath($suiteId));
17
+        if (!isset($this->cache[$projectId][$suiteId])) {
18
+            $this->cache[$projectId][$suiteId] = $this->connector->send_get('get_sections/'.$this->encodePath($projectId).'&suite_id='.$this->encodePath($suiteId));
19 19
         }
20 20
         return $this->cache[$projectId][$suiteId];
21 21
     }
22 22
 
23 23
     public function get(int $sectionId)
24 24
     {
25
-        return $this->connector->send_get('get_section/' . $this->encodePath($sectionId));
25
+        return $this->connector->send_get('get_section/'.$this->encodePath($sectionId));
26 26
     }
27 27
 
28 28
     public function findByName(int $projectId, int $suiteId, string $name)
29 29
     {
30
-        $allSections = $this->all($projectId,$suiteId);
30
+        $allSections = $this->all($projectId, $suiteId);
31 31
         foreach ($allSections as $section) {
32 32
             if ($section['name'] === $name) {
33 33
                 return $section;
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
         return [];
37 37
     }
38 38
 
39
-    public function findByNameAndParent(int $projectId, int $suiteId, string $name, int $parentId=null)
39
+    public function findByNameAndParent(int $projectId, int $suiteId, string $name, int $parentId = null)
40 40
     {
41
-        $allSections = $this->all($projectId,$suiteId);
41
+        $allSections = $this->all($projectId, $suiteId);
42 42
         foreach ($allSections as $section) {
43 43
             if ($section['name'] === $name && $section['parent_id'] == $parentId) {
44 44
                 return $section;
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
         return [];
48 48
     }
49 49
 
50
-    public function findByParent(int $projectId, int $suiteId, int $parentId = null){
51
-        $allSections = $this->all($projectId,$suiteId);
50
+    public function findByParent(int $projectId, int $suiteId, int $parentId = null) {
51
+        $allSections = $this->all($projectId, $suiteId);
52 52
         $sections = [];
53 53
         foreach ($allSections as $section) {
54 54
             if ((!isset($section['parent_id']) && $parentId == null) || (isset($section['parent_id']) && $section['parent_id'] == $parentId)) {
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
      * }
78 78
      * @return mixed
79 79
      */
80
-    public function update(int $sectionId, array $parameters = []){
81
-        $section = $this->connector->send_post('update_section/'.$this->encodePath($sectionId),$parameters);
80
+    public function update(int $sectionId, array $parameters = []) {
81
+        $section = $this->connector->send_post('update_section/'.$this->encodePath($sectionId), $parameters);
82 82
         $this->cache = [];
83 83
         return $section;
84 84
     }
85 85
 
86
-    public function delete(int $sectionId){
87
-        $this->connector->send_post('delete_section/'.$this->encodePath($sectionId),[]);
86
+    public function delete(int $sectionId) {
87
+        $this->connector->send_post('delete_section/'.$this->encodePath($sectionId), []);
88 88
         $this->cache = [];
89 89
     }
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
src/api/Templates.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
     private $cache = null;
15 15
     public function all(int $projectId)
16 16
     {
17
-        if($this->cache === null) {
18
-            $this->cache = $this->connector->send_get('get_templates/' . $this->encodePath($projectId));
17
+        if ($this->cache === null) {
18
+            $this->cache = $this->connector->send_get('get_templates/'.$this->encodePath($projectId));
19 19
         }
20 20
         return $this->cache;
21 21
     }
Please login to merge, or discard this patch.