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
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
139
 <a href="//absolute.com">absolute</a>.</p>
140
141
<p><img src="https://github.com/silverstripe/silverstripe-framework/raw/master/relative.png">
142
<img src="https://www.whatever.com/image.png"></p>
143
HTML;
144
145
        $this->assertSame($expected, $this->builder->replaceRelativeLinks($addon, $input));
146
    }
147
@@ 152-158 (lines=7) @@
149
     * For non GitHub repositories, the readme input should simply be returned as is from the "replaceRelativeLinks"
150
     * method
151
     */
152
    public function testDoNotRewriteRelativeLinksForNonGitHubRepositories()
153
    {
154
        $addon = Addon::create();
155
        $addon->Repository = 'https://gitlab.com/not-a/github-repo.git';
156
        $readme = '<p>Please do not touch me.</p>';
157
        $this->assertSame($readme, $this->builder->replaceRelativeLinks($addon, $readme));
158
    }
159
}
160