Page MenuHomeDevCentral

No OneTemporary

diff --git a/src/Build/TriggerBuild.php b/src/Build/TriggerBuild.php
new file mode 100644
index 0000000..05358f9
--- /dev/null
+++ b/src/Build/TriggerBuild.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Keruald\DockerHub\Build;
+
+use Keruald\DockerHub\DockerHubImage as Image;
+
+/**
+ * this classe represents a trigger for a new build on the Docker Hub registry.
+ */
+class TriggerBuild {
+
+ ///
+ /// Private members
+ ///
+
+ /**
+ * The image to build
+ *
+ * @var Keruald\DockerHub\DockerHubImage
+ */
+ protected $image;
+
+ /**
+ * Trigger token used to authentify requests
+ *
+ * @var string
+ */
+ protected $token;
+
+ ///
+ /// Constructor
+ ///
+
+ /**
+ * Initializes a new instance of the TriggerBuild class.
+ *
+ * @param Keruald\DockerHub\DockerHubImage $image The image to build
+ * @param string $token The token to authentify the build request
+ */
+ public function __construct (Image $image, $token) {
+ $this->image = $image;
+ $this->token = $token;
+ }
+
+ ///
+ /// Helper methods
+ ///
+
+ /**
+ * Gets build trigger URL.
+ *
+ * @return string
+ */
+ public function getTriggerUrl () {
+ return $this->image->getRegistryUrl()
+ . '/trigger/' . $this->token . '/';
+ }
+
+}
diff --git a/tests/Build/TriggerBuildTest.php b/tests/Build/TriggerBuildTest.php
new file mode 100644
index 0000000..e95b055
--- /dev/null
+++ b/tests/Build/TriggerBuildTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Keruald\DockerHub\Tests\Build;
+
+use Keruald\DockerHub\DockerHubImage;
+use Keruald\DockerHub\Build\TriggerBuild;
+
+class TriggerBuildTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Keruald\DockerHub\Build\TriggerBuild
+ */
+ protected $trigger;
+
+ public function setUp () {
+ $image = new DockerHubImage("acme", "foo");
+ $this->trigger = new TriggerBuild($image, "0000");
+ }
+
+ public function testGetTriggerUrl () {
+ $this->assertSame(
+ "https://registry.hub.docker.com/u/acme/foo/trigger/0000/",
+ $this->trigger->getTriggerUrl()
+ );
+ }
+
+}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 22:09 (9 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2257760
Default Alt Text
(2 KB)

Event Timeline