|
@@ 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 <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 |
|
|
| 143 |
|
$this->assertSame($expected, $this->builder->replaceRelativeLinks($addon, $input)); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
/** |
| 147 |
|
* For non GitHub repositories, the readme input should simply be returned as is from the "replaceRelativeLinks" |
|
@@ 150-156 (lines=7) @@
|
| 147 |
|
* For non GitHub repositories, the readme input should simply be returned as is from the "replaceRelativeLinks" |
| 148 |
|
* method |
| 149 |
|
*/ |
| 150 |
|
public function testDoNotRewriteRelativeLinksForNonGitHubRepositories() |
| 151 |
|
{ |
| 152 |
|
$addon = Addon::create(); |
| 153 |
|
$addon->Repository = 'https://gitlab.com/not-a/github-repo.git'; |
| 154 |
|
$readme = '<p>Please do not touch me.</p>'; |
| 155 |
|
$this->assertSame($readme, $this->builder->replaceRelativeLinks($addon, $readme)); |
| 156 |
|
} |
| 157 |
|
} |
| 158 |
|
|