You are here

public function SimpleTestBrowserTest::testTestingThroughUI in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php \Drupal\simpletest\Tests\SimpleTestBrowserTest::testTestingThroughUI()

Tests that PHPUnit and KernelTestBase tests work through the UI.

File

core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php, line 126
Contains \Drupal\simpletest\Tests\SimpleTestBrowserTest.

Class

SimpleTestBrowserTest
Tests the Simpletest UI internal browser.

Namespace

Drupal\simpletest\Tests

Code

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 = array(
    // A KernelTestBase test.
    'Drupal\\system\\Tests\\DrupalKernel\\DrupalKernelTest',
    // A PHPUnit unit test.
    'Drupal\\Tests\\action\\Unit\\Menu\\ActionLocalTasksTest',
    // A PHPUnit functional test.
    'Drupal\\Tests\\simpletest\\Functional\\BrowserTestBaseTest',
  );
  foreach ($tests as $test) {
    $this
      ->drupalGet('admin/config/development/testing');
    $edit = array(
      "tests[{$test}]" => TRUE,
    );
    $this
      ->drupalPostForm(NULL, $edit, t('Run tests'));
    $this
      ->assertText('0 fails, 0 exceptions');
  }
}