$flat */ private function resolverWithFlatConfig(array $flat): EnvServicePortResolver { $config = new DeploymentConfig(); foreach ($flat as $k => $v) { $config->setTestValue($k, $v); } return new EnvServicePortResolver($config); } public function testMysqlDefaultPortWhenOmitted(): void { $r = $this->resolverWithFlatConfig([ 'db/connection/default' => [ 'host' => '127.0.0.1', 'active' => '1', ], ]); $resolved = $r->resolveService('mysql_default'); $this->assertNotNull($resolved); $this->assertSame('127.0.0.1', $resolved['host']); $this->assertSame(3306, $resolved['port']); } public function testDiscoversRedisCacheFrontendsAndSession(): void { $r = $this->resolverWithFlatConfig([ 'db/connection/default' => ['host' => '127.0.0.1'], 'cache' => [ 'frontend' => [ 'default' => [ 'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis', 'backend_options' => [ 'server' => '127.0.0.1', 'port' => '6380', ], ], 'page_cache' => [ 'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis', 'backend_options' => [ 'server' => '127.0.0.1', 'port' => '6381', ], ], ], ], 'session' => [ 'save' => 'redis', 'redis' => [ 'host' => '127.0.0.1', 'port' => '6379', ], ], ]); $this->assertNotNull($r->resolveService('mysql_default')); $keys = []; foreach ($r->getDiscoveredServices() as $s) { $keys[] = $s['service_key']; } $this->assertContains('cache_frontend_default', $keys); $this->assertContains('cache_frontend_page_cache', $keys); $this->assertContains('session_redis', $keys); } public function testAmqpAndHttpCacheHosts(): void { $r = $this->resolverWithFlatConfig([ 'db/connection/default' => ['host' => '127.0.0.1'], 'queue' => [ 'amqp' => [ 'host' => '127.0.0.1', 'port' => '5672', ], ], 'http_cache_hosts' => [ ['host' => '127.0.0.1', 'port' => '80'], ], ]); $this->assertNotNull($r->resolveService('queue_amqp')); $this->assertNotNull($r->resolveService('http_cache_0')); } public function testResolveUnknownKeyReturnsNull(): void { $r = $this->resolverWithFlatConfig([ 'db/connection/default' => ['host' => '127.0.0.1'], ]); $this->assertNull($r->resolveService('does_not_exist')); } }