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('STATUSNET', true);
10 define('LACONICA', true);
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 $user = new User(); // fake user
27 $cmd = $inter->handle_command($user, $input);
29 $type = $cmd ? get_class($cmd) : null;
30 $this->assertEquals(strtolower($expectedType), strtolower($type), $comment);
33 static public function commandInterpreterCases()
36 array('help', 'HelpCommand'),
37 array('help me bro', null, 'help does not accept multiple params'),
38 array('HeLP', 'HelpCommand', 'case check'),
39 array('HeLP Me BRO!', null, 'case & non-params check'),
41 array('login', 'LoginCommand'),
42 array('login to savings!', null, 'login does not accept params'),
44 array('lose', null, 'lose must have at least 1 parameter'),
45 array('lose foobar', 'LoseCommand', 'lose requires 1 parameter'),
46 array('lose foobar', 'LoseCommand', 'check for space norm'),
47 array('lose more weight', null, 'lose does not accept multiple params'),
49 array('subscribers', 'SubscribersCommand'),
50 array('subscribers foo', null, 'subscribers does not take params'),
52 array('subscriptions', 'SubscriptionsCommand'),
53 array('subscriptions foo', null, 'subscriptions does not take params'),
55 array('groups', 'GroupsCommand'),
56 array('groups foo', null, 'groups does not take params'),
58 array('off', 'OffCommand', 'off accepts 0 or 1 params'),
59 array('off foo', 'OffCommand', 'off accepts 0 or 1 params'),
60 array('off foo bar', null, 'off accepts 0 or 1 params'),
62 array('stop', 'OffCommand', 'stop accepts 0 params'),
63 array('stop foo', null, 'stop accepts 0 params'),
65 array('quit', 'OffCommand', 'quit accepts 0 params'),
66 array('quit foo', null, 'quit accepts 0 params'),
68 array('on', 'OnCommand', 'on accepts 0 or 1 params'),
69 array('on foo', 'OnCommand', 'on accepts 0 or 1 params'),
70 array('on foo bar', null, 'on accepts 0 or 1 params'),
73 array('join foo', 'JoinCommand'),
74 array('join foo bar', null),
77 array('drop foo', 'DropCommand'),
78 array('drop foo bar', null),
80 array('follow', null),
81 array('follow foo', 'SubCommand'),
82 array('follow foo bar', null),
85 array('sub foo', 'SubCommand'),
86 array('sub foo bar', null),
89 array('leave foo', 'UnsubCommand'),
90 array('leave foo bar', null),
93 array('unsub foo', 'UnsubCommand'),
94 array('unsub foo bar', null),
97 array('leave foo', 'UnsubCommand'),
98 array('leave foo bar', null),
101 array('d foo', null),
102 array('d foo bar', 'MessageCommand'),
105 array('dm foo', null),
106 array('dm foo bar', 'MessageCommand'),
109 array('r foo', null),
110 array('r foo bar', 'ReplyCommand'),
112 array('reply', null),
113 array('reply foo', null),
114 array('reply foo bar', 'ReplyCommand'),
116 array('repeat', null),
117 array('repeat foo', 'RepeatCommand'),
118 array('repeat foo bar', null),
121 array('rp foo', 'RepeatCommand'),
122 array('rp foo bar', null),
125 array('rt foo', 'RepeatCommand'),
126 array('rt foo bar', null),
129 array('rd foo', 'RepeatCommand'),
130 array('rd foo bar', null),
132 array('whois', null),
133 array('whois foo', 'WhoisCommand'),
134 array('whois foo bar', null),
137 array('fav foo', 'FavCommand'),
138 array('fav foo bar', null),
140 array('nudge', null),
141 array('nudge foo', 'NudgeCommand'),
142 array('nudge foo bar', null),
144 array('stats', 'StatsCommand'),
145 array('stats foo', null),
147 array('invite', null),
148 array('invite foo', 'InviteCommand'),
149 array('invite foo bar', null),
151 array('track', null),
152 array('track foo', 'TrackCommand'),
153 array('track off', 'TrackOffCommand'),
154 array('track foo bar', null),
155 array('track off foo', null),
157 array('untrack', null),
158 array('untrack foo', 'UntrackCommand'),
159 array('untrack all', 'TrackOffCommand'),
160 array('untrack foo bar', null),
161 array('untrack all foo', null),
163 array('tracking', 'TrackingCommand'),
164 array('tracking foo', null),
166 array('tracks', 'TrackingCommand'),
167 array('tracks foo', null),