3 namespace Drupal\KernelTests\Core\Test;
5 use Drupal\FunctionalTests\BrowserMissingDependentModuleMethodTest;
6 use Drupal\FunctionalTests\BrowserMissingDependentModuleTest;
7 use Drupal\KernelTests\KernelTestBase;
11 * @group FunctionalTests
13 * @coversDefaultClass \Drupal\Tests\BrowserTestBase
15 class BrowserTestBaseTest extends KernelTestBase {
18 * Tests that a test method is skipped when it requires a module not present.
20 * In order to catch checkRequirements() regressions, we have to make a new
21 * test object and run checkRequirements() here.
23 * @covers ::checkRequirements
24 * @covers ::checkModuleRequirements
26 public function testMethodRequiresModule() {
27 require __DIR__ . '/../../../../fixtures/BrowserMissingDependentModuleMethodTest.php';
29 $stub_test = new BrowserMissingDependentModuleMethodTest();
30 // We have to setName() to the method name we're concerned with.
31 $stub_test->setName('testRequiresModule');
33 // We cannot use $this->setExpectedException() because PHPUnit would skip
34 // the test before comparing the exception type.
36 $stub_test->publicCheckRequirements();
37 $this->fail('Missing required module throws skipped test exception.');
39 catch (\PHPUnit_Framework_SkippedTestError $e) {
40 $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage());
45 * Tests that a test case is skipped when it requires a module not present.
47 * In order to catch checkRequirements() regressions, we have to make a new
48 * test object and run checkRequirements() here.
50 * @covers ::checkRequirements
51 * @covers ::checkModuleRequirements
53 public function testRequiresModule() {
54 require __DIR__ . '/../../../../fixtures/BrowserMissingDependentModuleTest.php';
56 $stub_test = new BrowserMissingDependentModuleTest();
57 // We have to setName() to the method name we're concerned with.
58 $stub_test->setName('testRequiresModule');
60 // We cannot use $this->setExpectedException() because PHPUnit would skip
61 // the test before comparing the exception type.
63 $stub_test->publicCheckRequirements();
64 $this->fail('Missing required module throws skipped test exception.');
66 catch (\PHPUnit_Framework_SkippedTestError $e) {
67 $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage());