Code Duplication    Length = 19-23 lines in 3 locations

tests/Xtools/EditCounterTest.php 3 locations

@@ 11-29 (lines=19) @@
8
    /**
9
     * Get counts of revisions: deleted, not-deleted, and total.
10
     */
11
    public function testLiveAndDeletedEdits()
12
    {
13
        $editCounterRepo = $this->getMock(EditCounterRepository::class);
14
        $editCounterRepo->expects($this->once())
15
            ->method('getRevisionCounts')
16
            ->willReturn([
17
                'deleted' => 10,
18
                'live' => 100,
19
            ]);
20
21
        $project = new Project('TestProject');
22
        $user = new User('Testuser');
23
        $editCounter = new EditCounter($project, $user);
24
        $editCounter->setRepository($editCounterRepo);
25
26
        $this->assertEquals(100, $editCounter->countLiveRevisions());
27
        $this->assertEquals(10, $editCounter->countDeletedRevisions());
28
        $this->assertEquals(110, $editCounter->countAllRevisions());
29
    }
30
31
    /**
32
     * A first and last date, and number of days between.
@@ 34-54 (lines=21) @@
31
    /**
32
     * A first and last date, and number of days between.
33
     */
34
    public function testDates()
35
    {
36
        $editCounterRepo = $this->getMock(EditCounterRepository::class);
37
        $editCounterRepo->expects($this->once())->method('getRevisionDates')->willReturn([
38
                'first' => '20170510100000',
39
                'last' => '20170515150000',
40
            ]);
41
        $project = new Project('TestProject');
42
        $user = new User('Testuser1');
43
        $editCounter = new EditCounter($project, $user);
44
        $editCounter->setRepository($editCounterRepo);
45
        $this->assertEquals(
46
            new \DateTime('2017-05-10 10:00'),
47
            $editCounter->datetimeFirstRevision()
48
        );
49
        $this->assertEquals(
50
            new \DateTime('2017-05-15 15:00'),
51
            $editCounter->datetimeLastRevision()
52
        );
53
        $this->assertEquals(5, $editCounter->getDays());
54
    }
55
56
    /**
57
     * Only one edit means the dates will be the same.
@@ 59-81 (lines=23) @@
56
    /**
57
     * Only one edit means the dates will be the same.
58
     */
59
    public function testDatesWithOneRevision()
60
    {
61
        $editCounterRepo = $this->getMock(EditCounterRepository::class);
62
        $editCounterRepo->expects($this->once())
63
            ->method('getRevisionDates')
64
            ->willReturn([
65
                'first' => '20170510110000',
66
                'last' => '20170510110000',
67
            ]);
68
        $project = new Project('TestProject');
69
        $user = new User('Testuser1');
70
        $editCounter = new EditCounter($project, $user);
71
        $editCounter->setRepository($editCounterRepo);
72
        $this->assertEquals(
73
            new \DateTime('2017-05-10 11:00'),
74
            $editCounter->datetimeFirstRevision()
75
        );
76
        $this->assertEquals(
77
            new \DateTime('2017-05-10 11:00'),
78
            $editCounter->datetimeLastRevision()
79
        );
80
        $this->assertEquals(1, $editCounter->getDays());
81
    }
82
83
    public function testPageCounts()
84
    {