Browse Source

add unit tests for OpentalentEnvService

Olivier Massot 4 years ago
parent
commit
71486649e5
1 changed files with 26 additions and 0 deletions
  1. 26 0
      ot_core/Tests/Unit/Service/OpentalentEnvServiceTest.php

+ 26 - 0
ot_core/Tests/Unit/Service/OpentalentEnvServiceTest.php

@@ -0,0 +1,26 @@
+<?php
+
+namespace Opentalent\OtCore\Tests\Unit\Service;
+
+use Nimut\TestingFramework\TestCase\UnitTestCase;
+use Opentalent\OtCore\Service\OpentalentEnvService;
+
+class OpentalentEnvServiceTest extends UnitTestCase
+{
+    /**
+     * get should return the requested variable default value,
+     * or the overridden one if $GLOBALS have been set
+     *
+     * @test
+     */
+    public function get() {
+        $this->assertEquals('https://api.opentalent.fr', OpentalentEnvService::get('API_BASE_URI'));
+        $this->assertEquals('prod-back', OpentalentEnvService::get('DB_HOST'));
+        $this->assertEquals('dbcloner', OpentalentEnvService::get('DB_USER'));
+        $this->assertEquals('wWZ4hYcrmHLW2mUK', OpentalentEnvService::get('DB_PASSWORD'));
+
+        $GLOBALS['OT']['API_BASE_URI'] = 'https://local.api.opentalent.fr';
+
+        $this->assertEquals('https://local.api.opentalent.fr', OpentalentEnvService::get('API_BASE_URI'));
+    }
+}