Code Duplication    Length = 11-12 lines in 4 locations

tests/Xtools/PageTest.php 2 locations

@@ 66-76 (lines=11) @@
63
    /**
64
     * A page has an integer ID on a given project.
65
     */
66
    public function testId()
67
    {
68
        $pageRepo = $this->getMock(PagesRepository::class, ['getPageInfo']);
69
        $pageRepo->expects($this->once())
70
            ->method('getPageInfo')
71
            ->willReturn(['pageid' => '42']);
72
73
        $page = new Page(new Project('TestProject'), 'Test_Page');
74
        $page->setRepository($pageRepo);
75
        $this->assertEquals(42, $page->getId());
76
    }
77
78
    /**
79
     * A page has a URL.
@@ 81-91 (lines=11) @@
78
    /**
79
     * A page has a URL.
80
     */
81
    public function testUrls()
82
    {
83
        $pageRepo = $this->getMock(PagesRepository::class, ['getPageInfo']);
84
        $pageRepo->expects($this->once())
85
            ->method('getPageInfo')
86
            ->willReturn(['fullurl' => 'https://example.org/Page']);
87
88
        $page = new Page(new Project('exampleWiki'), 'Page');
89
        $page->setRepository($pageRepo);
90
        $this->assertEquals('https://example.org/Page', $page->getUrl());
91
    }
92
93
    /**
94
     * 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.