Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Test / BrowserTestBaseTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Test;
4
5 use Drupal\FunctionalTests\BrowserMissingDependentModuleMethodTest;
6 use Drupal\FunctionalTests\BrowserMissingDependentModuleTest;
7 use Drupal\KernelTests\KernelTestBase;
8
9 /**
10  * @group Test
11  * @group FunctionalTests
12  *
13  * @coversDefaultClass \Drupal\Tests\BrowserTestBase
14  */
15 class BrowserTestBaseTest extends KernelTestBase {
16
17   /**
18    * Tests that a test method is skipped when it requires a module not present.
19    *
20    * In order to catch checkRequirements() regressions, we have to make a new
21    * test object and run checkRequirements() here.
22    *
23    * @covers ::checkRequirements
24    * @covers ::checkModuleRequirements
25    */
26   public function testMethodRequiresModule() {
27     require __DIR__ . '/../../../../fixtures/BrowserMissingDependentModuleMethodTest.php';
28
29     $stub_test = new BrowserMissingDependentModuleMethodTest();
30     // We have to setName() to the method name we're concerned with.
31     $stub_test->setName('testRequiresModule');
32
33     // We cannot use $this->setExpectedException() because PHPUnit would skip
34     // the test before comparing the exception type.
35     try {
36       $stub_test->publicCheckRequirements();
37       $this->fail('Missing required module throws skipped test exception.');
38     }
39     catch (\PHPUnit_Framework_SkippedTestError $e) {
40       $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage());
41     }
42   }
43
44   /**
45    * Tests that a test case is skipped when it requires a module not present.
46    *
47    * In order to catch checkRequirements() regressions, we have to make a new
48    * test object and run checkRequirements() here.
49    *
50    * @covers ::checkRequirements
51    * @covers ::checkModuleRequirements
52    */
53   public function testRequiresModule() {
54     require __DIR__ . '/../../../../fixtures/BrowserMissingDependentModuleTest.php';
55
56     $stub_test = new BrowserMissingDependentModuleTest();
57     // We have to setName() to the method name we're concerned with.
58     $stub_test->setName('testRequiresModule');
59
60     // We cannot use $this->setExpectedException() because PHPUnit would skip
61     // the test before comparing the exception type.
62     try {
63       $stub_test->publicCheckRequirements();
64       $this->fail('Missing required module throws skipped test exception.');
65     }
66     catch (\PHPUnit_Framework_SkippedTestError $e) {
67       $this->assertEqual('Required modules: module_does_not_exist', $e->getMessage());
68     }
69   }
70
71 }