]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - tests/CommandInterperterTest.php
EmailRegistration plugin flow requires a confirmation address before user creation
[quix0rs-gnu-social.git] / tests / CommandInterperterTest.php
1 <?php
2
3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4     print "This script must be run from the command line\n";
5     exit();
6 }
7
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('GNUSOCIAL', true);
10 define('STATUSNET', true);  // compatibility
11
12 require_once INSTALLDIR . '/lib/common.php';
13
14 class CommandInterpreterTest extends PHPUnit_Framework_TestCase
15 {
16
17     /**
18      * @dataProvider commandInterpreterCases
19      */
20     public function testCommandInterpreter($input, $expectedType, $comment='')
21     {
22         $inter = new CommandInterpreter();
23
24         $cmd = $inter->handle_command(null, $input);
25
26         $type = $cmd ? get_class($cmd) : null;
27         $this->assertEquals(strtolower($expectedType), strtolower($type), $comment);
28     }
29
30     static public function commandInterpreterCases()
31     {
32         $sets = array(
33             array('help', 'HelpCommand'),
34             array('help me bro', null, 'help does not accept multiple params'),
35             array('HeLP', 'HelpCommand', 'case check'),
36             array('HeLP Me BRO!', null, 'case & non-params check'),
37
38             array('login', 'LoginCommand'),
39             array('login to savings!', null, 'login does not accept params'),
40
41             array('lose', null, 'lose must have at least 1 parameter'),
42             array('lose foobar', 'LoseCommand', 'lose requires 1 parameter'),
43             array('lose        foobar', 'LoseCommand', 'check for space norm'),
44             array('lose more weight', null, 'lose does not accept multiple params'),
45
46             array('subscribers', 'SubscribersCommand'),
47             array('subscribers foo', null, 'subscribers does not take params'),
48
49             array('subscriptions', 'SubscriptionsCommand'),
50             array('subscriptions foo', null, 'subscriptions does not take params'),
51
52             array('groups', 'GroupsCommand'),
53             array('groups foo', null, 'groups does not take params'),
54
55             array('off', 'OffCommand', 'off accepts 0 or 1 params'),
56             array('off foo', 'OffCommand', 'off accepts 0 or 1 params'),
57             array('off foo bar', null, 'off accepts 0 or 1 params'),
58
59             array('stop', 'OffCommand', 'stop accepts 0 params'),
60             array('stop foo', null, 'stop accepts 0 params'),
61
62             array('quit', 'OffCommand', 'quit accepts 0 params'),
63             array('quit foo', null, 'quit accepts 0 params'),
64
65             array('on', 'OnCommand', 'on accepts 0 or 1 params'),
66             array('on foo', 'OnCommand', 'on accepts 0 or 1 params'),
67             array('on foo bar', null, 'on accepts 0 or 1 params'),
68
69             array('join', null),
70             array('join foo', 'JoinCommand'),
71             array('join foo bar', null),
72
73             array('drop', null),
74             array('drop foo', 'DropCommand'),
75             array('drop foo bar', null),
76
77             array('follow', null),
78             array('follow foo', 'SubCommand'),
79             array('follow foo bar', null),
80
81             array('sub', null),
82             array('sub foo', 'SubCommand'),
83             array('sub foo bar', null),
84
85             array('leave', null),
86             array('leave foo', 'UnsubCommand'),
87             array('leave foo bar', null),
88
89             array('unsub', null),
90             array('unsub foo', 'UnsubCommand'),
91             array('unsub foo bar', null),
92
93             array('leave', null),
94             array('leave foo', 'UnsubCommand'),
95             array('leave foo bar', null),
96
97             array('d', null),
98             array('d foo', null),
99             array('d foo bar', 'MessageCommand'),
100
101             array('dm', null),
102             array('dm foo', null),
103             array('dm foo bar', 'MessageCommand'),
104
105             array('r', null),
106             array('r foo', null),
107             array('r foo bar', 'ReplyCommand'),
108
109             array('reply', null),
110             array('reply foo', null),
111             array('reply foo bar', 'ReplyCommand'),
112
113             array('repeat', null),
114             array('repeat foo', 'RepeatCommand'),
115             array('repeat foo bar', null),
116
117             array('rp', null),
118             array('rp foo', 'RepeatCommand'),
119             array('rp foo bar', null),
120
121             array('rt', null),
122             array('rt foo', 'RepeatCommand'),
123             array('rt foo bar', null),
124
125             array('rd', null),
126             array('rd foo', 'RepeatCommand'),
127             array('rd foo bar', null),
128
129             array('whois', null),
130             array('whois foo', 'WhoisCommand'),
131             array('whois foo bar', null),
132
133 /*            array('fav', null),
134             array('fav foo', 'FavCommand'),
135             array('fav foo bar', null),*/
136
137             array('nudge', null),
138             array('nudge foo', 'NudgeCommand'),
139             array('nudge foo bar', null),
140
141             array('stats', 'StatsCommand'),
142             array('stats foo', null),
143
144             array('invite', null),
145             array('invite foo', 'InviteCommand'),
146             array('invite foo bar', null),
147
148             array('track', null),
149             array('track foo', 'SearchSubTrackCommand'),
150             array('track off', 'SearchSubTrackOffCommand'),
151             array('track foo bar', null),
152             array('track off foo', null),
153
154             array('untrack', null),
155             array('untrack foo', 'SearchSubUntrackCommand'),
156             array('untrack all', 'SearchSubTrackOffCommand'),
157             array('untrack foo bar', null),
158             array('untrack all foo', null),
159
160             array('tracking', 'SearchSubTrackingCommand'),
161             array('tracking foo', null),
162
163             array('tracks', 'SearchSubTrackingCommand'),
164             array('tracks foo', null),
165
166         );
167         return $sets;
168     }
169
170 }
171