33namespace Tests \Icinga \Module \Notifications \Controllers ;
44
55use Icinga \Module \Notifications \Test \BaseApiV1TestCase ;
6+ use WebSocket \Base ;
67
78class ApiV1ChannelsTest extends BaseApiV1TestCase
89{
@@ -12,14 +13,14 @@ class ApiV1ChannelsTest extends BaseApiV1TestCase
1213 public function testGetWithMatchingFilter (): void
1314 {
1415 $ expected = $ this ->jsonEncodeResults ([
15- 'id ' => ' 0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' ,
16+ 'id ' => BaseApiV1TestCase:: CHANNEL_UUID ,
1617 'name ' => 'Test ' ,
1718 'type ' => 'email ' ,
1819 'config ' => null ,
1920 ]);
2021
2122 // filter by id
22- $ response = $ this ->sendRequest ('GET ' , 'channels?id=0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' );
23+ $ response = $ this ->sendRequest ('GET ' , 'channels?id= ' . BaseApiV1TestCase:: CHANNEL_UUID );
2324 $ content = $ response ->getBody ()->getContents ();
2425
2526 $ this ->assertSame (200 , $ response ->getStatusCode (), $ content );
@@ -40,7 +41,10 @@ public function testGetWithMatchingFilter(): void
4041 $ this ->assertSame ($ expected , $ content );
4142
4243 // filter by all available filters together
43- $ response = $ this ->sendRequest ('GET ' , 'channels?id=0817d973-398e-41d7-9cd2-61cdb7ef41a1&name=Test&type=email ' );
44+ $ response = $ this ->sendRequest (
45+ 'GET ' ,
46+ 'channels?id= ' . BaseApiV1TestCase::CHANNEL_UUID . '&name=Test&type=email '
47+ );
4448 $ content = $ response ->getBody ()->getContents ();
4549
4650 $ this ->assertSame (200 , $ response ->getStatusCode (), $ content );
@@ -58,13 +62,13 @@ public function testGetEverything(): void
5862
5963 $ expected = $ this ->jsonEncodeResults ([
6064 [
61- 'id ' => ' 0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' ,
65+ 'id ' => BaseApiV1TestCase:: CHANNEL_UUID ,
6266 'name ' => 'Test ' ,
6367 'type ' => 'email ' ,
6468 'config ' => null ,
6569 ],
6670 [
67- 'id ' => ' 0817d973-398e-41d7-9cd2-61cdb7ef41a2 ' ,
71+ 'id ' => BaseApiV1TestCase:: CHANNEL_UUID_2 ,
6872 'name ' => 'Test2 ' ,
6973 'type ' => 'webhook ' ,
7074 'config ' => null ,
@@ -79,11 +83,11 @@ public function testGetEverything(): void
7983 */
8084 public function testGetWithAlreadyExistingIdentifier (): void
8185 {
82- $ response = $ this ->sendRequest ('GET ' , 'channels/0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' );
86+ $ response = $ this ->sendRequest ('GET ' , 'channels/ ' . BaseApiV1TestCase:: CHANNEL_UUID );
8387 $ content = $ response ->getBody ()->getContents ();
8488
8589 $ expected = $ this ->jsonEncodeResult ([
86- 'id ' => ' 0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' ,
90+ 'id ' => BaseApiV1TestCase:: CHANNEL_UUID ,
8791 'name ' => 'Test ' ,
8892 'type ' => 'email ' ,
8993 'config ' => null ,
@@ -124,7 +128,7 @@ public function testGetWithInvalidFilter(): void
124128 */
125129 public function testGetWithNewIdentifier (): void
126130 {
127- $ response = $ this ->sendRequest ('GET ' , 'channels/0817d973-398e-41d7-9ef2-61cdb7ef41a2 ' );
131+ $ response = $ this ->sendRequest ('GET ' , 'channels/ ' . BaseApiV1TestCase:: UUID_INCOMPLETE . ' 01 ' );
128132 $ content = $ response ->getBody ()->getContents ();
129133
130134 $ this ->assertSame (404 , $ response ->getStatusCode (), $ content );
@@ -136,7 +140,7 @@ public function testGetWithNewIdentifier(): void
136140 */
137141 public function testGetWithInvalidIdentifier (): void
138142 {
139- $ response = $ this ->sendRequest ('GET ' , 'channels/0817d973-398e-41d7-9ef2-61cdb7ef41a234534 ' );
143+ $ response = $ this ->sendRequest ('GET ' , 'channels/ ' . BaseApiV1TestCase:: UUID_INCOMPLETE );
140144 $ content = $ response ->getBody ()->getContents ();
141145
142146 $ this ->assertSame (400 , $ response ->getStatusCode (), $ content );
@@ -153,14 +157,17 @@ public function testGetWithIdentifierAndFilter(): void
153157 );
154158
155159 // Valid identifier and valid filter
156- $ response = $ this ->sendRequest ('GET ' , 'channels/0817d973-398e-41d7-9cd2-61cdb7ef41a1 ?name=Test ' );
160+ $ response = $ this ->sendRequest ('GET ' , 'channels/ ' . BaseApiV1TestCase:: CHANNEL_UUID . ' ?name=Test ' );
157161 $ content = $ response ->getBody ()->getContents ();
158162
159163 $ this ->assertSame (400 , $ response ->getStatusCode (), $ content );
160164 $ this ->assertSame ($ expected , $ content );
161165
162166 // Invalid identifier and invalid filter
163- $ response = $ this ->sendRequest ('GET ' , 'channels/0817d973-398e-41d7-9cd2-61cdb7ef41aa?nonexistingfilter=value ' );
167+ $ response = $ this ->sendRequest (
168+ 'GET ' ,
169+ 'channels/ ' . BaseApiV1TestCase::CHANNEL_UUID . '?nonexistingfilter=value '
170+ );
164171 $ content = $ response ->getBody ()->getContents ();
165172
166173 $ this ->assertSame (400 , $ response ->getStatusCode (), $ content );
@@ -193,7 +200,7 @@ public function testRequestWithNonSupportedMethod(): void
193200 $ this ->assertSame ($ expected , $ content );
194201
195202 // Try to POST with identifier
196- $ response = $ this ->sendRequest ('POST ' , 'channels/0817d973-398e-41d7-9cd2-61cdb7ef41a1 ' );
203+ $ response = $ this ->sendRequest ('POST ' , 'channels/ ' . BaseApiV1TestCase:: CHANNEL_UUID );
197204 $ content = $ response ->getBody ()->getContents ();
198205
199206 $ this ->assertSame (405 , $ response ->getStatusCode (), $ content );
@@ -209,7 +216,7 @@ public function testRequestWithNonSupportedMethod(): void
209216 $ this ->assertSame ($ expected , $ content );
210217
211218 // Try to POST with identifier and filter
212- $ response = $ this ->sendRequest ('POST ' , 'channels/0817d973-398e-41d7-9cd2-61cdb7ef41a1 ?name=Test ' );
219+ $ response = $ this ->sendRequest ('POST ' , 'channels/ ' . BaseApiV1TestCase:: CHANNEL_UUID . ' ?name=Test ' );
213220 $ content = $ response ->getBody ()->getContents ();
214221
215222 $ this ->assertSame (405 , $ response ->getStatusCode (), $ content );
0 commit comments