public function BuildTestTest::testPortMany in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php \Drupal\BuildTests\Framework\Tests\BuildTestTest::testPortMany()
@covers ::findAvailablePort
File
- core/
tests/ Drupal/ BuildTests/ Framework/ Tests/ BuildTestTest.php, line 132
Class
- BuildTestTest
- @coversDefaultClass \Drupal\BuildTests\Framework\BuildTestBase @group Build
Namespace
Drupal\BuildTests\Framework\TestsCode
public function testPortMany() {
$iterator = (new Finder())
->in($this
->getDrupalRoot())
->ignoreDotFiles(FALSE)
->exclude([
'sites/simpletest',
])
->path('/^.ht.router.php$/')
->getIterator();
$this
->copyCodebase($iterator);
/** @var \Symfony\Component\Process\Process[] $processes */
$processes = [];
$count = 15;
for ($i = 0; $i <= $count; $i++) {
$port = $this
->findAvailablePort();
$this
->assertArrayNotHasKey($port, $processes, 'Port ' . $port . ' was already in use by a process.');
$processes[$port] = $this
->instantiateServer($port);
$this
->assertNotEmpty($processes[$port]);
$this
->assertTrue($processes[$port]
->isRunning(), 'Process on port ' . $port . ' is not still running.');
$this
->assertFalse($this
->checkPortIsAvailable($port));
}
// Clean up after ourselves.
foreach ($processes as $process) {
$process
->stop();
}
}