X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FKernelTests%2FCore%2FTest%2FBrowserTestBaseTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FKernelTests%2FCore%2FTest%2FBrowserTestBaseTest.php;h=c93069c8e404d27a8677018c9fcaebb544fb25c7;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/tests/Drupal/KernelTests/Core/Test/BrowserTestBaseTest.php b/web/core/tests/Drupal/KernelTests/Core/Test/BrowserTestBaseTest.php new file mode 100644 index 000000000..c93069c8e --- /dev/null +++ b/web/core/tests/Drupal/KernelTests/Core/Test/BrowserTestBaseTest.php @@ -0,0 +1,71 @@ +setName('testRequiresModule'); + + // We cannot use $this->setExpectedException() because PHPUnit would skip + // the test before comparing the exception type. + try { + $stub_test->publicCheckRequirements(); + $this->fail('Missing required module throws skipped test exception.'); + } + catch (\PHPUnit_Framework_SkippedTestError $e) { + $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage()); + } + } + + /** + * Tests that a test case is skipped when it requires a module not present. + * + * In order to catch checkRequirements() regressions, we have to make a new + * test object and run checkRequirements() here. + * + * @covers ::checkRequirements + * @covers ::checkModuleRequirements + */ + public function testRequiresModule() { + require __DIR__ . '/../../../../fixtures/BrowserMissingDependentModuleTest.php'; + + $stub_test = new BrowserMissingDependentModuleTest(); + // We have to setName() to the method name we're concerned with. + $stub_test->setName('testRequiresModule'); + + // We cannot use $this->setExpectedException() because PHPUnit would skip + // the test before comparing the exception type. + try { + $stub_test->publicCheckRequirements(); + $this->fail('Missing required module throws skipped test exception.'); + } + catch (\PHPUnit_Framework_SkippedTestError $e) { + $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage()); + } + } + +}