/** * Test the round trip for PHPUnit execution status codes. * * @covers ::simpletest_run_phpunit_tests * * @dataProvider provideStatusCodes */ public function testSimpletestPhpUnitRunCommand($status, $label) { $test_id = basename(tempnam(sys_get_temp_dir(), 'xxx')); putenv('SimpletestPhpunitRunCommandTestWillDie=' . $status); $ret = simpletest_run_phpunit_tests($test_id, [SimpletestPhpunitRunCommandTestWillDie::class]); $this->assertSame($ret[0]['status'], $label); putenv('SimpletestPhpunitRunCommandTestWillDie'); unlink(simpletest_phpunit_xml_filepath($test_id)); }
function testSimpletestPhpUnitRunCommand() { include_once __DIR__ . '/../../fixtures/simpletest_phpunit_run_command_test.php'; $app_root = __DIR__ . '/../../../../../..'; include_once "{$app_root}/core/modules/simpletest/simpletest.module"; $container = new ContainerBuilder(); $container->set('app.root', $app_root); $file_system = $this->prophesize('Drupal\\Core\\File\\FileSystemInterface'); $file_system->realpath('public://simpletest')->willReturn(sys_get_temp_dir()); $container->set('file_system', $file_system->reveal()); \Drupal::setContainer($container); $test_id = basename(tempnam(sys_get_temp_dir(), 'xxx')); foreach (['pass', 'fail'] as $status) { putenv('SimpletestPhpunitRunCommandTestWillDie=' . $status); $ret = simpletest_run_phpunit_tests($test_id, ['Drupal\\Tests\\simpletest\\Unit\\SimpletestPhpunitRunCommandTestWillDie']); $this->assertSame($ret[0]['status'], $status); } unlink(simpletest_phpunit_xml_filepath($test_id)); }