diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php index d45c5bb12c..cf0e0d1612 100644 --- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php +++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php @@ -4,7 +4,6 @@ use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; -use Drupal\Tests\simpletest\Functional\ThroughUITest; /** * Tests the WebTestBase internal browser. @@ -117,35 +116,4 @@ public function testUserAgentValidation() { $this->assertResponse(403, 'Requesting https.php with a normal User-Agent fails.'); } - /** - * Tests that PHPUnit and KernelTestBase tests work through the UI. - * - * @todo Move this to a BrowserTestBase test. - */ - public function testTestingThroughUI() { - $this->drupalGet('admin/config/development/testing'); - $this->assertTrue(strpos($this->drupalSettings['simpleTest']['images'][0], 'core/misc/menu-collapsed.png') > 0, 'drupalSettings contains a link to core/misc/menu-collapsed.png.'); - // We can not test WebTestBase tests here since they require a valid .htkey - // to be created. However this scenario is covered by the testception of - // \Drupal\simpletest\Tests\SimpleTestTest. - - $tests = [ - // A KernelTestBase test. - 'Drupal\KernelTests\KernelTestBaseTest', - // A PHPUnit unit test. - 'Drupal\Tests\action\Unit\Menu\ActionLocalTasksTest', - // A PHPUnit functional test. - ThroughUITest::class, - ]; - - foreach ($tests as $test) { - $this->drupalGet('admin/config/development/testing'); - $edit = [ - "tests[$test]" => TRUE, - ]; - $this->drupalPostForm(NULL, $edit, t('Run tests')); - $this->assertText('0 fails, 0 exceptions'); - } - } - } diff --git a/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php b/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php index 6d99ab5860..e032cef941 100644 --- a/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php +++ b/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php @@ -11,8 +11,6 @@ * @group simpletest * * @see \Drupal\Tests\Listeners\SimpletestUiPrinter - * - * @todo Convert to BrowserTestBase test. */ class UiPhpUnitOutputTest extends WebTestBase { diff --git a/core/modules/simpletest/tests/src/Functional/SimpletestUiTest.php b/core/modules/simpletest/tests/src/Functional/SimpletestUiTest.php new file mode 100644 index 0000000000..43fdd2b2fc --- /dev/null +++ b/core/modules/simpletest/tests/src/Functional/SimpletestUiTest.php @@ -0,0 +1,64 @@ +drupalLogin($this->createUser(['administer unit tests'])); + } + + /** + * Tests that unit, kernel, and functional tests work through the UI. + */ + public function testTestingThroughUI() { + $url = Url::fromRoute('simpletest.test_form'); + $assertion = $this->assertSession(); + + $this->drupalGet($url); + $settings = $this->getDrupalSettings(); + $this->assertTrue(strpos($settings['simpleTest']['images'][0], 'core/misc/menu-collapsed.png') > 0, 'drupalSettings contains a link to core/misc/menu-collapsed.png.'); + + // We can not test WebTestBase tests here since they require a valid .htkey + // to be created. However this scenario is covered by the testception of + // \Drupal\simpletest\Tests\SimpleTestTest. + $tests = [ + // A KernelTestBase test. + KernelTestBaseTest::class, + // A PHPUnit unit test. + ActionLocalTasksTest::class, + // A PHPUnit functional test. + ThroughUITest::class, + ]; + + foreach ($tests as $test) { + $edit = [ + "tests[$test]" => TRUE, + ]; + $this->drupalPostForm($url, $edit, t('Run tests')); + $assertion->pageTextContains('0 fails, 0 exceptions'); + } + } + +} diff --git a/core/modules/simpletest/tests/src/Unit/SimpletestUiPrinterTest.php b/core/modules/simpletest/tests/src/Unit/SimpletestUiPrinterTest.php new file mode 100644 index 0000000000..03aeda66f0 --- /dev/null +++ b/core/modules/simpletest/tests/src/Unit/SimpletestUiPrinterTest.php @@ -0,0 +1,34 @@ +'], + ['http:////www.example.com', 'http:////www.example.com'], + ['this is some text http://www.example.com/ with a link in it.', 'this is some text http://www.example.com/ with a link in it.'], + ["HTML output was generated
\n", "HTML output was generated\n"], + ]; + } + + /** + * @dataProvider provideBuffer + */ + public function testWrite($expected, $buffer) { + $printer = new SimpletestUiPrinter(); + // Set up our expectation. + $this->expectOutputString($expected); + // Write the buffer. + $printer->write($buffer); + } + +} diff --git a/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php b/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php index 7c1f45e38f..53bb0e2347 100644 --- a/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php +++ b/core/tests/Drupal/Tests/Listeners/Legacy/HtmlOutputPrinter.php @@ -15,7 +15,7 @@ class HtmlOutputPrinter extends \PHPUnit_TextUI_ResultPrinter { /** * {@inheritdoc} */ - public function __construct($out, $verbose, $colors, $debug, $numberOfColumns) { + public function __construct($out = null, $verbose = false, $colors = self::COLOR_DEFAULT, $debug = false, $numberOfColumns = 80) { parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns); $this->setUpHtmlOutput();