@@ -42,6 +42,18 @@ public function testSendNotification()
42
42
$ this ->assertEquals (true , $ res ['success ' ]);
43
43
}
44
44
45
+ public function testSendNotificationWithPayload ()
46
+ {
47
+ $ res = $ this ->webPush ->sendNotification (
48
+ $ this ->endpoints ['standard ' ],
49
+ 'test ' ,
50
+ $ this ->keys ['standard ' ]
51
+ );
52
+
53
+ $ this ->assertArrayHasKey ('success ' , $ res );
54
+ $ this ->assertEquals (true , $ res ['success ' ]);
55
+ }
56
+
45
57
public function testSendGCMNotification ()
46
58
{
47
59
$ res = $ this ->webPush ->sendNotification ($ this ->endpoints ['GCM ' ]);
@@ -71,4 +83,25 @@ public function testSendGCMNotificationWithWrongGCMApiKey()
71
83
72
84
$ this ->assertArrayHasKey ('headers ' , $ res );
73
85
}
86
+
87
+ public function testEncrypt ()
88
+ {
89
+ // encrypt is a private method
90
+ $ class = new ReflectionClass (get_class ($ this ->webPush ));
91
+ $ encrypt = $ class ->getMethod ('encrypt ' );
92
+ $ encrypt ->setAccessible (true );
93
+
94
+ $ expected = array (
95
+ 'localPublicKey ' => 'BH_1HZcs53fCIMW7Q6ePJqCqc4JIzSeCTjcNBmoet2eMObvQTpiBHH0EnDYZ0kTqk5f2b6wruq7US1vewtngt6o ' ,
96
+ 'salt ' => '0HK6QfkQmcQKFVAgG2iOTw ' ,
97
+ 'cipherText ' => 'ivmuewrVd-7qkRgxRcu972JyrSvXJzbLeWhTXx1FRZndeP5PVS3fnLQhmK077PgW7C5MLAA_wzDpIN_oB9vo ' ,
98
+ );
99
+
100
+ $ actualUserPublicKey = 'BDFsuXPNuJ4SxoYcVVvRagonMcSKHXjsif4qmzpXTDyy29ZKqbwtVAgHCLJGP0HgQ0hpkg6H5-fPBvDjBQxjYfc ' ;
101
+ $ actualPayload = '{"action":"chatMsg","name":"Bob","msg":"test"} ' ;
102
+
103
+ $ actual = $ encrypt ->invokeArgs ($ this ->webPush , array ($ actualUserPublicKey , $ actualPayload ));
104
+
105
+ $ this ->assertEquals ($ expected , $ actual );
106
+ }
74
107
}
0 commit comments