|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace AsyncAws\Core\Tests\Unit; |
| 6 | + |
| 7 | +use AsyncAws\Core\Configuration; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | + |
| 10 | +class ConfigurationTest extends TestCase |
| 11 | +{ |
| 12 | + public function testDefaultValues() |
| 13 | + { |
| 14 | + $config = Configuration::create(['endpoint' => 'foo']); |
| 15 | + self::assertEquals('foo', $config->get('endpoint')); |
| 16 | + |
| 17 | + $config = Configuration::create(['endpoint' => '']); |
| 18 | + self::assertEquals('', $config->get('endpoint')); |
| 19 | + |
| 20 | + $config = Configuration::create([]); |
| 21 | + self::assertEquals('https://%service%.%region%.amazonaws.com', $config->get('endpoint')); |
| 22 | + |
| 23 | + // If a configuration value is set to null, we should use default value. |
| 24 | + $config = Configuration::create(['endpoint' => null]); |
| 25 | + self::assertEquals('https://%service%.%region%.amazonaws.com', $config->get('endpoint')); |
| 26 | + |
| 27 | + $config = Configuration::create([]); |
| 28 | + self::assertEquals('default', $config->get('profile')); |
| 29 | + |
| 30 | + putenv('AWS_PROFILE=foo'); |
| 31 | + $config = Configuration::create([]); |
| 32 | + self::assertEquals('foo', $config->get('profile')); |
| 33 | + |
| 34 | + putenv('AWS_PROFILE'); |
| 35 | + $config = Configuration::create([]); |
| 36 | + self::assertEquals('default', $config->get('profile')); |
| 37 | + } |
| 38 | +} |
0 commit comments