Code Duplication    Length = 11-12 lines in 4 locations

tests/Xtools/PageTest.php 2 locations

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

@@ 52-62 (lines=11) @@
49
    /**
50
     * A project has a set of namespaces, comprising integer IDs and string titles.
51
     */
52
    public function testNamespaces()
53
    {
54
        $projectRepo = $this->getMock(ProjectRepository::class);
55
        $projectRepo->expects($this->once())
56
            ->method('getMetadata')
57
            ->willReturn(['namespaces' => [0 => 'Article', 1 => 'Article_talk']]);
58
59
        $project = new Project('testWiki');
60
        $project->setRepository($projectRepo);
61
        $this->assertCount(2, $project->getNamespaces());
62
    }
63
64
    /**
65
     * XTools can be run in single-wiki mode, where there is only one project.
@@ 67-78 (lines=12) @@
64
    /**
65
     * XTools can be run in single-wiki mode, where there is only one project.
66
     */
67
    public function testSingleWiki()
68
    {
69
        $projectRepo = new ProjectRepository();
70
        $projectRepo->setSingleMetadata([
71
            'url' => 'https://example.org/a-wiki/',
72
            'dbname' => 'example_wiki',
73
        ]);
74
        $project = new Project('disregarded_wiki_name');
75
        $project->setRepository($projectRepo);
76
        $this->assertEquals('example_wiki', $project->getDatabaseName());
77
        $this->assertEquals('https://example.org/a-wiki/', $project->getUrl());
78
    }
79
80
    /**
81
     * A project is considered to exist if it has at least a domain name.