-
Notifications
You must be signed in to change notification settings - Fork 2
/
TechulusTest.php
68 lines (56 loc) · 1.73 KB
/
TechulusTest.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
<?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\Techulus;
use Pusher\Message\TechulusMessage;
class TechulusTest extends TestCase
{
private string $token = '';
## 每月只能发 30 条信息,故跳过单元测试
private static bool $PASS = true;
public function setUp(): void
{
$token = getenv('TechulusToken');
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 [
[ '文本标题一', '不支持 HTML 和 Markdown。项目地址:https://github.com/idev-sig/pusher', 'https://github.com/idev-sig/pusher', 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'],
];
}
/**
* @dataProvider additionProvider
*
* @return void
*/
public function testCases(string $text, string $body, string $link, string $image): void
{
$this->skipTest(__METHOD__);
$channel = new Techulus();
$channel->setToken($this->token);
$message = new TechulusMessage($body, $text);
$message->setLink($link)
->setImage($image);
$channel->request($message);
$this->assertTrue($channel->getStatus());
}
}