| @@ 40-48 (lines=9) @@ | ||
| 37 | /** |
|
| 38 | * @test |
|
| 39 | */ |
|
| 40 | public function processForReturnsCorrectResponseForWrongUsername() |
|
| 41 | { |
|
| 42 | $this->initCommandWithPayload(BeerCommand::class, [ |
|
| 43 | 'user' => 'U54321', |
|
| 44 | 'text' => 'beer:for max', |
|
| 45 | ]); |
|
| 46 | $result = $this->command->process(); |
|
| 47 | static::assertEquals('*Sorry, a username must start with a @-sign:*', $result); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @test |
|
| @@ 66-75 (lines=10) @@ | ||
| 63 | /** |
|
| 64 | * @test |
|
| 65 | */ |
|
| 66 | public function processForReturnsCorrectResponseForCorrectUsernameWithin24Hours() |
|
| 67 | { |
|
| 68 | $this->initCommandWithPayload(BeerCommand::class, [ |
|
| 69 | 'user' => 'U12345', |
|
| 70 | 'text' => 'beer:for <@U23456>', |
|
| 71 | ]); |
|
| 72 | $this->command->process(); |
|
| 73 | $result = $this->command->process(); |
|
| 74 | static::assertStringStartsWith('You spend one :t3beer: to <@U23456> within in last 24 hours. Too much beer is unhealthy ;)', $result); |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * @test |
|
| @@ 119-127 (lines=9) @@ | ||
| 116 | /** |
|
| 117 | * @test |
|
| 118 | */ |
|
| 119 | public function processStatsReturnsCorrectResponseForinvalidUsername() |
|
| 120 | { |
|
| 121 | $this->initCommandWithPayload(BeerCommand::class, [ |
|
| 122 | 'user' => 'U12345', |
|
| 123 | 'text' => 'beer:stats foo', |
|
| 124 | ]); |
|
| 125 | $result = $this->command->process(); |
|
| 126 | static::assertEquals('*Sorry, a username must start with a @-sign:*', $result); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| @@ 39-47 (lines=9) @@ | ||
| 36 | /** |
|
| 37 | * @test |
|
| 38 | */ |
|
| 39 | public function processShowReturnsCorrectResponseForNoOptions() |
|
| 40 | { |
|
| 41 | $this->initCommandWithPayload(ForgeCommand::class, [ |
|
| 42 | 'user' => 'U54321', |
|
| 43 | 'text' => 'forge:show', |
|
| 44 | ]); |
|
| 45 | $result = $this->command->process(); |
|
| 46 | static::assertEquals('hey, I need an issue number!', $result); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @test |
|
| @@ 52-60 (lines=9) @@ | ||
| 49 | /** |
|
| 50 | * @test |
|
| 51 | */ |
|
| 52 | public function processShowReturnsCorrectResponseForInvalidIssueNumber() |
|
| 53 | { |
|
| 54 | $this->initCommandWithPayload(ForgeCommand::class, [ |
|
| 55 | 'user' => 'U54321', |
|
| 56 | 'text' => 'forge:show asdasd', |
|
| 57 | ]); |
|
| 58 | $result = $this->command->process(); |
|
| 59 | static::assertEquals('hey, I need an issue number!', $result); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @test |
|
| @@ 65-73 (lines=9) @@ | ||
| 62 | /** |
|
| 63 | * @test |
|
| 64 | */ |
|
| 65 | public function processShowReturnsCorrectResponseForUnknownIssueNumber() |
|
| 66 | { |
|
| 67 | $this->initCommandWithPayload(ForgeCommand::class, [ |
|
| 68 | 'user' => 'U54321', |
|
| 69 | 'text' => 'forge:show 99999', |
|
| 70 | ]); |
|
| 71 | $result = $this->command->process(); |
|
| 72 | static::assertEquals('Sorry not found!', $result); |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * @test |
|
| @@ 105-114 (lines=10) @@ | ||
| 102 | /** |
|
| 103 | * @test |
|
| 104 | */ |
|
| 105 | public function processUserReturnsCorrectOutputForNoUser() |
|
| 106 | { |
|
| 107 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 108 | 'user' => 'U54321', |
|
| 109 | 'text' => 'review:user', |
|
| 110 | ]); |
|
| 111 | /** @var Message $result */ |
|
| 112 | $result = $this->command->process(); |
|
| 113 | static::assertEquals('hey, I need a username!', $result); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * @test |
|
| @@ 187-197 (lines=11) @@ | ||
| 184 | /** |
|
| 185 | * @test |
|
| 186 | */ |
|
| 187 | public function processShowReturnsCorrectOutputForNoRefIds() |
|
| 188 | { |
|
| 189 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 190 | 'user' => 'U54321', |
|
| 191 | 'text' => 'review:show', |
|
| 192 | ]); |
|
| 193 | /** @var Message $result */ |
|
| 194 | $result = $this->command->process(); |
|
| 195 | $expectedString = 'hey, I need at least one change number!'; |
|
| 196 | static::assertEquals($expectedString, $result); |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * @test |
|
| @@ 202-212 (lines=11) @@ | ||
| 199 | /** |
|
| 200 | * @test |
|
| 201 | */ |
|
| 202 | public function processShowReturnsCorrectOutputForInvalidRefId() |
|
| 203 | { |
|
| 204 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 205 | 'user' => 'U54321', |
|
| 206 | 'text' => 'review:show x11111', |
|
| 207 | ]); |
|
| 208 | /** @var Message $result */ |
|
| 209 | $result = $this->command->process(); |
|
| 210 | $expectedString = 'hey, I need at least one change number!'; |
|
| 211 | static::assertEquals($expectedString, $result); |
|
| 212 | } |
|
| 213 | ||
| 214 | /** |
|
| 215 | * @test |
|
| @@ 217-227 (lines=11) @@ | ||
| 214 | /** |
|
| 215 | * @test |
|
| 216 | */ |
|
| 217 | public function processShowReturnsCorrectOutputForUnknownRefId() |
|
| 218 | { |
|
| 219 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 220 | 'user' => 'U54321', |
|
| 221 | 'text' => 'review:show 999999', |
|
| 222 | ]); |
|
| 223 | /** @var Message $result */ |
|
| 224 | $result = $this->command->process(); |
|
| 225 | $expectedString = '999999 not found, sorry!'; |
|
| 226 | static::assertEquals($expectedString, $result); |
|
| 227 | } |
|
| 228 | ||
| 229 | /** |
|
| 230 | * @test |
|
| @@ 232-242 (lines=11) @@ | ||
| 229 | /** |
|
| 230 | * @test |
|
| 231 | */ |
|
| 232 | public function processQueryReturnsCorrectOutputForNoQuery() |
|
| 233 | { |
|
| 234 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 235 | 'user' => 'U54321', |
|
| 236 | 'text' => 'review:query', |
|
| 237 | ]); |
|
| 238 | /** @var Message $result */ |
|
| 239 | $result = $this->command->process(); |
|
| 240 | $expectedString = 'hey, I need a query!'; |
|
| 241 | static::assertEquals($expectedString, $result); |
|
| 242 | } |
|
| 243 | ||
| 244 | /** |
|
| 245 | * @test |
|
| @@ 277-287 (lines=11) @@ | ||
| 274 | /** |
|
| 275 | * @test |
|
| 276 | */ |
|
| 277 | public function processMergedReturnsCorrectOutputForNoDate() |
|
| 278 | { |
|
| 279 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 280 | 'user' => 'U54321', |
|
| 281 | 'text' => 'review:merged', |
|
| 282 | ]); |
|
| 283 | /** @var Message $result */ |
|
| 284 | $result = $this->command->process(); |
|
| 285 | $expectedString = 'hey, I need a date in the format YYYY-MM-DD!'; |
|
| 286 | static::assertEquals($expectedString, $result); |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * @test |
|
| @@ 292-302 (lines=11) @@ | ||
| 289 | /** |
|
| 290 | * @test |
|
| 291 | */ |
|
| 292 | public function processMergedReturnsCorrectOutputForInvalidDate() |
|
| 293 | { |
|
| 294 | $this->initCommandWithPayload(ReviewCommand::class, [ |
|
| 295 | 'user' => 'U54321', |
|
| 296 | 'text' => 'review:merged 01.01.2015', |
|
| 297 | ]); |
|
| 298 | /** @var Message $result */ |
|
| 299 | $result = $this->command->process(); |
|
| 300 | $expectedString = 'hey, I need a date in the format YYYY-MM-DD!'; |
|
| 301 | static::assertEquals($expectedString, $result); |
|
| 302 | } |
|
| 303 | ||
| 304 | /** |
|
| 305 | * @test |
|
| @@ 58-66 (lines=9) @@ | ||
| 55 | * @param string $message |
|
| 56 | * @param string $expectedMessage |
|
| 57 | */ |
|
| 58 | public function processTellReturnsCorrectResponse($message, $expectedMessage) |
|
| 59 | { |
|
| 60 | $this->initCommandWithPayload(TellCommand::class, [ |
|
| 61 | 'user' => 'U54321', |
|
| 62 | 'text' => $message, |
|
| 63 | ]); |
|
| 64 | $result = $this->command->process(); |
|
| 65 | static::assertEquals($expectedMessage, $result); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * @test |
|
| @@ 25-33 (lines=9) @@ | ||
| 22 | /** |
|
| 23 | * @test |
|
| 24 | */ |
|
| 25 | public function processCoinReturnsCorrectResponseForNoOptions() |
|
| 26 | { |
|
| 27 | $this->initCommandWithPayload(UtilCommand::class, [ |
|
| 28 | 'user' => 'U54321', |
|
| 29 | 'text' => 'util:coin', |
|
| 30 | ]); |
|
| 31 | $result = $this->command->process(); |
|
| 32 | static::assertEquals('*Botty says:* _A complicated decision ..._', $result); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @test |
|
| @@ 38-46 (lines=9) @@ | ||
| 35 | /** |
|
| 36 | * @test |
|
| 37 | */ |
|
| 38 | public function processCoinReturnsCorrectResponseForOneOption() |
|
| 39 | { |
|
| 40 | $this->initCommandWithPayload(UtilCommand::class, [ |
|
| 41 | 'user' => 'U54321', |
|
| 42 | 'text' => 'util:coin a', |
|
| 43 | ]); |
|
| 44 | $result = $this->command->process(); |
|
| 45 | static::assertEquals('*Botty says:* _A complicated decision ..._', $result); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @test |
|
| @@ 77-85 (lines=9) @@ | ||
| 74 | /** |
|
| 75 | * @test |
|
| 76 | */ |
|
| 77 | public function processCoinReturnsCorrectResponseForTwoIdenticalOptions() |
|
| 78 | { |
|
| 79 | $this->initCommandWithPayload(UtilCommand::class, [ |
|
| 80 | 'user' => 'U54321', |
|
| 81 | 'text' => 'util:coin a, a', |
|
| 82 | ]); |
|
| 83 | $result = $this->command->process(); |
|
| 84 | static::assertEquals('*Botty says:* _it is undecidable ..._', $result); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||