Page MenuHomeDevCentral

No OneTemporary

diff --git a/composer.json b/composer.json
index 883bd4b..8e2dbd3 100644
--- a/composer.json
+++ b/composer.json
@@ -1,39 +1,39 @@
{
"name": "keruald/dockerhub",
"description": "Docker Hub API client",
"license": "BSD-2-Clause",
"authors": [
{
"name": "Sébastien Santoro",
"email": "dereckson@espace-win.org"
}
],
"keywords": [
"keruald",
"Docker",
"Docker Hub"
],
"support": {
"irc": "irc://irc.freenode.net/wolfplex",
"issues": "https://devcentral.nasqueron.org"
},
"require": {
- "php": ">=5.6.0",
- "guzzlehttp/psr7": "~1.3",
- "guzzlehttp/guzzle": "~6.0"
+ "php": ">=7.3",
+ "guzzlehttp/psr7": "^2.4.1",
+ "guzzlehttp/guzzle": "^7.5.0"
},
"require-dev": {
- "phpunit/phpunit": "5.0.*",
- "psy/psysh": "dev-master",
- "squizlabs/php_codesniffer": "*"
+ "phpunit/phpunit": "^9.0.0",
+ "psy/psysh": "^v0.11.8",
+ "squizlabs/php_codesniffer": "^3.7.1"
},
"autoload": {
"psr-4": {
"Keruald\\DockerHub\\": "src/",
"Keruald\\DockerHub\\Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit tests"
}
}
diff --git a/phpunit.xml b/phpunit.xml
index 97a54ba..98063f3 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
-<phpunit bootstrap="./vendor/autoload.php">
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ bootstrap="./vendor/autoload.php"
+ colors="true"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
+ stopOnFailure="false">
<testsuites>
<testsuite name="Library test suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
diff --git a/tests/Build/Payloads/SourceRepositoryBuildPayloadTest.php b/tests/Build/Payloads/SourceRepositoryBuildPayloadTest.php
index 3c08ee9..ea9d7bf 100644
--- a/tests/Build/Payloads/SourceRepositoryBuildPayloadTest.php
+++ b/tests/Build/Payloads/SourceRepositoryBuildPayloadTest.php
@@ -1,24 +1,24 @@
<?php
namespace Keruald\DockerHub\Tests\Build\Payloads;
use Keruald\DockerHub\Build\Payloads\SourceRepositoryBuildPayload;
-class SourceRepositoryBuildPayloadTest extends \PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class SourceRepositoryBuildPayloadTest extends TestCase {
public function testIsValidType () {
$this->assertTrue(SourceRepositoryBuildPayload::isValidType('Tag'));
$this->assertTrue(SourceRepositoryBuildPayload::isValidType('Branch'));
$this->assertFalse(SourceRepositoryBuildPayload::isValidType('foo'));
$this->assertFalse(SourceRepositoryBuildPayload::isValidType(''));
$this->assertFalse(SourceRepositoryBuildPayload::isValidType(null));
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testInvalidTypeThrowException () {
+ $this->expectException(\InvalidArgumentException::class);
$mock = new NotExistingObjectBuildPayloadMock();
}
}
diff --git a/tests/Build/TriggerBuildFactoryTest.php b/tests/Build/TriggerBuildFactoryTest.php
index 77c2cf1..aca148f 100644
--- a/tests/Build/TriggerBuildFactoryTest.php
+++ b/tests/Build/TriggerBuildFactoryTest.php
@@ -1,64 +1,65 @@
<?php
namespace Keruald\DockerHub\Tests\Build;
use Keruald\DockerHub\DockerHubImage;
use Keruald\DockerHub\Build\TriggerBuild;
use Keruald\DockerHub\Build\TriggerBuildFactory;
use Keruald\DockerHub\Tests\WithMockHttpClient;
-class TriggerBuildFactoryTest extends \PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class TriggerBuildFactoryTest extends TestCase {
use WithMockHttpClient;
/**
* @var Keruald\DockerHub\Build\TriggerBuildFactory
*/
protected $factory;
- public function setUp () {
+ public function setUp () : void {
$client = self::mockHttpClient();
$tokens = self::mockTokens();
$this->factory = new TriggerBuildFactory($client, $tokens);
}
/**
* @return array
*/
private static function mockTokens () {
return [
"acme/foo" => "0000",
];
}
public function testGetForImage () {
$this->assertInstanceOf(
TriggerBuild::class,
$this->factory->getForImage("acme/foo")
);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testGetForImageWithoutToken () {
+ $this->expectException(\Exception::class);
$this->factory->getForImage("acme/bar");
}
public function testBuild () {
// That returns void.
// We don't need to test the sendPayloadForAll method.
// So, we only need to check there is no exception or error.
$this->factory->build("acme/foo");
+ $this->expectNotToPerformAssertions();
}
public function testHasToken () {
$this->assertTrue($this->factory->hasToken("acme/foo"));
}
public function testHasTokenWhenWeDoNot () {
$this->assertFalse($this->factory->hasToken("acme/bar"));
}
}
diff --git a/tests/Build/TriggerBuildTest.php b/tests/Build/TriggerBuildTest.php
index d827a11..da0ad36 100644
--- a/tests/Build/TriggerBuildTest.php
+++ b/tests/Build/TriggerBuildTest.php
@@ -1,107 +1,101 @@
<?php
namespace Keruald\DockerHub\Tests\Build;
use Keruald\DockerHub\DockerHubImage;
use Keruald\DockerHub\Build\TriggerBuild;
use Keruald\DockerHub\Build\Payloads\AllBuildPayload;
use Keruald\DockerHub\Build\Payloads\DockerTagBuildPayload;
use Keruald\DockerHub\Build\Payloads\SourceRepositoryBuildPayload;
use Keruald\DockerHub\Tests\WithMockHttpClient;
-class TriggerBuildTest extends \PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class TriggerBuildTest extends TestCase {
use WithMockHttpClient;
/**
* @var Keruald\DockerHub\Build\TriggerBuild
*/
protected $trigger;
/**
* @var Keruald\DockerHub\DockerHubImage
*/
protected $image;
- public function setUp () {
+ public function setUp () : void {
$this->image = new DockerHubImage("acme", "foo");
$this->trigger = new TriggerBuild($this->image, "0000");
}
public function testGetTriggerUrl () {
$this->assertSame(
"https://registry.hub.docker.com/u/acme/foo/trigger/0000/",
$this->trigger->getTriggerUrl()
);
}
public function testGetPayloadForAll () {
// {"build": true}
$payload = $this->trigger->getPayloadForAll();
$this->assertInstanceOf(AllBuildPayload::class, $payload);
$this->assertTrue($payload->build);
}
public function testGetPayloadForDockerTag () {
// {"docker_tag": "master"}
$payload = $this->trigger->getPayloadForDockerTag("master");
$this->assertInstanceOf(DockerTagBuildPayload::class, $payload);
$this->assertSame($payload->docker_tag, "master");
}
public function testGetPayloadForSourceRepositoryBranch () {
// {"source_type": "Branch", "source_name": "staging"}
$payload = $this->trigger->getPayloadForSourceRepositoryBranch("staging");
$this->assertInstanceOf(SourceRepositoryBuildPayload::class, $payload);
$this->assertSame($payload->source_type, "Branch");
$this->assertSame($payload->source_name, "staging");
}
public function testGetPayloadForSourceRepositoryTag () {
// {"source_type": "Tag", "source_name": "v1.1"}
$payload = $this->trigger->getPayloadForSourceRepositoryTag("v1.1");
$this->assertInstanceOf(SourceRepositoryBuildPayload::class, $payload);
$this->assertSame($payload->source_type, "Tag");
$this->assertSame($payload->source_name, "v1.1");
}
///
/// Overloads test
///
- /**
- * @expectedException \BadMethodCallException
- */
public function testMethodOverloadingForNonExistingMethod () {
+ $this->expectException(\BadMethodCallException::class);
$this->trigger->loremIpsum();
}
- /**
- * @expectedException \BadMethodCallException
- */
public function testMethodOverloadingForNonExistingPayloadMethod () {
+ $this->expectException(\BadMethodCallException::class);
$this->trigger->sendPayloadForLoremIpsum();
}
///
/// HTTP client tests
///
- /**
- * @expectedException \InvalidArgumentException
- */
public function testPostWhenClientIsNull () {
+ $this->expectException(\InvalidArgumentException::class);
$this->trigger->sendPayloadForAll();
}
- /**
- * @expectedException \RuntimeException
- */
public function testPostThrowsRuntimeExceptionWhenResponseIsNot200 () {
+ $this->expectException(\RuntimeException::class);
$mockClient = $this->mockHttpClient(500);
$trigger = new TriggerBuild($this->image, "0000", $mockClient);
$trigger->sendPayloadForAll();
}
}
diff --git a/tests/DockerHubImageTest.php b/tests/DockerHubImageTest.php
index 8c8cb75..71a34d1 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 PHPUnit\Framework\TestCase;
+
+class DockerHubImageTest extends TestCase {
use WithMockHttpClient;
/**
* @var Keruald\DockerHub\DockerHubImage
*/
private $image;
- public function setUp () {
+ public function setUp () : void {
$this->image = new DockerHubImage("acme", "foo");
}
public function testLoadFromSlashNotation () {
$slashNotationImage = DockerHubImage::loadFromSlashNotation("acme/foo");
$this->assertEquals($slashNotationImage, $this->image);
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testLoadFromSlashNotationWithInvalidArgument () {
+ $this->expectException(\Exception::class);
DockerHubImage::loadFromSlashNotation("foo");
}
public function testGetRegistryUrl () {
$this->assertSame(
"https://registry.hub.docker.com/u/acme/foo",
$this->image->getRegistryUrl()
);
}
public function testGetTriggerBuild () {
$client = self::mockHttpClient(200);
$this->assertInstanceOf(
TriggerBuild::class,
$this->image->getTriggerBuild($client, '0000')
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Mar 18, 14:34 (3 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3540113
Default Alt Text
(10 KB)

Event Timeline