-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #788 from City-of-Helsinki/UHF-10339
UHF-10339: Default to testing in case matching environment does not exist
- Loading branch information
Showing
3 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
modules/helfi_paragraphs_news_list/tests/src/Unit/ClientBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\Tests\helfi_\Unit; | ||
|
||
use Drupal\helfi_api_base\Environment\EnvironmentResolver; | ||
use Drupal\helfi_paragraphs_news_list\ClientBuilder; | ||
use Drupal\Tests\helfi_api_base\Traits\EnvironmentResolverTrait; | ||
use Drupal\Tests\UnitTestCase; | ||
use Elasticsearch\Client; | ||
|
||
/** | ||
* Tests elastic client builder. | ||
* | ||
* @group helfi_api_base | ||
*/ | ||
class ClientBuilderTest extends UnitTestCase { | ||
|
||
use EnvironmentResolverTrait; | ||
|
||
/** | ||
* Tests that client builder fallbacks to testing environment. | ||
*/ | ||
public function testEnvironmentFallback() : void { | ||
/** @var \Drupal\Core\Config\ConfigFactoryInterface $configFactory */ | ||
$configFactory = $this->getConfigFactoryStub([ | ||
'helfi_api_base.environment_resolver.settings' => [ | ||
EnvironmentResolver::ENVIRONMENT_NAME_KEY => 'nonexistent', | ||
], | ||
]); | ||
$envResolver = new EnvironmentResolver($configFactory); | ||
$sut = new ClientBuilder($envResolver); | ||
$this->assertInstanceOf(Client::class, $sut->create()); | ||
} | ||
|
||
} |