3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('GNUSOCIAL', true);
10 define('STATUSNET', true); // compatibility
12 require_once INSTALLDIR . '/lib/common.php';
14 class CommandInterpreterTest extends PHPUnit_Framework_TestCase
18 * @dataProvider commandInterpreterCases
20 public function testCommandInterpreter($input, $expectedType, $comment='')
22 $inter = new CommandInterpreter();
24 $cmd = $inter->handle_command(null, $input);
26 $type = $cmd ? get_class($cmd) : null;
27 $this->assertEquals(strtolower($expectedType), strtolower($type), $comment);
30 static public function commandInterpreterCases()
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'),
38 array('login', 'LoginCommand'),
39 array('login to savings!', null, 'login does not accept params'),
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'),
46 array('subscribers', 'SubscribersCommand'),
47 array('subscribers foo', null, 'subscribers does not take params'),
49 array('subscriptions', 'SubscriptionsCommand'),
50 array('subscriptions foo', null, 'subscriptions does not take params'),
52 array('groups', 'GroupsCommand'),
53 array('groups foo', null, 'groups does not take params'),
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'),
59 array('stop', 'OffCommand', 'stop accepts 0 params'),
60 array('stop foo', null, 'stop accepts 0 params'),
62 array('quit', 'OffCommand', 'quit accepts 0 params'),
63 array('quit foo', null, 'quit accepts 0 params'),
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'),
70 array('join foo', 'JoinCommand'),
71 array('join foo bar', null),
74 array('drop foo', 'DropCommand'),
75 array('drop foo bar', null),
77 array('follow', null),
78 array('follow foo', 'SubCommand'),
79 array('follow foo bar', null),
82 array('sub foo', 'SubCommand'),
83 array('sub foo bar', null),
86 array('leave foo', 'UnsubCommand'),
87 array('leave foo bar', null),
90 array('unsub foo', 'UnsubCommand'),
91 array('unsub foo bar', null),
94 array('leave foo', 'UnsubCommand'),
95 array('leave foo bar', null),
99 array('d foo bar', 'MessageCommand'),
102 array('dm foo', null),
103 array('dm foo bar', 'MessageCommand'),
106 array('r foo', null),
107 array('r foo bar', 'ReplyCommand'),
109 array('reply', null),
110 array('reply foo', null),
111 array('reply foo bar', 'ReplyCommand'),
113 array('repeat', null),
114 array('repeat foo', 'RepeatCommand'),
115 array('repeat foo bar', null),
118 array('rp foo', 'RepeatCommand'),
119 array('rp foo bar', null),
122 array('rt foo', 'RepeatCommand'),
123 array('rt foo bar', null),
126 array('rd foo', 'RepeatCommand'),
127 array('rd foo bar', null),
129 array('whois', null),
130 array('whois foo', 'WhoisCommand'),
131 array('whois foo bar', null),
133 /* array('fav', null),
134 array('fav foo', 'FavCommand'),
135 array('fav foo bar', null),*/
137 array('nudge', null),
138 array('nudge foo', 'NudgeCommand'),
139 array('nudge foo bar', null),
141 array('stats', 'StatsCommand'),
142 array('stats foo', null),
144 array('invite', null),
145 array('invite foo', 'InviteCommand'),
146 array('invite foo bar', null),
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),
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),
160 array('tracking', 'SearchSubTrackingCommand'),
161 array('tracking foo', null),
163 array('tracks', 'SearchSubTrackingCommand'),
164 array('tracks foo', null),