Code Duplication    Length = 7-23 lines in 2 locations

mysite/tests/services/AddonBuilderTest.php 2 locations

@@ 122-144 (lines=23) @@
119
     *
120
     * @covers ::replaceRelativeLinks
121
     */
122
    public function testRewriteRelativeLinksAndImages()
123
    {
124
        $addon = Addon::create();
125
        $addon->Repository = 'https://github.com/silverstripe/silverstripe-framework';
126
// phpcs:disable
127
        $input = <<<HTML
128
<h1>Heading</h1>
129
130
<p><a href="relative">Relative</a> and <a href="//absolute.com">absolute</a>.</p>
131
132
<p><img src="relative.png"><img src="https://www.whatever.com/image.png"></p>
133
HTML;
134
135
        $expected = <<<HTML
136
<h1>Heading</h1>
137
138
<p><a href="https://github.com/silverstripe/silverstripe-framework/blob/master/relative">Relative</a> and <a href="//absolute.com">absolute</a>.</p>
139
140
<p><img src="https://github.com/silverstripe/silverstripe-framework/raw/master/relative.png"><img src="https://www.whatever.com/image.png"></p>
141
HTML;
142
// phpcs:enable
143
144
        $this->assertSame($expected, $this->builder->replaceRelativeLinks($addon, $input));
145
    }
146
147
    /**
@@ 151-157 (lines=7) @@
148
     * For non GitHub repositories, the readme input should simply be returned as is from the "replaceRelativeLinks"
149
     * method
150
     */
151
    public function testDoNotRewriteRelativeLinksForNonGitHubRepositories()
152
    {
153
        $addon = Addon::create();
154
        $addon->Repository = 'https://gitlab.com/not-a/github-repo.git';
155
        $readme = '<p>Please do not touch me.</p>';
156
        $this->assertSame($readme, $this->builder->replaceRelativeLinks($addon, $readme));
157
    }
158
}
159