diff --git a/documentation/environment-resolver.md b/documentation/environment-resolver.md index 7c7fc24..67f33f5 100644 --- a/documentation/environment-resolver.md +++ b/documentation/environment-resolver.md @@ -15,8 +15,6 @@ $resolver = \Drupal::service('helfi_api_base.environment_resolver'); $project = $resolver->getProject($projectName); /** @var \Drupal\helfi_api_base\Environment\ProjectMetadata $projectMetadata */ $projectMetadata = $project->getMetadata(); -// A link to the Azure DevOps service. -$projectMetadata->getAzureDevopsLink(); // 'https://dev.azure.com/City-of-Helsinki/asuminen'. // A link to the Git repository. $projectMetadata->getRepositoryUrl(); // 'https://github.com/City-of-Helsinki/drupal-helfi-asuminen'. @@ -31,8 +29,6 @@ $domain = $environment->getDomain(); // 'nginx-asuminen-dev.agw.arodevtest.hel.f $baseUrl = $environment->getBaseUrl(); // 'https://nginx-asuminen-dev.agw.arodevtest.hel.fi' /** @var \Drupal\helfi_api_base\Environment\EnvironmentMetadata $environmentMetadata */ $environmentMetadata = $environment->getMetadata(); -// A link to the OpenShift service. -$environmentMetadata->getOpenshiftConsoleLink(); // 'https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-asuminen-test' ``` ### Active environment diff --git a/fixtures/environments.json b/fixtures/environments.json index bd1161e..6e4e813 100644 --- a/fixtures/environments.json +++ b/fixtures/environments.json @@ -1,8 +1,7 @@ { "asuminen": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-asuminen", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/asuminen" + "repository": "City-of-Helsinki/drupal-helfi-asuminen" }, "environments": { "local": { @@ -19,8 +18,7 @@ "protocol": "http", "domain": "helfi-asuminen", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -35,9 +33,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-asuminen-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-asuminen-test" } }, "stage": { @@ -53,9 +48,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-asuminen-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-asuminen-staging" } }, "prod": { @@ -71,17 +63,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-asuminen-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-asuminen-prod" } } } }, "etusivu": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-etusivu", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/helfi-etusivu" + "repository": "City-of-Helsinki/drupal-helfi-etusivu" }, "environments": { "local": { @@ -98,8 +86,7 @@ "protocol": "http", "domain": "helfi-etusivu", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -114,9 +101,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-etusivu-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-etusivu-test" } }, "stage": { @@ -132,9 +116,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-etusivu-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-etusivu-staging" } }, "prod": { @@ -150,17 +131,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-etusivu-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-etusivu-prod" } } } }, "kasvatus-koulutus": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-kasvatus-koulutus", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/kasvatus-koulutus" + "repository": "City-of-Helsinki/drupal-helfi-kasvatus-koulutus" }, "environments": { "local": { @@ -177,8 +154,7 @@ "protocol": "http", "domain": "helfi-kasko", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -193,9 +169,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-kasvatus-koulutus-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kasko-kasvatus-koulutus-test" } }, "stage": { @@ -211,9 +184,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-kasvatus-koulutus-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kasko-kasvatus-koulutus-staging" } }, "prod": { @@ -229,17 +199,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-kasvatus-koulutus-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kasko-kasvatus-koulutus-prod" } } } }, "kuva": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-kuva", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/helfi-kuva" + "repository": "City-of-Helsinki/drupal-helfi-kuva" }, "environments": { "local": { @@ -256,8 +222,7 @@ "protocol": "http", "domain": "helfi-kuva", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -272,9 +237,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-kuva-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kuva-helfi-kuva-test" } }, "stage": { @@ -290,9 +252,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-kuva-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kuva-helfi-kuva-staging" } }, "prod": { @@ -308,17 +267,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-kuva-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kuva-helfi-kuva-prod" } } } }, "liikenne": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-kymp", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/liikenne" + "repository": "City-of-Helsinki/drupal-helfi-kymp" }, "environments": { "local": { @@ -335,8 +290,7 @@ "protocol": "http", "domain": "helfi-kymp", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -351,9 +305,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-liikenne-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-liikenne-test" } }, "stage": { @@ -369,9 +320,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-liikenne-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-liikenne-staging" } }, "prod": { @@ -387,17 +335,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-liikenne-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-liikenne-prod" } } } }, "rekry": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-rekry", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/helfi-rekry" + "repository": "City-of-Helsinki/drupal-helfi-rekry" }, "environments": { "local": { @@ -414,8 +358,7 @@ "protocol": "http", "domain": "helfi-rekry", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -430,9 +373,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-rekry-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-rekry-test" } }, "stage": { @@ -448,9 +388,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-rekry-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-rekry-staging" } }, "prod": { @@ -466,17 +403,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-rekry-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-helfi-rekry-prod" } } } }, "strategia": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-strategia", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/strategia-talous" + "repository": "City-of-Helsinki/drupal-helfi-strategia" }, "environments": { "local": { @@ -493,8 +426,7 @@ "protocol": "http", "domain": "strategia", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -509,9 +441,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-strategia-talous-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-strategia-talous-test" } }, "stage": { @@ -527,9 +456,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-strategia-talous-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-strategia-talous-staging" } }, "prod": { @@ -545,17 +471,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-strategia-talous-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-strategia-talous-prod" } } } }, "terveys": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-sote", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/terveys" + "repository": "City-of-Helsinki/drupal-helfi-sote" }, "environments": { "local": { @@ -572,8 +494,7 @@ "protocol": "http", "domain": "helfi-sote", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -588,9 +509,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-terveys-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-terveys-test" } }, "stage": { @@ -606,9 +524,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-terveys-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-terveys-staging" } }, "prod": { @@ -624,17 +539,13 @@ "internal_address": { "protocol": "https", "domain": "nginx-terveys-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-terveys-prod" } } } }, "tyo-yrittaminen": { "meta": { - "repository": "City-of-Helsinki/drupal-helfi-tyo-yrittaminen", - "azure_devops_link": "https://dev.azure.com/City-of-Helsinki/tyo-yrittaminen" + "repository": "City-of-Helsinki/drupal-helfi-tyo-yrittaminen" }, "environments": { "local": { @@ -651,8 +562,7 @@ "protocol": "http", "domain": "helfi-elo", "port": 8080 - }, - "meta": {} + } }, "test": { "path": { @@ -667,9 +577,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-tyo-yrittaminen-test.apps.arodevtest.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.arodevtest.hel.fi/k8s/cluster/projects/hki-kanslia-tyo-yrittaminen-test" } }, "stage": { @@ -685,9 +592,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-tyo-yrittaminen-staging.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-tyo-yrittaminen-staging" } }, "prod": { @@ -703,9 +607,6 @@ "internal_address": { "protocol": "https", "domain": "nginx-tyo-yrittaminen-prod.apps.platta.hel.fi" - }, - "meta": { - "openshift_console_link": "https://console-openshift-console.apps.platta.hel.fi/k8s/cluster/projects/hki-kanslia-tyo-yrittaminen-prod" } } } diff --git a/src/Environment/Environment.php b/src/Environment/Environment.php index 5e0bf9b..83b49fb 100644 --- a/src/Environment/Environment.php +++ b/src/Environment/Environment.php @@ -22,8 +22,6 @@ final class Environment { * Environment resolver identifier for the project. * @param \Drupal\helfi_api_base\Environment\EnvironmentEnum $environment * The environment name. - * @param \Drupal\helfi_api_base\Environment\EnvironmentMetadata|null $metadata - * The environment specific metadata. */ public function __construct( private readonly Address $address, @@ -31,7 +29,6 @@ public function __construct( private readonly array $paths, private readonly string $id, private readonly EnvironmentEnum $environment, - private readonly ?EnvironmentMetadata $metadata, ) { } @@ -129,14 +126,4 @@ public function getEnvironment() : EnvironmentEnum { return $this->environment; } - /** - * Gets the environment metadata. - * - * @return \Drupal\helfi_api_base\Environment\EnvironmentMetadata|null - * The metadata. - */ - public function getMetadata(): ?EnvironmentMetadata { - return $this->metadata; - } - } diff --git a/src/Environment/EnvironmentMetadata.php b/src/Environment/EnvironmentMetadata.php deleted file mode 100644 index 19f63fd..0000000 --- a/src/Environment/EnvironmentMetadata.php +++ /dev/null @@ -1,64 +0,0 @@ - $openShiftConsoleLink, - ] = $data; - - return new self($openShiftConsoleLink); - } - - /** - * Gets the link to OpenShift console. - * - * @return string - * The OpenShift console link. - */ - public function getOpenshiftConsoleLink(): string { - return $this->openshiftConsoleLink; - } - -} diff --git a/src/Environment/EnvironmentResolver.php b/src/Environment/EnvironmentResolver.php index c2d9594..62eda82 100644 --- a/src/Environment/EnvironmentResolver.php +++ b/src/Environment/EnvironmentResolver.php @@ -100,7 +100,6 @@ private function populateEnvironments(string $pathOrJson) : void { $settings['path'], $id, EnvironmentEnum::tryFrom($environment), - EnvironmentMetadata::createFromArray($settings['meta'] ?? []) )); } $this->projects[$id] = $project; diff --git a/src/Environment/ProjectMetadata.php b/src/Environment/ProjectMetadata.php index 3928d34..7681fa4 100644 --- a/src/Environment/ProjectMetadata.php +++ b/src/Environment/ProjectMetadata.php @@ -14,12 +14,9 @@ final class ProjectMetadata { * * @param string $repository * The repository. - * @param string $azureDevopsLink - * The azure devops link. */ public function __construct( private readonly string $repository, - private readonly string $azureDevopsLink, ) { } @@ -35,7 +32,6 @@ public function __construct( public static function createFromArray(array $data) : self { $required = [ 'repository', - 'azure_devops_link', ]; foreach ($required as $key) { @@ -46,20 +42,9 @@ public static function createFromArray(array $data) : self { [ 'repository' => $repository, - 'azure_devops_link' => $devopsLink, ] = $data; - return new self($repository, $devopsLink); - } - - /** - * Gets the Azure DevOps link. - * - * @return string - * The azure_devops_link link. - */ - public function getAzureDevopsLink() : string { - return $this->azureDevopsLink; + return new self($repository); } /** diff --git a/tests/src/Unit/Environment/EnvironmentMetadataTest.php b/tests/src/Unit/Environment/EnvironmentMetadataTest.php deleted file mode 100644 index daa9963..0000000 --- a/tests/src/Unit/Environment/EnvironmentMetadataTest.php +++ /dev/null @@ -1,53 +0,0 @@ - 'dsa']); - } - catch (\InvalidArgumentException $e) { - $this->assertMatchesRegularExpression('/Missing required/', $e->getMessage()); - $caught = TRUE; - } - $this->assertTrue($caught); - } - - /** - * @covers ::createFromArray - */ - public function testNull() : void { - $sut = EnvironmentMetadata::createFromArray([]); - $this->assertNull($sut); - } - - /** - * @covers ::__construct - * @covers ::createFromArray - * @covers ::getOpenshiftConsoleLink - */ - public function testGetters() : void { - $sut = EnvironmentMetadata::createFromArray([ - 'openshift_console_link' => 'https://example.com', - ]); - $this->assertEquals('https://example.com', $sut->getOpenshiftConsoleLink()); - } - -} diff --git a/tests/src/Unit/Environment/EnvironmentResolverTest.php b/tests/src/Unit/Environment/EnvironmentResolverTest.php index c105a28..e9a179a 100644 --- a/tests/src/Unit/Environment/EnvironmentResolverTest.php +++ b/tests/src/Unit/Environment/EnvironmentResolverTest.php @@ -40,8 +40,6 @@ class EnvironmentResolverTest extends UnitTestCase { * @covers \Drupal\helfi_api_base\Environment\EnvironmentTrait::normalizeEnvironmentName * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct */ public function testProjectConstant() : void { $constants = new \ReflectionClass(Project::class); @@ -119,8 +117,6 @@ public function populateEnvironmentsExceptionsData() : array { * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::getNormalizedRepository - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct * @dataProvider resolveEnvironmentExceptionData */ public function testGetEnvironmentException( @@ -164,8 +160,6 @@ public function resolveEnvironmentExceptionData() : array { * @covers \Drupal\helfi_api_base\Environment\EnvironmentTrait::normalizeEnvironmentName * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct * @dataProvider environmentMapData */ public function testEnvironmentMap(string $envName, string $expected) : void { @@ -203,8 +197,6 @@ public function environmentMapData() : array { * @covers \Drupal\helfi_api_base\Environment\Project::addEnvironment * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct * @dataProvider activeProjectExceptionData */ public function testGetActiveProjectException(mixed $value) : void { @@ -252,8 +244,6 @@ public function activeProjectExceptionData() : array { * @covers \Drupal\helfi_api_base\Environment\EnvironmentResolver::getProject * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct */ public function testGetActiveProject() : void { $sut = $this->getEnvironmentResolver(Project::ASUMINEN, 'dev'); @@ -278,8 +268,6 @@ public function testGetActiveProject() : void { * @covers \Drupal\helfi_api_base\Environment\Project::addEnvironment * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct */ public function testGetActiveEnvironmentException() : void { putenv('APP_ENV='); @@ -299,8 +287,6 @@ public function testGetActiveEnvironmentException() : void { * @covers \Drupal\helfi_api_base\Environment\EnvironmentTrait::normalizeEnvironmentName * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct */ public function testGetActiveEnvironmentFallback() : void { // Make sure environment resolver fallbacks to APP_ENV env variable when @@ -329,8 +315,6 @@ public function testGetActiveEnvironmentFallback() : void { * @covers \Drupal\helfi_api_base\Environment\EnvironmentTrait::normalizeEnvironmentName * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::createFromArray - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct */ public function testGetActiveEnvironment() : void { $sut = $this->getEnvironmentResolver(Project::ASUMINEN, 'test'); diff --git a/tests/src/Unit/Environment/EnvironmentTest.php b/tests/src/Unit/Environment/EnvironmentTest.php index ca7530a..aa06661 100644 --- a/tests/src/Unit/Environment/EnvironmentTest.php +++ b/tests/src/Unit/Environment/EnvironmentTest.php @@ -7,7 +7,6 @@ use Drupal\helfi_api_base\Environment\Address; use Drupal\helfi_api_base\Environment\Environment; use Drupal\helfi_api_base\Environment\EnvironmentEnum; -use Drupal\helfi_api_base\Environment\EnvironmentMetadata; use Drupal\Tests\UnitTestCase; /** @@ -27,8 +26,6 @@ class EnvironmentTest extends UnitTestCase { * @covers ::getBaseUrl * @cove * @covers ::getMetadata - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::__construct - * @covers \Drupal\helfi_api_base\Environment\EnvironmentMetadata::getOpenshiftConsoleLink */ public function testSimpleGetters() : void { $sut = new Environment( @@ -37,13 +34,12 @@ public function testSimpleGetters() : void { [], 'test', EnvironmentEnum::Test, - new EnvironmentMetadata('https://localhost')); + ); $this->assertEquals('test', $sut->getId()); $this->assertEquals(EnvironmentEnum::Test, $sut->getEnvironment()); $this->assertEquals(EnvironmentEnum::Test->value, $sut->getEnvironmentName()); $this->assertEquals('https://www.hel.fi', $sut->getBaseUrl()); $this->assertEquals('http://internal-address.local:8080', $sut->getInternalBaseUrl()); - $this->assertEquals('https://localhost', $sut->getMetadata()->getOpenshiftConsoleLink()); } /** @@ -59,7 +55,7 @@ public function testGetUrl() : void { ['fi' => 'test-path'], 'test', EnvironmentEnum::Local, - NULL); + ); $this->assertEquals('https://www.hel.fi/test-path', $sut->getUrl('fi')); $this->assertEquals('http://www.hel.fi/test-path', $sut->getInternalAddress('fi')); @@ -79,7 +75,7 @@ public function testGetUrl() : void { ['fi' => 'test-path'], 'test', EnvironmentEnum::Local, - NULL); + ); $this->assertEquals('https://www.hel.fi/test-path', $sut->getUrl('fi')); $this->assertEquals('https://www.hel.fi:8080/test-path', $sut->getInternalAddress('fi')); } diff --git a/tests/src/Unit/Environment/ProjectMetadataTest.php b/tests/src/Unit/Environment/ProjectMetadataTest.php index 3e29a9b..9833428 100644 --- a/tests/src/Unit/Environment/ProjectMetadataTest.php +++ b/tests/src/Unit/Environment/ProjectMetadataTest.php @@ -21,7 +21,7 @@ class ProjectMetadataTest extends UnitTestCase { public function testRequiredValueException() : void { $caught = FALSE; try { - ProjectMetadata::createFromArray(['repository' => 'test']); + ProjectMetadata::createFromArray(['dsad' => 'test']); } catch (\InvalidArgumentException $e) { $this->assertMatchesRegularExpression('/Missing required/', $e->getMessage()); @@ -33,7 +33,6 @@ public function testRequiredValueException() : void { /** * @covers ::__construct * @covers ::createFromArray - * @covers ::getAzureDevopsLink * @covers ::getRepository * @covers ::getRepositoryUrl * @covers ::getNormalizedRepository @@ -41,12 +40,10 @@ public function testRequiredValueException() : void { public function testGetters() : void { $sut = ProjectMetadata::createFromArray([ 'repository' => 'City-of-Helsinki/test', - 'azure_devops_link' => 'https://example.com/2', ]); $this->assertEquals('City-of-Helsinki/test', $sut->getRepository()); $this->assertEquals('city-of-helsinki/test', $sut->getNormalizedRepository()); $this->assertEquals('https://github.com/City-of-Helsinki/test', $sut->getRepositoryUrl()); - $this->assertEquals('https://example.com/2', $sut->getAzureDevopsLink()); } } diff --git a/tests/src/Unit/Environment/ProjectTest.php b/tests/src/Unit/Environment/ProjectTest.php index b0e78a5..012d029 100644 --- a/tests/src/Unit/Environment/ProjectTest.php +++ b/tests/src/Unit/Environment/ProjectTest.php @@ -28,7 +28,7 @@ public function testConstructorException() : void { $caught = FALSE; try { // Make sure $environments parameter must be an Environment object. - new Project(Project::ASUMINEN, new ProjectMetadata('', ''), ['invalid env']); + new Project(Project::ASUMINEN, new ProjectMetadata(''), ['invalid env']); } catch (\InvalidArgumentException $e) { $caught = TRUE; @@ -45,14 +45,13 @@ public function testConstructorException() : void { * @covers \Drupal\helfi_api_base\Environment\ProjectMetadata::__construct */ public function testGetters() : void { - $sut = new Project(Project::ASUMINEN, new ProjectMetadata('', ''), [ + $sut = new Project(Project::ASUMINEN, new ProjectMetadata(''), [ new Environment( new Address('www.hel.fi'), new Address('www.hel.fi'), [], Project::ASUMINEN, EnvironmentEnum::Local, - NULL ), ]); $this->assertEquals(Project::ASUMINEN, $sut->getName()); @@ -69,7 +68,7 @@ public function testGetters() : void { */ public function testGetEnvironmentException() : void { $caught = FALSE; - $sut = new Project(Project::ASUMINEN, new ProjectMetadata('', '')); + $sut = new Project(Project::ASUMINEN, new ProjectMetadata('')); try { $sut->getEnvironment('local'); } @@ -90,7 +89,7 @@ public function testLabel() : void { $found = 0; foreach ($constants->getConstants() as $value) { $found++; - $sut = new Project($value, new ProjectMetadata('', '')); + $sut = new Project($value, new ProjectMetadata('')); $this->assertInstanceOf(TranslatableMarkup::class, $sut->label()); } $this->assertTrue($found > 0);