Completed
Branch master (812a3e)
by Frank
04:30 queued 02:09
created

UtilCommandTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 67.16 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 45
loc 67
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * T3Bot.
4
 *
5
 * @author Frank Nägler <[email protected]>
6
 *
7
 * @link http://www.t3bot.de
8
 * @link http://wiki.typo3.org/T3Bot
9
 */
10
namespace T3Bot\Tests\Unit\Commands;
11
12
use T3Bot\Commands\UtilCommand;
13
use T3Bot\Tests\Unit\BaseCommandTestCase;
14
15
/**
16
 * Class UtilCommandTest.
17
 */
18
19
/** @noinspection LongInheritanceChainInspection */
20
class UtilCommandTest extends BaseCommandTestCase
21
{
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
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
50
     */
51
    public function processCoinReturnsCorrectResponseForTwoOptions()
52
    {
53
        $this->initCommandWithPayload(UtilCommand::class, [
54
            'user' => 'U54321',
55
            'text' => 'util:coin a, b',
56
        ]);
57
        $result = $this->command->process();
58
        static::assertContains($result, ['*Botty says:* _a_', '*Botty says:* _b_']);
59
    }
60
61
    /**
62
     * @test
63
     */
64
    public function processCoinReturnsCorrectResponseForThreeOptions()
65
    {
66
        $this->initCommandWithPayload(UtilCommand::class, [
67
            'user' => 'U54321',
68
            'text' => 'util:coin a, b, c',
69
        ]);
70
        $result = $this->command->process();
71
        static::assertContains($result, ['*Botty says:* _a_', '*Botty says:* _b_', '*Botty says:* _c_']);
72
    }
73
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