|
@@ 61-68 (lines=8) @@
|
| 58 |
|
* @covers ::hasGitHubRepository |
| 59 |
|
* @dataProvider hasGitHubProvider |
| 60 |
|
*/ |
| 61 |
|
public function testHasGitHubRepository($repository, $expected) |
| 62 |
|
{ |
| 63 |
|
$addon = Addon::create(); |
| 64 |
|
$addon->Repository = $repository; |
| 65 |
|
|
| 66 |
|
$result = $this->builder->hasGitHubRepository($addon); |
| 67 |
|
$this->assertSame($expected, $result); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
/** |
| 71 |
|
* @return array |
|
@@ 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 |
|
|