-
Notifications
You must be signed in to change notification settings - Fork 2
/
PushBackTest.php
70 lines (58 loc) · 1.89 KB
/
PushBackTest.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
<?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\PushBack;
use Pusher\Message\PushBackMessage;
class PushBackTest extends TestCase
{
private string $token = '';
private static bool $PASS = false;
public function setUp(): void
{
$token = getenv('PushBackToken');
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通知 User', '[用户方式]本[项目地址](https://github.com/idev-sig/pusher)', 'User_1857', '左侧', '右侧', '回复些消息'],
[ 'Pusher通知 Channel', '[通道方式]本[项目地址](https://github.com/idev-sig/pusher)', 'Channel_2421', '左侧', '右侧', '回复些消息'],
];
}
/**
* @dataProvider additionProvider
*
* @return void
*/
public function testCases(string $title, string $body = '', string $id = '', string $action1 = '', string $action2 = '', string $reply = ''): void
{
$this->skipTest(__METHOD__);
$channel = new PushBack();
$channel->setToken($this->token);
$message = new PushBackMessage($body, $title);
$message->setID($id)
->setAction1($action1)
->setAction2($action2)
->setReply($reply);
$channel->request($message);
$this->assertTrue($channel->getStatus());
}
}