Skip to content

Commit c24b03a

Browse files
add tests for wrong request methods
1 parent aea57e3 commit c24b03a

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

tests/BitBucketHookTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,11 @@ public function testHookShouldGiveErrorWhenInvalidEventIsWatched()
218218

219219
$this->assertSame($this->response(), "Can't watch an invalid event");
220220
}
221+
222+
public function testHookShouldGiveErrorWhenUsingGetRequest()
223+
{
224+
$this->event('repo:push');
225+
226+
$this->assertSame($this->tryGetResponse(), 'Wrong request method');
227+
}
221228
}

tests/GitHubHookTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,11 @@ public function testHookShouldGiveErrorWhenInvalidEventIsWatched()
345345

346346
$this->assertSame($this->response(), "Can't watch an invalid event");
347347
}
348+
349+
public function testHookShouldGiveErrorWhenUsingGetRequest()
350+
{
351+
$this->event('push');
352+
353+
$this->assertSame($this->tryGetResponse(), 'Wrong request method');
354+
}
348355
}

tests/GitLabHookTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,11 @@ public function testHookShouldGiveErrorWhenInvalidEventIsWatched()
191191

192192
$this->assertSame($this->response(), "Can't watch an invalid event");
193193
}
194+
195+
public function testHookShouldGiveErrorWhenUsingGetRequest()
196+
{
197+
$this->event('Push Hook');
198+
199+
$this->assertSame($this->tryGetResponse(), 'Wrong request method');
200+
}
194201
}

tests/TestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,17 @@ public function response()
108108
'json' => json_decode($this->payload, true),
109109
])->getBody();
110110
}
111+
112+
/**
113+
* Try to perform a GET request.
114+
*
115+
* @return string
116+
*/
117+
public function tryGetResponse()
118+
{
119+
return (string) $this->client->request('GET', '', [
120+
'query' => $this->query,
121+
'headers' => $this->headers,
122+
])->getBody();
123+
}
111124
}

0 commit comments

Comments
 (0)