/** * @test */ public function getSortedMatchesReturnsNoMatchIfDomainIsLongerThanHostname() { $mockDomains = array($this->getMockBuilder(Domain::class)->disableOriginalConstructor()->setMethods(array('dummy'))->getMock()); $mockDomains[0]->setHostname('flow.neos.io'); $expectedDomains = array(); $strategy = new DomainMatchingStrategy(); $actualDomains = $strategy->getSortedMatches('neos.io', $mockDomains); $this->assertSame($expectedDomains, $actualDomains); }
/** * Finds all active domains matching the given hostname. * * Their order is determined by how well they match, best match first. * * @param string $hostname Hostname the domain should match with (eg. "localhost" or "www.neos.io") * @param boolean $onlyActive Only include active domains * @return array An array of matching domains * @api */ public function findByHost($hostname, $onlyActive = false) { $domains = $onlyActive === true ? $this->findByActive(true)->toArray() : $this->findAll()->toArray(); return $this->domainMatchingStrategy->getSortedMatches($hostname, $domains); }