-
Notifications
You must be signed in to change notification settings - Fork 2
/
PushsaferTest.php
151 lines (130 loc) · 10.3 KB
/
PushsaferTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php declare(strict_types=1);
/*
* This file is part of Pusher.
*
* (c) Jetsung Chan <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Pusher\Tests\Channels;
use PHPUnit\Framework\TestCase;
use Pusher\Channel\Pushsafer;
use Pusher\Message\PushsaferMessage;
class PushsaferTest extends TestCase
{
private string $token = '';
## 50 条免费,故跳过测试
private static bool $PASS = true;
public function setUp(): void
{
$token = getenv('PushsaferToken');
if ($token) {
$this->token = $token;
} else {
self::$PASS = true;
}
}
public function skipTest(string $func, bool $skip = false): void
{
if (self::$PASS || $skip) {
$this->markTestSkipped("skip {$func}");
}
}
public static function additionProvider(): array
{
return [
[
'Pusher通知标题一',
'Pushsafer 测试。项目地址:https://github.com/idev-sig/pusher <strong>测试一下</strong>',
0,
2,
3,
'#FF0000',
'a',
'https://github.com/idev-sig/pusher',
'链接标题',
'',
],
[
'Pusher通知标题二',
'Pushsafer 测试二。项目地址:https://github.com/idev-sig/pusher <strong>测试一下</strong>',
2,
1,
181,
'#0000FF',
'a',
'https://github.com/idev-sig/pusher',
'链接标题二',
'',
],
];
}
public static function additionProviderImage(): array
{
$base64 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfIAAAClCAMAAACQs48ZAAA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wHyQ66CPIxSU5VackfeoL95BcIBAKBQCAQCAQCgUAgEAgEAoFAIBAIBAKB4Ej4DyuRSP4xPo3PAAAAAElFTkSuQmCC';
return [
[ $base64 ],
];
}
/**
* @dataProvider additionProvider
*
* @return void
*/
public function testCases(
string $title,
string $message,
int $sound,
int $vibration,
int $icon,
string $icon_color,
string $device,
string $url,
string $url_title,
string $picture,
): void {
$this->skipTest(__METHOD__);
$channel = new Pushsafer();
$channel->setToken($this->token);
$message = new PushsaferMessage($message, $title);
$message->setSound($sound)
->setVibration($vibration)
->setIcon($icon)
->setIconColor($icon_color)
->setDevice($device)
->setURL($url)
->setUrlTitle($url_title)
->setPicture($picture);
$channel->request($message);
echo "\n";
if (!$channel->getStatus()) {
var_dump($channel->getContents());//, $channel->getContents());
}
$this->assertTrue($channel->getStatus());
}
/**
* @dataProvider additionProviderImage
*
* @return void
*/
public function testImageCases(string $picture): void
{
$this->skipTest(__METHOD__);
$channel = new Pushsafer();
$channel->setToken($this->token);
$message = '<strong>这是一条图片消息,<a href="https://github.com/idev-sig/pusher">项目地址</a></strong>';
$title = '这是一条图片消息';
$message = new PushsaferMessage($message, $title);
$message->setSound(50)
->setVibration(3)
->setIcon(50)
->setPicture($picture);
$channel->request($message);
echo "\n";
if (!$channel->getStatus()) {
var_dump($channel->getErrMessage());//, $channel->getContents());
}
$this->assertTrue($channel->getStatus());
}
}