15
15
namespace Gitlab \Tests \Api ;
16
16
17
17
use Gitlab \Api \Integrations ;
18
+ use PHPUnit \Framework \Attributes \Test ;
18
19
use PHPUnit \Framework \MockObject \MockObject ;
19
20
20
21
class IntegrationsTest extends TestCase
21
22
{
22
- /**
23
- * @test
24
- */
23
+ #[Test]
25
24
public function shouldGetAllIntegrations (): void
26
25
{
27
26
$ expectedArray = $ this ->getMultipleIntegrationsData ();
@@ -30,6 +29,7 @@ public function shouldGetAllIntegrations(): void
30
29
$ this ->assertEquals ($ expectedArray , $ api ->all (1 ));
31
30
}
32
31
32
+ #[Test]
33
33
public function shouldCreateMicrosoftTeams (): void
34
34
{
35
35
$ expectedArray = [
@@ -40,14 +40,15 @@ public function shouldCreateMicrosoftTeams(): void
40
40
$ api = $ this ->getApiMock ();
41
41
$ api ->expects ($ this ->once ())
42
42
->method ('put ' )
43
- ->with ('projects/1/integrations ' )
44
- ->will ( $ this -> returnValue ( $ expectedArray) );
43
+ ->with ('projects/1/integrations/microsoft-teams ' )
44
+ ->willReturn ( $ expectedArray );
45
45
46
46
$ this ->assertEquals ($ expectedArray , $ api ->createMicrosoftTeams (1 , [
47
- 'webroot ' => 'https://test.org/ ' ,
47
+ 'webhook ' => 'https://test.org/ ' ,
48
48
]));
49
49
}
50
50
51
+ #[Test]
51
52
public function shouldUpdateMicrosoftTeams (): void
52
53
{
53
54
$ expectedArray = [
@@ -58,14 +59,15 @@ public function shouldUpdateMicrosoftTeams(): void
58
59
$ api = $ this ->getApiMock ();
59
60
$ api ->expects ($ this ->once ())
60
61
->method ('put ' )
61
- ->with ('projects/1/integrations ' )
62
- ->will ( $ this -> returnValue ( $ expectedArray) );
62
+ ->with ('projects/1/integrations/microsoft-teams ' )
63
+ ->willReturn ( $ expectedArray );
63
64
64
65
$ this ->assertEquals ($ expectedArray , $ api ->updateMicrosoftTeams (1 , [
65
- 'webroot ' => 'https://test.org/ ' ,
66
+ 'webhook ' => 'https://test.org/ ' ,
66
67
]));
67
68
}
68
69
70
+ #[Test]
69
71
public function shouldGetMicrosoftTeams (): void
70
72
{
71
73
$ expectedArray = [
@@ -76,25 +78,27 @@ public function shouldGetMicrosoftTeams(): void
76
78
$ api = $ this ->getApiMock ();
77
79
$ api ->expects ($ this ->once ())
78
80
->method ('get ' )
79
- ->with ('projects/1/integrations ' )
80
- ->will ( $ this -> returnValue ( $ expectedArray) );
81
+ ->with ('projects/1/integrations/microsoft-teams ' )
82
+ ->willReturn ( $ expectedArray );
81
83
82
84
$ this ->assertEquals ($ expectedArray , $ api ->getMicrosoftTeams (1 ));
83
85
}
84
86
87
+ #[Test]
85
88
public function shouldRemoveMicrosoftTeams (): void
86
89
{
87
90
$ expectedBool = true ;
88
91
89
92
$ api = $ this ->getApiMock ();
90
93
$ api ->expects ($ this ->once ())
91
94
->method ('delete ' )
92
- ->with ('projects/1/integrations ' )
93
- ->will ( $ this -> returnValue ( $ expectedBool) );
95
+ ->with ('projects/1/integrations/microsoft-teams ' )
96
+ ->willReturn ( $ expectedBool );
94
97
95
98
$ this ->assertEquals ($ expectedBool , $ api ->removeMicrosoftTeams (1 ));
96
99
}
97
100
101
+ #[Test]
98
102
public function shouldCreateJira (): void
99
103
{
100
104
$ expectedArray = [
@@ -105,15 +109,16 @@ public function shouldCreateJira(): void
105
109
$ api = $ this ->getApiMock ();
106
110
$ api ->expects ($ this ->once ())
107
111
->method ('put ' )
108
- ->with ('projects/1/integrations ' )
109
- ->will ( $ this -> returnValue ( $ expectedArray) );
112
+ ->with ('projects/1/integrations/jira ' )
113
+ ->willReturn ( $ expectedArray );
110
114
111
115
$ this ->assertEquals ($ expectedArray , $ api ->createJira (1 , [
112
- 'url ' => 'http ://test.org/ ' ,
116
+ 'url ' => 'https ://test.org/ ' ,
113
117
'password ' => '123 ' ,
114
118
]));
115
119
}
116
120
121
+ #[Test]
117
122
public function shouldUpdateJira (): void
118
123
{
119
124
$ expectedArray = [
@@ -124,15 +129,16 @@ public function shouldUpdateJira(): void
124
129
$ api = $ this ->getApiMock ();
125
130
$ api ->expects ($ this ->once ())
126
131
->method ('put ' )
127
- ->with ('projects/1/integrations ' )
128
- ->will ( $ this -> returnValue ( $ expectedArray) );
132
+ ->with ('projects/1/integrations/jira ' )
133
+ ->willReturn ( $ expectedArray );
129
134
130
135
$ this ->assertEquals ($ expectedArray , $ api ->updateJira (1 , [
131
- 'url ' => 'http ://test.org/ ' ,
136
+ 'url ' => 'https ://test.org/ ' ,
132
137
'password ' => '123 ' ,
133
138
]));
134
139
}
135
140
141
+ #[Test]
136
142
public function shouldGetJira (): void
137
143
{
138
144
$ expectedArray = [
@@ -143,40 +149,45 @@ public function shouldGetJira(): void
143
149
$ api = $ this ->getApiMock ();
144
150
$ api ->expects ($ this ->once ())
145
151
->method ('get ' )
146
- ->with ('projects/1/integrations ' )
147
- ->will ( $ this -> returnValue ( $ expectedArray) );
152
+ ->with ('projects/1/integrations/jira ' )
153
+ ->willReturn ( $ expectedArray );
148
154
149
155
$ this ->assertEquals ($ expectedArray , $ api ->getJira (1 ));
150
156
}
151
157
158
+ #[Test]
152
159
public function shouldRemoveJira (): void
153
160
{
154
161
$ expectedBool = true ;
155
162
156
163
$ api = $ this ->getApiMock ();
157
164
$ api ->expects ($ this ->once ())
158
165
->method ('delete ' )
159
- ->with ('projects/1/integrations ' )
160
- ->will ( $ this -> returnValue ( $ expectedBool) );
166
+ ->with ('projects/1/integrations/jira ' )
167
+ ->willReturn ( $ expectedBool );
161
168
162
169
$ this ->assertEquals ($ expectedBool , $ api ->removeJira (1 ));
163
170
}
164
171
165
- protected function getMultipleIntegrationsData (): array
172
+ // This method is used to create an array of multiple integrations data.
173
+ // NOT A TEST
174
+ private function getMultipleIntegrationsData (): array
166
175
{
167
176
return [
168
177
['id ' => 1 , 'title ' => 'Microsoft Teams notifications ' , 'slug ' => 'microsoft-teams ' ],
169
178
['id ' => 2 , 'title ' => 'Jira ' , 'slug ' => 'jira ' ],
170
179
];
171
180
}
172
181
173
- protected function getMultipleIntegrationsRequestMock ($ path , $ expectedArray = [], $ expectedParameters = []): MockObject
182
+ // This method is used to create a mock for the Integrations class.
183
+ // NOT A TEST
184
+ private function getMultipleIntegrationsRequestMock ($ path , $ expectedArray = [], $ expectedParameters = []): MockObject
174
185
{
175
186
$ api = $ this ->getApiMock ();
176
187
$ api ->expects ($ this ->once ())
177
188
->method ('get ' )
178
189
->with ($ path , $ expectedParameters )
179
- ->will ( $ this -> returnValue ( $ expectedArray) );
190
+ ->willReturn ( $ expectedArray );
180
191
181
192
return $ api ;
182
193
}
0 commit comments