Page MenuHomeDevCentral

D302.diff
No OneTemporary

D302.diff

diff --git a/app/Console/Commands/ConfigShow.php b/app/Console/Commands/ConfigShow.php
--- a/app/Console/Commands/ConfigShow.php
+++ b/app/Console/Commands/ConfigShow.php
@@ -48,15 +48,10 @@
protected function getServicesTableRows () {
$rows = [];
foreach (Services::get() as $service) {
- if (isset($service->instance)) {
- $instance = $service->instance;
- } else {
- $instance = 'ø';
- }
$rows[] = [
$service->gate,
$service->door,
- $instance,
+ $service->getInstanceName(),
$this->getServiveStatus($service)
];
}
diff --git a/app/Services/Service.php b/app/Services/Service.php
--- a/app/Services/Service.php
+++ b/app/Services/Service.php
@@ -22,4 +22,17 @@
* @var string
*/
public $secret;
+
+ /**
+ * Gets instance name
+ *
+ * @return string The instance name or "ø" if omitted
+ */
+ public function getInstanceName () {
+ if (!isset($this->instance)) {
+ return "ø";
+ }
+
+ return $this->instance;
+ }
}
diff --git a/tests/Services/ServiceTest.php b/tests/Services/ServiceTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Services/ServiceTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Services;
+
+use Nasqueron\Notifications\Services\Service;
+use Nasqueron\Notifications\Tests\TestCase;
+
+class ServiceTest extends TestCase {
+
+ /**
+ * @var Nasqueron\Notifications\Services\Service
+ */
+ private $serviceWithInstance;
+
+ /**
+ * @var Nasqueron\Notifications\Services\Service
+ */
+ private $serviceWithoutInstance;
+
+ public function setUp () {
+ $this->serviceWithoutInstance = new Service();
+
+ $this->serviceWithInstance = clone $this->serviceWithoutInstance;
+ $this->serviceWithInstance->instance = "http://www.perdu.com";
+ }
+
+ ///
+ /// Tests for getInstanceName()
+ ///
+
+ public function testGetInstanceName () {
+ $this->assertSame(
+ "http://www.perdu.com",
+ $this->serviceWithInstance->getInstanceName()
+ );
+ }
+
+ public function testGetInstanceNameWhenThereIsNoInstance () {
+ $this->assertSame(
+ "ø",
+ $this->serviceWithoutInstance->getInstanceName()
+ );
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 06:28 (18 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2277169
Default Alt Text
D302.diff (2 KB)

Event Timeline