Code Duplication    Length = 11-12 lines in 4 locations

tests/Xtools/PageTest.php 2 locations

@@ 72-82 (lines=11) @@
69
    /**
70
     * A page has an integer ID on a given project.
71
     */
72
    public function testId()
73
    {
74
        $pageRepo = $this->getMock(PagesRepository::class, ['getPageInfo']);
75
        $pageRepo->expects($this->once())
76
            ->method('getPageInfo')
77
            ->willReturn(['pageid' => '42']);
78
79
        $page = new Page(new Project('TestProject'), 'Test_Page');
80
        $page->setRepository($pageRepo);
81
        $this->assertEquals(42, $page->getId());
82
    }
83
84
    /**
85
     * A page has a URL.
@@ 87-97 (lines=11) @@
84
    /**
85
     * A page has a URL.
86
     */
87
    public function testUrls()
88
    {
89
        $pageRepo = $this->getMock(PagesRepository::class, ['getPageInfo']);
90
        $pageRepo->expects($this->once())
91
            ->method('getPageInfo')
92
            ->willReturn(['fullurl' => 'https://example.org/Page']);
93
94
        $page = new Page(new Project('exampleWiki'), 'Page');
95
        $page->setRepository($pageRepo);
96
        $this->assertEquals('https://example.org/Page', $page->getUrl());
97
    }
98
99
    /**
100
     * A list of a single user's edits on this page can be retrieved, along with the count of

tests/Xtools/ProjectTest.php 2 locations

@@ 33-43 (lines=11) @@
30
    /**
31
     * A project has a set of namespaces, comprising integer IDs and string titles.
32
     */
33
    public function testNamespaces()
34
    {
35
        $projectRepo = $this->getMock(ProjectRepository::class);
36
        $projectRepo->expects($this->once())
37
            ->method('getMetadata')
38
            ->willReturn(['namespaces' => [0 => 'Article', 1 => 'Article_talk']]);
39
40
        $project = new Project('testWiki');
41
        $project->setRepository($projectRepo);
42
        $this->assertCount(2, $project->getNamespaces());
43
    }
44
45
    /**
46
     * Xtools can be run in single-wiki mode, where there is only one project.
@@ 48-59 (lines=12) @@
45
    /**
46
     * Xtools can be run in single-wiki mode, where there is only one project.
47
     */
48
    public function testSingleWiki()
49
    {
50
        $projectRepo = new ProjectRepository();
51
        $projectRepo->setSingleMetadata([
52
            'url' => 'https://example.org/a-wiki/',
53
            'dbname' => 'example_wiki',
54
        ]);
55
        $project = new Project('disregarded_wiki_name');
56
        $project->setRepository($projectRepo);
57
        $this->assertEquals('example_wiki', $project->getDatabaseName());
58
        $this->assertEquals('https://example.org/a-wiki/', $project->getUrl());
59
    }
60
61
    /**
62
     * A project is considered to exist if it has at least a domain name.