1+ <?php
2+ /**
3+ * LICENSE
4+ *
5+ * Copyright © 2016-2018 Teclib'
6+ * Copyright © 2010-2018 by the FusionInventory Development Team.
7+ *
8+ * This file is part of Flyve MDM Plugin for GLPI.
9+ *
10+ * Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
11+ * device management software.
12+ *
13+ * Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
14+ * modify it under the terms of the GNU Affero General Public License as published
15+ * by the Free Software Foundation, either version 3 of the License, or
16+ * (at your option) any later version.
17+ * Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
18+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+ * GNU Affero General Public License for more details.
21+ * You should have received a copy of the GNU Affero General Public License
22+ * along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
23+ * ------------------------------------------------------------------------------
24+ * @author Domingo Oropeza <[email protected] > 25+ * @copyright Copyright © 2018 Teclib
26+ * @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
27+ * @link https://github.com/flyve-mdm/glpi-plugin
28+ * @link https://flyve-mdm.com/
29+ * ------------------------------------------------------------------------------
30+ */
31+
32+ namespace tests \units \GlpiPlugin \Flyvemdm \Fcm ;
33+
34+
35+ use Flyvemdm \Tests \CommonTestCase ;
36+
37+ class FcmEnvelope extends CommonTestCase {
38+
39+ private $ scope = [['type ' => 'fcm ' , 'token ' => 'Sup3rT0k3n ' ]];
40+ private $ topic = ['lorem/ipsum/dolor ' ];
41+
42+ protected function providerContext () {
43+ return [
44+ 'empty ' => [
45+ 'context ' => [[]],
46+ 'expected ' => 'The scope argument is needed (push type and token) ' ,
47+ ],
48+ 'invalid scope ' => [
49+ 'context ' => ['lorem ' => ['key ' => '' ]],
50+ 'expected ' => 'The scope argument is needed (push type and token) ' ,
51+ ],
52+ 'invalid type ' => [
53+ 'context ' => ['scope ' => [['key ' => '' ]]],
54+ 'expected ' => 'The scope argument is needed (push type and token) ' ,
55+ ],
56+ 'invalid token ' => [
57+ 'context ' => ['scope ' => [['type ' => 'fcm ' ]]],
58+ 'expected ' => 'The scope argument is needed (push type and token) ' ,
59+ ],
60+ 'invalid topic ' => [
61+ 'context ' => ['scope ' => $ this ->scope ],
62+ 'expected ' => 'A topic argument is needed ' ,
63+ ],
64+ ];
65+ }
66+ /**
67+ * @tags testException
68+ * @dataProvider providerContext
69+ * @param array $context
70+ * @param string $expected
71+ */
72+ public function testException ($ context , $ expected ) {
73+ $ this ->exception (function () use ($ context ) {
74+ $ this ->newTestedInstance ($ context );
75+ })->hasMessage ($ expected );
76+ }
77+
78+ /**
79+ * @tags testEnvelope
80+ */
81+ public function testEnvelope () {
82+ $ instance = $ this ->newTestedInstance (['scope ' => $ this ->scope , 'topic ' => $ this ->topic ]);
83+ $ this ->array ($ instance ->getContext ('scope ' ))->child [0 ](function ($ child ) {
84+ $ scope = $ this ->scope [0 ];
85+ $ child ->hasKeys (['type ' , 'token ' ])->values
86+ ->string [0 ]->isEqualTo ($ scope ['type ' ])
87+ ->string [1 ]->isEqualTo ($ scope ['token ' ]);
88+ });
89+ $ context = $ instance ->getContext ('topic ' );
90+ $ this ->string ($ context [0 ])->isEqualTo ('lorem-ipsum-dolor ' );
91+ }
92+
93+ }
0 commit comments