2
2
3
3
namespace App \Tests \Controller ;
4
4
5
+ use App \Issues \StatusApi ;
6
+ use App \Repository \Provider \RepositoryProviderInterface ;
5
7
use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
6
8
7
9
class WebhookControllerTest extends WebTestCase
8
10
{
11
+ private $ client ;
12
+
13
+ public function setup ()
14
+ {
15
+ if ($ this ->client ) {
16
+ return ;
17
+ }
18
+
19
+ $ this ->client = $ this ->createClient ();
20
+ $ repository = self ::$ container ->get (RepositoryProviderInterface::class);
21
+ $ statusApi = self ::$ container ->get (StatusApi::class);
22
+
23
+ // the labels need to be off this issue for one test to pass
24
+ $ statusApi ->setIssueStatus (
25
+ 5 ,
26
+ null ,
27
+ $ repository ->getRepository ('weaverryan/symfony ' )
28
+ );
29
+ }
30
+
9
31
/**
10
32
* @dataProvider getTests
11
33
*/
12
34
public function testIssueComment ($ eventHeader , $ payloadFilename , $ expectedResponse )
13
35
{
14
- $ client = $ this ->createClient () ;
36
+ $ client = $ this ->client ;
15
37
$ body = file_get_contents (__DIR__ .'/../webhook_examples/ ' .$ payloadFilename );
16
38
$ client ->request ('POST ' , '/webhooks/github ' , [], [], ['HTTP_X-Github-Event ' => $ eventHeader ], $ body );
17
39
$ response = $ client ->getResponse ();
@@ -36,7 +58,7 @@ public function getTests()
36
58
'pull_request.opened.json ' ,
37
59
['pull_request ' => 3 , 'status_change ' => 'needs_review ' , 'pr_labels ' => ['Bug ' ]],
38
60
],
39
- 'On issue labeled " bug" ' => [
61
+ 'On issue labeled bug ' => [
40
62
'issues ' ,
41
63
'issues.labeled.bug.json ' ,
42
64
['issue ' => 5 , 'status_change ' => 'needs_review ' ],
0 commit comments