Skip to content

Commit d998e94

Browse files
author
Holger Lösken
committed
More tests
1 parent ceadd78 commit d998e94

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/SourceRepositoryTypes/HttpRepositoryType.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ public function getVersionAvailable($prepend = '', $append = ''): string
197197
$version = $this->getVersionFile();
198198
} else {
199199
$releaseCollection = $this->extractFromHtml($this->getRepositoryReleases()->getBody()->getContents());
200-
if ($releaseCollection->isEmpty()) {
201-
return '';
202-
}
203200
$version = $releaseCollection->first()->name;
204201
}
205202

tests/SourceRepositoryTypes/HttpRepositoryTypeTest.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@ public function it_cannot_fetch_releases_because_there_is_no_release(): void
6666
/** @test */
6767
public function it_cannot_fetch_releases_because_there_is_no_release_with_access_token(): void
6868
{
69+
$client = $this->getMockedClient([
70+
$this->getResponse200Type('http'),
71+
$this->getResponse200ZipFile(),
72+
$this->getResponse200Type('http'),
73+
$this->getResponse200Type('http'),
74+
]);
75+
$this->app->instance(Client::class, $client);
76+
6977
/** @var HttpRepositoryType $http */
70-
$http = resolve(HttpRepositoryType::class);
78+
$http = $this->app->make(HttpRepositoryType::class);
7179
$http->setAccessToken('123');
7280

7381
$this->assertInstanceOf(Release::class, $http->fetch());
@@ -76,18 +84,23 @@ public function it_cannot_fetch_releases_because_there_is_no_release_with_access
7684
$this->assertInstanceOf(Release::class, $http->fetch());
7785
}
7886

79-
87+
/** @test */
8088
public function it_can_fetch_http_releases(): void
8189
{
90+
$client = $this->getMockedClient([
91+
$this->getResponse200Type('http'),
92+
$this->getResponse200ZipFile(),
93+
$this->getResponse200Type('http'),
94+
$this->getResponse200Type('http'),
95+
]);
96+
$this->app->instance(Client::class, $client);
97+
8298
/** @var HttpRepositoryType $http */
83-
$http = resolve(HttpRepositoryType::class);
99+
$http = $this->app->make(HttpRepositoryType::class);
84100

85101
$release = $http->fetch();
86102

87103
$this->assertInstanceOf(Release::class, $release);
88-
89-
// Fetch again when source is already fetched
90-
$this->assertInstanceOf(Release::class, $http->fetch());
91104
}
92105

93106
/** @test */
@@ -154,7 +167,7 @@ public function it_cannot_get_new_version_available_and_fails_with_exception():
154167
}
155168

156169
/** @test */
157-
public function it_can_get_new_version_available_from_type_tag_without_version_file(): void
170+
public function it_can_get_new_version_available_without_version_file(): void
158171
{
159172
$client = $this->getMockedClient([
160173
$this->getResponse200Type('http'),
@@ -163,7 +176,7 @@ public function it_can_get_new_version_available_from_type_tag_without_version_f
163176
$this->app->instance(Client::class, $client);
164177

165178
/** @var HttpRepositoryType $http */
166-
$http = resolve(HttpRepositoryType::class);
179+
$http = $this->app->make(HttpRepositoryType::class);
167180
$http->deleteVersionFile();
168181

169182
$this->assertTrue($http->isNewVersionAvailable('4.5'));

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function getResponse200ZipFile(): Response
143143
protected function getResponseEmpty(): Response
144144
{
145145
return new Response (
146-
200, [ 'Content-Type' => 'application/json' ], ''
146+
200, [ 'Content-Type' => 'text/html' ], ''
147147
);
148148
}
149149

0 commit comments

Comments
 (0)