Skip to content

Commit 081b5b6

Browse files
author
Matt Gaunt
committed
Fixing up tests to hopefully pass
1 parent 72ea2a3 commit 081b5b6

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@ following commands:
2020
**For a Single Test**
2121
`php phpunit.phar . --filter "/::testPadPayload( .*)?$/"` (regex)
2222

23-
Some tests have a custom decorator @skipIfTravis. The reason is that
24-
there's no way in Travis to update the push subscription, so the endpoint
25-
in my phpunit.travis.xml would ultimately expire
26-
(and require a human modification), and the corresponding tests would fail.
2723
But locally, these tests are handy.

tests/PushServiceTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class PushServiceTest extends PHPUnit_Framework_TestCase
3333
* detect current OS, we can probably run this automatically
3434
* for Linux and OS X at a later date.
3535
*/
36-
protected function checkRequirements()
36+
/** protected function checkRequirements()
3737
{
3838
parent::checkRequirements();
3939
4040
if (!(getenv('TRAVIS') || getenv('CI'))) {
4141
$this->markTestSkipped('This test does not run on Travis.');
4242
}
43-
}
43+
}**/
4444

4545
public static function setUpBeforeClass()
4646
{
@@ -77,9 +77,6 @@ public function browserProvider()
7777
{
7878
return array(
7979
// Web Push
80-
array('chrome', 'stable', array()),
81-
array('chrome', 'beta', array()),
82-
array('chrome', 'unstable', array()),
8380
array('firefox', 'stable', array()),
8481
array('firefox', 'beta', array()),
8582
array('firefox', 'unstable', array()),

tests/WebPushTest.php

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,41 @@ protected function checkRequirements()
2424
{
2525
parent::checkRequirements();
2626

27-
if (!array_key_exists('skipIfTravis', $this->getAnnotations()['method'])) {
28-
return;
29-
}
30-
3127
if (getenv('TRAVIS') || getenv('CI')) {
3228
$this->markTestSkipped('This test does not run on Travis.');
3329
}
30+
31+
if (!getenv('STANDARD_ENDPOINT')) {
32+
$this->markTestSkipped('No \'STANDARD_ENDPOINT\' found in env.');
33+
}
34+
35+
if (!getenv('GCM_ENDPOINT')) {
36+
$this->markTestSkipped('No \'GCM_ENDPOINT\' found in env.');
37+
}
38+
39+
if (!getenv('USER_PUBLIC_KEY')) {
40+
$this->markTestSkipped('No \'USER_PUBLIC_KEY\' found in env.');
41+
}
42+
43+
if (!getenv('GCM_USER_PUBLIC_KEY')) {
44+
$this->markTestSkipped('No \'GCM_USER_PUBLIC_KEY\' found in env.');
45+
}
46+
47+
if (!getenv('USER_AUTH_TOKEN')) {
48+
$this->markTestSkipped('No \'USER_PUBLIC_KEY\' found in env.');
49+
}
50+
51+
if (!getenv('GCM_USER_AUTH_TOKEN')) {
52+
$this->markTestSkipped('No \'GCM_USER_AUTH_TOKEN\' found in env.');
53+
}
54+
55+
if (!getenv('VAPID_PUBLIC_KEY')) {
56+
$this->markTestSkipped('No \'VAPID_PUBLIC_KEY\' found in env.');
57+
}
58+
59+
if (!getenv('VAPID_PRIVATE_KEY')) {
60+
$this->markTestSkipped('No \'VAPID_PRIVATE_KEY\' found in env.');
61+
}
3462
}
3563

3664
public static function setUpBeforeClass()
@@ -77,7 +105,6 @@ public function notificationProvider()
77105

78106
/**
79107
* @dataProvider notificationProvider
80-
* @skipIfTravis
81108
*
82109
* @param string $endpoint
83110
* @param string $payload
@@ -103,9 +130,6 @@ public function testSendNotificationWithTooBigPayload()
103130
);
104131
}
105132

106-
/**
107-
* @skipIfTravis
108-
*/
109133
public function testFlush()
110134
{
111135
$this->webPush->sendNotification(self::$endpoints['standard']);
@@ -118,9 +142,6 @@ public function testFlush()
118142
$this->assertTrue($this->webPush->flush());
119143
}
120144

121-
/**
122-
* @skipIfTravis
123-
*/
124145
public function testSendGCMNotificationWithoutGCMApiKey()
125146
{
126147
$webPush = new WebPush();
@@ -129,9 +150,6 @@ public function testSendGCMNotificationWithoutGCMApiKey()
129150
$webPush->sendNotification(self::$endpoints['GCM'], null, null, null, true);
130151
}
131152

132-
/**
133-
* @skipIfTravis
134-
*/
135153
public function testSendGCMNotificationWithWrongGCMApiKey()
136154
{
137155
$webPush = new WebPush(array('GCM' => 'bar'));

0 commit comments

Comments
 (0)