/** * Test that exception is thrown as there are too many matches. * * @param \Envariable\Util\Server $server */ function it_throws_exception_as_there_are_one_too_many_matches(Server $server) { $_SERVER['SERVER_NAME'] = 'www.example.com'; $server->getInterfaceType()->willReturn('apache2handler'); $server->getHostname()->willReturn(self::$configMap['environmentToDetectionMethodMap']['production-without-servername-matching']['hostname']); $this->setConfiguration(array('environmentToDetectionMethodMap' => array('production' => array('hostname' => 'production.machine-name.without-servername-matching'), 'production-redundant-entry' => array('hostname' => 'production.machine-name.without-servername-matching')), 'cliDefaultEnvironment' => 'production')); $this->setServer($server); $this->setEnvironmentValidationStrategyMap(self::$environmentValidationStrategyMap); $this->shouldThrow(new \RuntimeException('Could not detect the environment.'))->duringDetect(); $this->getEnvironment()->shouldReturn(null); }
/** * {@inheritdoc} */ public function validate(array $configMap) { $validHostname = $this->server->getHostname() === $configMap['hostname']; return $validHostname && strpos($_SERVER['SERVER_NAME'], $configMap['servername']) === 0; }
/** * {@inheritdoc} */ public function validate(array $configMap) { return $this->server->getHostname() === $configMap['hostname']; }