Page MenuHomeDevCentral

TriggerBuildFactoryTest.php
No OneTemporary

TriggerBuildFactoryTest.php

<?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 WithMockHttpClient;
/**
* @var Keruald\DockerHub\Build\TriggerBuildFactory
*/
protected $factory;
public function setUp () {
$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->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");
}
public function testHasToken () {
$this->assertTrue($this->factory->hasToken("acme/foo"));
}
public function testHasTokenWhenWeDoNot () {
$this->assertFalse($this->factory->hasToken("acme/bar"));
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Nov 6, 23:47 (11 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4249070
Default Alt Text
TriggerBuildFactoryTest.php (1 KB)

Event Timeline