Code Duplication    Length = 19-23 lines in 3 locations

tests/Xtools/EditCounterTest.php 3 locations

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