1+ <?php
2+
3+ require_once '../vendor/autoload.php ' ;
4+
5+ use JPush \Model as M ;
6+ use JPush \JPushClient ;
7+
8+ class DeviceTest extends PHPUnit_Framework_TestCase {
9+ public $ appKey = "dd1066407b044738b6479275 " ;
10+ public $ masterSecret = '2b38ce69b1de2a7fa95706ea ' ;
11+
12+ public $ TAG1 = "tag1 " ;
13+ public $ TAG2 = "tag2 " ;
14+ public $ TAG3 = "tag3 " ;
15+ public $ TAG4 = "tag4 " ;
16+ public $ ALIAS1 = "alias1 " ;
17+ public $ ALIAS2 = "alias2 " ;
18+ public $ REGISTRATION_ID1 = "0900e8d85ef " ;
19+ public $ REGISTRATION_ID2 = "0a04ad7d8b4 " ;
20+
21+ /*----RegistrationId Tests----*/
22+ function testGetDeviceTagAlias () {
23+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
24+ $ result = $ client ->getDeviceTagAlias ($ this ->REGISTRATION_ID1 );
25+ $ this ->assertTrue ($ result ->isOk === true );
26+ }
27+ function testRemoveDeviceTag () {
28+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
29+ $ result = $ client ->removeDeviceTag ($ this ->REGISTRATION_ID1 );
30+ $ this ->assertTrue ($ result ->isOk === true );
31+ }
32+ function testRemoveDeviceAlias () {
33+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
34+ $ result = $ client ->removeDeviceAlias ($ this ->REGISTRATION_ID1 );
35+ $ this ->assertTrue ($ result ->isOk === true );
36+ }
37+ function testUpdateDeviceTagAlias () {
38+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
39+ $ result = $ client ->updateDeviceTagAlias ($ this ->REGISTRATION_ID1 , $ this ->ALIAS1 , array ($ this ->TAG1 , $ this ->TAG2 ), array ($ this ->TAG3 , $ this ->TAG4 ));
40+ $ this ->assertTrue ($ result ->isOk === true );
41+ }
42+ /*----Tag Tests----*/
43+
44+ function testGetTags () {
45+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
46+ $ result = $ client ->getTags ();
47+ $ this ->assertTrue ($ result ->isOk === true );
48+ }
49+ function testIsDeviceInTag () {
50+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
51+ $ result = $ client ->isDeviceInTag ($ this ->REGISTRATION_ID1 , $ this ->TAG1 );
52+ $ this ->assertTrue ($ result ->isOk === true );
53+ }
54+ function testUpdateTagDevices () {
55+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
56+ $ result = $ client ->updateTagDevices ($ this ->TAG1 , array ($ this ->REGISTRATION_ID1 ), array ($ this ->REGISTRATION_ID2 ));
57+ $ this ->assertTrue ($ result ->isOk === true );
58+ }
59+ function testDeleteUpdate () {
60+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
61+ $ result = $ client ->deleteAlias ($ this ->TAG4 );
62+ $ this ->assertTrue ($ result ->isOk === true );
63+ }
64+
65+ /*----Alias Tests----*/
66+ function testGetAliasDevices () {
67+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
68+ $ result = $ client ->getAliasDevices ($ this ->ALIAS1 );
69+ $ this ->assertTrue ($ result ->isOk === true );
70+ }
71+
72+ function testGetAliasDevices2 () {
73+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
74+ $ result = $ client ->getAliasDevices ($ this ->ALIAS1 , array ('ios ' , 'android ' ));
75+ $ this ->assertTrue ($ result ->isOk === true );
76+ }
77+ function testDeleteAlias () {
78+ $ client = new JPushClient ($ this ->appKey , $ this ->masterSecret );
79+ $ result = $ client ->deleteAlias ($ this ->ALIAS2 );
80+ $ this ->assertTrue ($ result ->isOk === true );
81+ }
82+ }
0 commit comments