Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/DockerHubImageTest.php b/tests/DockerHubImageTest.php
index 964dd05..8c8cb75 100644
--- a/tests/DockerHubImageTest.php
+++ b/tests/DockerHubImageTest.php
@@ -1,48 +1,48 @@
<?php
namespace Keruald\DockerHub\Tests;
use Keruald\DockerHub\DockerHubImage;
use Keruald\DockerHub\Build\TriggerBuild;
class DockerHubImageTest extends \PHPUnit_Framework_TestCase {
use WithMockHttpClient;
/**
* @var Keruald\DockerHub\DockerHubImage
*/
private $image;
public function setUp () {
$this->image = new DockerHubImage("acme", "foo");
}
public function testLoadFromSlashNotation () {
$slashNotationImage = DockerHubImage::loadFromSlashNotation("acme/foo");
$this->assertEquals($slashNotationImage, $this->image);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testLoadFromSlashNotationWithInvalidArgument () {
DockerHubImage::loadFromSlashNotation("foo");
}
public function testGetRegistryUrl () {
$this->assertSame(
"https://registry.hub.docker.com/u/acme/foo",
$this->image->getRegistryUrl()
);
}
public function testGetTriggerBuild () {
- $client = $this->mockHttpClient(200);
+ $client = self::mockHttpClient(200);
$this->assertInstanceOf(
TriggerBuild::class,
$this->image->getTriggerBuild($client, '0000')
);
}
}
diff --git a/tests/WithMockHttpClient.php b/tests/WithMockHttpClient.php
index 77121e8..82c9f06 100644
--- a/tests/WithMockHttpClient.php
+++ b/tests/WithMockHttpClient.php
@@ -1,32 +1,32 @@
<?php
namespace Keruald\DockerHub\Tests;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Psr7\Response;
trait WithMockHttpClient {
/**
* Mocks HTTP client
*
* @param int $httpResponseCode The HTTP response code to mock
* @return \GuzzleHttp\Client
*/
- protected function mockHttpClient ($httpResponseCode) {
+ protected static function mockHttpClient ($httpResponseCode = 200) {
$handler = self::getCustomMockHttpClientHandler($httpResponseCode);
return new Client(['handler' => $handler]);
}
/**
* @return \GuzzleHttp\HandlerStack
*/
protected static function getCustomMockHttpClientHandler ($code) {
return HandlerStack::create(new MockHandler([
new Response($code),
]));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Mar 18, 13:42 (12 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3532364
Default Alt Text
(2 KB)

Event Timeline