Skip to content

Commit ac93633

Browse files
authored
Merge pull request #69 from Nyholm/patch-test-1
Make sure we got a new and clean dispatcher at each test
2 parents 8c0b984 + ac85dc5 commit ac93633

5 files changed

+28
-46
lines changed

src/AppBundle/Tests/Subscriber/AutoLabelPRFromContentSubscriberTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ class AutoLabelPRFromContentSubscriberTest extends \PHPUnit_Framework_TestCase
1919
/**
2020
* @var EventDispatcher
2121
*/
22-
private static $dispatcher;
23-
24-
public static function setUpBeforeClass()
25-
{
26-
self::$dispatcher = new EventDispatcher();
27-
}
22+
private $dispatcher;
2823

2924
protected function setUp()
3025
{
@@ -34,7 +29,8 @@ protected function setUp()
3429
$this->autoLabelSubscriber = new AutoLabelPRFromContentSubscriber($this->labelsApi);
3530
$this->repository = new Repository('weaverryan', 'symfony', [], null);
3631

37-
self::$dispatcher->addSubscriber($this->autoLabelSubscriber);
32+
$this->dispatcher = new EventDispatcher();
33+
$this->dispatcher->addSubscriber($this->autoLabelSubscriber);
3834
}
3935

4036
/**
@@ -56,7 +52,7 @@ public function testAutoLabel($prTitle, $prBody, array $expectedNewLabels)
5652
),
5753
), $this->repository);
5854

59-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
55+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
6056

6157
$responseData = $event->getResponseData();
6258

src/AppBundle/Tests/Subscriber/BugLabelNewIssueSubscriberTest.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@ class BugLabelNewIssueSubscriberTest extends \PHPUnit_Framework_TestCase
2020
/**
2121
* @var EventDispatcher
2222
*/
23-
private static $dispatcher;
23+
private $dispatcher;
2424

25-
public static function setUpBeforeClass()
26-
{
27-
self::$dispatcher = new EventDispatcher();
28-
}
2925

3026
protected function setUp()
3127
{
3228
$this->statusApi = $this->getMock('AppBundle\Issues\StatusApi');
3329
$this->bugLabelSubscriber = new BugLabelNewIssueSubscriber($this->statusApi);
3430
$this->repository = new Repository('weaverryan', 'symfony', [], null);
3531

36-
self::$dispatcher->addSubscriber($this->bugLabelSubscriber);
32+
$this->dispatcher = new EventDispatcher();
33+
$this->dispatcher->addSubscriber($this->bugLabelSubscriber);
3734
}
3835

3936
public function testOnIssuesLabeledBug()
@@ -53,7 +50,7 @@ public function testOnIssuesLabeledBug()
5350
'label' => array('name' => 'bug'),
5451
), $this->repository);
5552

56-
self::$dispatcher->dispatch(GitHubEvents::ISSUES, $event);
53+
$this->dispatcher->dispatch(GitHubEvents::ISSUES, $event);
5754

5855
$responseData = $event->getResponseData();
5956

@@ -79,7 +76,7 @@ public function testOnIssuesLabeledBugIgnoresCase()
7976
'label' => array('name' => 'BUG'),
8077
), $this->repository);
8178

82-
self::$dispatcher->dispatch(GitHubEvents::ISSUES, $event);
79+
$this->dispatcher->dispatch(GitHubEvents::ISSUES, $event);
8380

8481
$responseData = $event->getResponseData();
8582

@@ -102,7 +99,7 @@ public function testOnIssuesIgnoresNonBugs()
10299
'label' => array('name' => 'feature'),
103100
), $this->repository);
104101

105-
self::$dispatcher->dispatch(GitHubEvents::ISSUES, $event);
102+
$this->dispatcher->dispatch(GitHubEvents::ISSUES, $event);
106103

107104
$responseData = $event->getResponseData();
108105

@@ -127,7 +124,7 @@ public function testOnIssuesIgnoresIfExistingStatus()
127124
'label' => array('name' => 'bug'),
128125
), $this->repository);
129126

130-
self::$dispatcher->dispatch(GitHubEvents::ISSUES, $event);
127+
$this->dispatcher->dispatch(GitHubEvents::ISSUES, $event);
131128

132129
$responseData = $event->getResponseData();
133130

@@ -150,7 +147,7 @@ public function testOnIssuesIgnoresNonLabeled()
150147
'label' => array('name' => 'bug'),
151148
), $this->repository);
152149

153-
self::$dispatcher->dispatch(GitHubEvents::ISSUES, $event);
150+
$this->dispatcher->dispatch(GitHubEvents::ISSUES, $event);
154151

155152
$responseData = $event->getResponseData();
156153

src/AppBundle/Tests/Subscriber/NeedsReviewNewPRSubscriberTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,16 @@ class NeedsReviewNewPRSubscriberTest extends \PHPUnit_Framework_TestCase
2020
/**
2121
* @var EventDispatcher
2222
*/
23-
private static $dispatcher;
24-
25-
public static function setUpBeforeClass()
26-
{
27-
self::$dispatcher = new EventDispatcher();
28-
}
23+
private $dispatcher;
2924

3025
protected function setUp()
3126
{
3227
$this->statusApi = $this->getMock('AppBundle\Issues\StatusApi');
3328
$this->needsReviewSubscriber = new NeedsReviewNewPRSubscriber($this->statusApi);
3429
$this->repository = new Repository('weaverryan', 'symfony', [], null);
3530

36-
self::$dispatcher->addSubscriber($this->needsReviewSubscriber);
31+
$this->dispatcher = new EventDispatcher();
32+
$this->dispatcher->addSubscriber($this->needsReviewSubscriber);
3733
}
3834

3935
public function testOnPullRequestOpen()
@@ -47,7 +43,7 @@ public function testOnPullRequestOpen()
4743
'pull_request' => array('number' => 1234),
4844
), $this->repository);
4945

50-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
46+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
5147

5248
$responseData = $event->getResponseData();
5349

@@ -65,7 +61,7 @@ public function testOnPullRequestNotOpen()
6561
'action' => 'close',
6662
), $this->repository);
6763

68-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
64+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
6965

7066
$responseData = $event->getResponseData();
7167

src/AppBundle/Tests/Subscriber/StatusChangeByCommentSubscriberTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ class StatusChangeByCommentSubscriberTest extends \PHPUnit_Framework_TestCase
2020
/**
2121
* @var EventDispatcher
2222
*/
23-
private static $dispatcher;
24-
25-
public static function setUpBeforeClass()
26-
{
27-
self::$dispatcher = new EventDispatcher();
28-
}
23+
private $dispatcher;
2924

3025
protected function setUp()
3126
{
@@ -34,7 +29,8 @@ protected function setUp()
3429
$this->statusChangeSubscriber = new StatusChangeByCommentSubscriber($this->statusApi, $logger);
3530
$this->repository = new Repository('weaverryan', 'symfony', [], null);
3631

37-
self::$dispatcher->addSubscriber($this->statusChangeSubscriber);
32+
$this->dispatcher = new EventDispatcher();
33+
$this->dispatcher->addSubscriber($this->statusChangeSubscriber);
3834
}
3935

4036
/**
@@ -53,7 +49,7 @@ public function testOnIssueComment($comment, $expectedStatus)
5349
'comment' => array('body' => $comment, 'user' => ['login' => 'leannapelham']),
5450
), $this->repository);
5551

56-
self::$dispatcher->dispatch(GitHubEvents::ISSUE_COMMENT, $event);
52+
$this->dispatcher->dispatch(GitHubEvents::ISSUE_COMMENT, $event);
5753

5854
$responseData = $event->getResponseData();
5955

@@ -121,7 +117,7 @@ public function testOnIssueCommentAuthorSelfReview()
121117
),
122118
), $this->repository);
123119

124-
self::$dispatcher->dispatch(GitHubEvents::ISSUE_COMMENT, $event);
120+
$this->dispatcher->dispatch(GitHubEvents::ISSUE_COMMENT, $event);
125121

126122
$responseData = $event->getResponseData();
127123

src/AppBundle/Tests/Subscriber/StatusChangeOnPushSubscriberTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@ class StatusChangeOnPushSubscriberTest extends \PHPUnit_Framework_TestCase
2020
/**
2121
* @var EventDispatcher
2222
*/
23-
private static $dispatcher;
23+
private $dispatcher;
2424

25-
public static function setUpBeforeClass()
26-
{
27-
self::$dispatcher = new EventDispatcher();
28-
}
2925

3026
protected function setUp()
3127
{
3228
$this->statusApi = $this->getMock('AppBundle\Issues\StatusApi');
3329
$this->statusChangeSubscriber = new StatusChangeOnPushSubscriber($this->statusApi);
3430
$this->repository = new Repository('weaverryan', 'symfony', [], null);
3531

36-
self::$dispatcher->addSubscriber($this->statusChangeSubscriber);
32+
$this->dispatcher = new EventDispatcher();
33+
$this->dispatcher->addSubscriber($this->statusChangeSubscriber);
3734
}
3835

3936
/**
@@ -57,7 +54,7 @@ public function testOnPushingCommits($currentStatus, $statusChange)
5754
'pull_request' => $this->getPullRequestData(),
5855
], $this->repository);
5956

60-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
57+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
6158

6259
$responseData = $event->getResponseData();
6360

@@ -88,7 +85,7 @@ public function testOnNonPushPullRequestEvent()
8885
'pull_request' => $this->getPullRequestData(),
8986
), $this->repository);
9087

91-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
88+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
9289

9390
$responseData = $event->getResponseData();
9491

@@ -108,7 +105,7 @@ public function testWipPullRequest()
108105
'pull_request' => $this->getPullRequestData('[wip] needs some more work.'),
109106
), $this->repository);
110107

111-
self::$dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
108+
$this->dispatcher->dispatch(GitHubEvents::PULL_REQUEST, $event);
112109

113110
$responseData = $event->getResponseData();
114111

0 commit comments

Comments
 (0)