class SecurityAdvisoriesFetcherTest in Drupal 10
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Kernel/SecurityAdvisories/SecurityAdvisoriesFetcherTest.php \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest
@coversDefaultClass \Drupal\system\SecurityAdvisories\SecurityAdvisoriesFetcher
@group system
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\system\Kernel\SecurityAdvisories\SecurityAdvisoriesFetcherTest implements \Psr\Log\LoggerInterface uses \Drupal\Core\Logger\RfcLoggerTrait
Expanded class hierarchy of SecurityAdvisoriesFetcherTest
File
- core/
modules/ system/ tests/ src/ Kernel/ SecurityAdvisories/ SecurityAdvisoriesFetcherTest.php, line 23
Namespace
Drupal\Tests\system\Kernel\SecurityAdvisoriesView source
class SecurityAdvisoriesFetcherTest extends KernelTestBase implements LoggerInterface {
use RfcLoggerTrait;
/**
* The log messages from watchdog_exception.
*
* @var string[]
*/
protected $watchdogExceptionMessages = [];
/**
* The log error log messages.
*
* @var string[]
*/
protected $logErrorMessages = [];
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'advisory_feed_test',
];
/**
* History of requests/responses.
*
* @var array
*/
protected $history = [];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this
->installConfig('system');
$this->container
->get('logger.factory')
->addLogger($this);
}
/**
* Tests contrib advisories that should be displayed.
*
* @param mixed[] $feed_item
* The feed item to test. 'title' and 'link' are omitted from this array
* because they do not need to vary between test cases.
* @param string|null $existing_version
* The existing version of the module.
*
* @dataProvider providerShowAdvisories
*/
public function testShowAdvisories(array $feed_item, string $existing_version = NULL) : void {
$this
->setFeedItems([
$feed_item,
]);
if ($existing_version !== NULL) {
$this
->setExistingProjectVersion($existing_version);
}
$links = $this
->getAdvisories();
$this
->assertCount(1, $links);
$this
->assertSame('http://example.com', $links[0]
->getUrl());
$this
->assertSame('SA title', $links[0]
->getTitle());
$this
->assertCount(1, $this->history);
}
/**
* Data provider for testShowAdvisories().
*/
public function providerShowAdvisories() : array {
return [
'contrib:exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0.0',
],
],
'existing_version' => '1.0.0',
],
'contrib:exact:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:not-exact:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '1.0',
],
'contrib:non-matching:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-2.0',
],
'contrib:no-insecure:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [],
],
'existing_version' => '8.x-2.0',
],
'contrib:no-existing-version:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-2.0',
],
],
'existing_version' => '',
],
'contrib:dev:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'the_project',
'insecure' => [],
],
'existing_version' => '8.x-2.x-dev',
],
'contrib:existing-dev-match-minor:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-1.x-dev',
],
'contrib:existing-dev-match-major-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.1.1',
],
],
'existing_version' => '8.x-dev',
],
'contrib:existing-dev-match-minor-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.2.1',
],
],
'existing_version' => '8.2.x-dev',
],
'core:exact:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
],
],
'core:exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
],
],
'core:not-exact:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
'9.1',
],
],
],
'core:non-matching:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
'9.0.0',
],
],
],
'core:no-insecure:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'core',
'project' => 'drupal',
'insecure' => [],
],
],
];
}
/**
* Tests advisories that should be ignored.
*
* @param mixed[] $feed_item
* The feed item to test. 'title' and 'link' are omitted from this array
* because they do not need to vary between test cases.
* @param string|null $existing_version
* The existing version of the module.
*
* @dataProvider providerIgnoreAdvisories
*/
public function testIgnoreAdvisories(array $feed_item, string $existing_version = NULL) : void {
$this
->setFeedItems([
$feed_item,
]);
if ($existing_version !== NULL) {
$this
->setExistingProjectVersion($existing_version);
}
$this
->assertCount(0, $this
->getAdvisories());
$this
->assertCount(1, $this->history);
}
/**
* Data provider for testIgnoreAdvisories().
*/
public function providerIgnoreAdvisories() : array {
return [
'contrib:not-exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:non-matching:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.1',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:not-exact:non-psa-reversed' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '1.0',
],
'contrib:semver-non-exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0',
],
],
'existing_version' => '1.0.0',
],
'contrib:semver-major-match-not-minor:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.1.0',
],
],
'existing_version' => '1.0.0',
],
'contrib:semver-major-minor-match-not-patch:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.1.1',
],
],
'existing_version' => '1.1.0',
],
'contrib:non-matching-not-exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.1',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:both-extra:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0-extraStringNotSpecial',
],
],
'existing_version' => '8.x-1.0-alsoNotSpecialNotMatching',
],
'contrib:semver-7major-match:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'7.x-1.0',
],
],
'existing_version' => '1.0.0',
],
'contrib:different-majors:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'7.x-1.0',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:semver-different-majors:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0.0',
],
],
'existing_version' => '2.0.0',
],
'contrib:no-version:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.1',
],
],
'existing_version' => '',
],
'contrib:insecure-extra:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0-extraStringNotSpecial',
],
],
'existing_version' => '8.x-1.0',
],
'contrib:existing-dev-different-minor:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-2.x-dev',
],
'contrib:existing-dev-different-major:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'7.x-1.0',
],
],
'existing_version' => '8.x-1.x-dev',
],
'contrib:existing-dev-different-major-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.0.0',
],
],
'existing_version' => '9.0.x-dev',
],
'contrib:existing-dev-different-major-no-minor-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.0.0',
],
],
'existing_version' => '9.x-dev',
],
'contrib:existing-dev-different-minor-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0.0',
],
],
'existing_version' => '1.1.0-dev',
],
'contrib:existing-dev-different-minor-x-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'1.0.0',
],
],
'existing_version' => '1.1.x-dev',
],
'contrib:existing-dev-different-8major-semver:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-dev',
],
'contrib:non-existing-project:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'non_existing_project',
'insecure' => [
'8.x-1.0',
],
],
],
'contrib:non-existing-project:psa' => [
'feed_item' => [
'is_psa' => 1,
'type' => 'module',
'project' => 'non_existing_project',
'insecure' => [
'8.x-1.0',
],
],
],
'core:non-matching:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
'9.0.0',
],
],
],
'core:non-matching-not-exact:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
'9.1',
],
],
],
'core:no-insecure:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'core',
'project' => 'drupal',
'insecure' => [],
],
],
'contrib:existing-extra:non-psa' => [
'feed_item' => [
'is_psa' => 0,
'type' => 'module',
'project' => 'the_project',
'insecure' => [
'8.x-1.0',
],
],
'existing_version' => '8.x-1.0-extraStringNotSpecial',
],
];
}
/**
* Sets the feed items to be returned for the test.
*
* @param mixed[][] $feed_items
* The feeds items to test. Every time the http_client makes a request the
* next item in this array will be returned. For each feed item 'title' and
* 'link' are omitted because they do not need to vary between test cases.
*/
protected function setFeedItems(array $feed_items) : void {
$responses = [];
foreach ($feed_items as $feed_item) {
$feed_item += [
'title' => 'SA title',
'link' => 'http://example.com',
];
$responses[] = new Response('200', [], json_encode([
$feed_item,
]));
}
$this
->setTestFeedResponses($responses);
}
/**
* Sets the existing version of the project.
*
* @param string $existing_version
* The existing version of the project.
*/
protected function setExistingProjectVersion(string $existing_version) : void {
$module_list = $this
->prophesize(ModuleExtensionList::class);
$extension = $this
->prophesize(Extension::class)
->reveal();
$extension->info = [
'project' => 'the_project',
];
if (!empty($existing_version)) {
$extension->info['version'] = $existing_version;
}
$module_list
->getList()
->willReturn([
$extension,
]);
$this->container
->set('extension.list.module', $module_list
->reveal());
}
/**
* Tests that the stored advisories response is deleted on interval decrease.
*/
public function testIntervalConfigUpdate() : void {
$feed_item_1 = [
'is_psa' => 1,
'type' => 'core',
'title' => 'Oh no🙀! Advisory 1',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
];
$feed_item_2 = [
'is_psa' => 1,
'type' => 'core',
'title' => 'Oh no😱! Advisory 2',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
];
$this
->setFeedItems([
$feed_item_1,
$feed_item_2,
]);
$advisories = $this
->getAdvisories();
$this
->assertCount(1, $advisories);
$this
->assertSame($feed_item_1['title'], $advisories[0]
->getTitle());
$this
->assertCount(1, $this->history);
// Ensure that new feed item is not retrieved because the stored response
// has not expired.
$advisories = $this
->getAdvisories();
$this
->assertCount(1, $this->history);
$this
->assertCount(1, $advisories);
$this
->assertSame($feed_item_1['title'], $advisories[0]
->getTitle());
/** @var \Drupal\Core\Config\Config $config */
$config = $this->container
->get('config.factory')
->getEditable('system.advisories');
$interval = $config
->get('interval_hours');
$config
->set('interval_hours', $interval + 1)
->save();
// Ensure that new feed item is not retrieved when the interval is
// increased.
$advisories = $this
->getAdvisories();
$this
->assertCount(1, $this->history);
$this
->assertCount(1, $advisories);
$this
->assertSame($feed_item_1['title'], $advisories[0]
->getTitle());
// Ensure that new feed item is retrieved when the interval is decreased.
$config
->set('interval_hours', $interval - 1)
->save();
$advisories = $this
->getAdvisories();
$this
->assertCount(2, $this->history);
$this
->assertCount(1, $advisories);
$this
->assertSame($feed_item_2['title'], $advisories[0]
->getTitle());
}
/**
* Tests that invalid JSON feed responses are not stored.
*/
public function testInvalidJsonResponse() : void {
$non_json_response = new Response(200, [], '1');
$json_response = new Response(200, [], '[]');
// Set 2 non-JSON responses and 1 JSON response.
$this
->setTestFeedResponses([
$non_json_response,
$non_json_response,
$json_response,
]);
$this
->assertNull($this
->getAdvisories());
$this
->assertCount(1, $this->history);
$this
->assertServiceAdvisoryLoggedErrors([
'The security advisory JSON feed from Drupal.org could not be decoded.',
]);
// Confirm that previous non-JSON response was not stored.
$this
->assertNull($this
->getAdvisories());
$this
->assertCount(2, $this->history);
$this
->assertServiceAdvisoryLoggedErrors([
'The security advisory JSON feed from Drupal.org could not be decoded.',
]);
// Confirm that if $allow_http_request is set to FALSE a new request will
// not be attempted.
$this
->assertNull($this
->getAdvisories(FALSE));
$this
->assertCount(2, $this->history);
// Make a 3rd request that will return a valid JSON response.
$this
->assertCount(0, $this
->getAdvisories());
$this
->assertCount(3, $this->history);
// Confirm that getting the advisories after a valid JSON response will use
// the stored response and not make another 'http_client' request.
$this
->assertCount(0, $this
->getAdvisories());
$this
->assertCount(3, $this->history);
$this
->assertServiceAdvisoryLoggedErrors([]);
}
/**
* @covers ::doRequest
* @covers ::getSecurityAdvisories
*/
public function testHttpFallback() : void {
$this
->setSetting('update_fetch_with_http_fallback', TRUE);
$feed_item = [
'is_psa' => 1,
'type' => 'core',
'project' => 'drupal',
'insecure' => [
\Drupal::VERSION,
],
'title' => 'SA title',
'link' => 'http://example.com',
];
$this
->setTestFeedResponses([
new Response('500', [], 'HTTPS failed'),
new Response('200', [], json_encode([
$feed_item,
])),
]);
$advisories = $this
->getAdvisories();
// There should be two request / response pairs.
$this
->assertCount(2, $this->history);
// The first request should have been HTTPS and should have failed.
$first_try = $this->history[0];
$this
->assertNotEmpty($first_try);
$this
->assertEquals('https', $first_try['request']
->getUri()
->getScheme());
$this
->assertEquals(500, $first_try['response']
->getStatusCode());
// The second request should have been the HTTP fallback and should have
// worked.
$second_try = $this->history[1];
$this
->assertNotEmpty($second_try);
$this
->assertEquals('http', $second_try['request']
->getUri()
->getScheme());
$this
->assertEquals(200, $second_try['response']
->getStatusCode());
$this
->assertCount(1, $advisories);
$this
->assertSame('http://example.com', $advisories[0]
->getUrl());
$this
->assertSame('SA title', $advisories[0]
->getTitle());
$this
->assertSame([
"Server error: `GET https://updates.drupal.org/psa.json` resulted in a `500 Internal Server Error` response:\nHTTPS failed\n",
], $this->watchdogExceptionMessages);
}
/**
* @covers ::doRequest
* @covers ::getSecurityAdvisories
*/
public function testNoHttpFallback() : void {
$this
->setTestFeedResponses([
new Response('500', [], 'HTTPS failed'),
]);
$exception_thrown = FALSE;
try {
$this
->getAdvisories();
} catch (TransferException $exception) {
$this
->assertSame("Server error: `GET https://updates.drupal.org/psa.json` resulted in a `500 Internal Server Error` response:\nHTTPS failed\n", $exception
->getMessage());
$exception_thrown = TRUE;
}
$this
->assertTrue($exception_thrown);
// There should only be one request / response pair.
$this
->assertCount(1, $this->history);
$request = $this->history[0]['request'];
$this
->assertNotEmpty($request);
// It should have only been an HTTPS request.
$this
->assertEquals('https', $request
->getUri()
->getScheme());
// And it should have failed.
$response = $this->history[0]['response'];
$this
->assertEquals(500, $response
->getStatusCode());
}
/**
* Gets the advisories from the 'system.sa_fetcher' service.
*
* @param bool $allow_http_request
* Argument to pass on to
* SecurityAdvisoriesFetcher::getSecurityAdvisories().
*
* @return \Drupal\system\SecurityAdvisories\SecurityAdvisory[]|null
* The return value of SecurityAdvisoriesFetcher::getSecurityAdvisories().
*/
protected function getAdvisories(bool $allow_http_request = TRUE) : ?array {
$fetcher = $this->container
->get('system.sa_fetcher');
return $fetcher
->getSecurityAdvisories($allow_http_request);
}
/**
* Sets test feed responses.
*
* @param \GuzzleHttp\Psr7\Response[] $responses
* The responses for the http_client service to return.
*/
protected function setTestFeedResponses(array $responses) : void {
// Create a mock and queue responses.
$mock = new MockHandler($responses);
$handler_stack = HandlerStack::create($mock);
$history = Middleware::history($this->history);
$handler_stack
->push($history);
// Rebuild the container because the 'system.sa_fetcher' service and other
// services may already have an instantiated instance of the 'http_client'
// service without these changes.
$this->container
->get('kernel')
->rebuildContainer();
$this->container = $this->container
->get('kernel')
->getContainer();
$this->container
->get('logger.factory')
->addLogger($this);
$this->container
->set('http_client', new Client([
'handler' => $handler_stack,
]));
}
/**
* Asserts the expected error messages were logged.
*
* @param string[] $expected_messages
* The expected error messages.
*
* @internal
*/
protected function assertServiceAdvisoryLoggedErrors(array $expected_messages) : void {
$this
->assertSame($expected_messages, $this->logErrorMessages);
$this->logErrorMessages = [];
}
/**
* {@inheritdoc}
*/
public function log($level, $message, array $context = []) : void {
if (isset($context['@message'])) {
$this->watchdogExceptionMessages[] = $context['@message'];
}
if ($level === RfcLogLevel::ERROR) {
$this->logErrorMessages[] = $message;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified module. | |
ExtensionListTestTrait:: |
protected | function | Gets the path for the specified theme. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 3 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 4 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 2 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
14 |
KernelTestBase:: |
protected | function | Renders a render array. | |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | ||
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 1 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
protected | function | 3 | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
SecurityAdvisoriesFetcherTest:: |
protected | property | History of requests/responses. | |
SecurityAdvisoriesFetcherTest:: |
protected | property | The log error log messages. | |
SecurityAdvisoriesFetcherTest:: |
protected static | property |
Modules to enable. Overrides KernelTestBase:: |
|
SecurityAdvisoriesFetcherTest:: |
protected | property | The log messages from watchdog_exception. | |
SecurityAdvisoriesFetcherTest:: |
protected | function | Asserts the expected error messages were logged. | |
SecurityAdvisoriesFetcherTest:: |
protected | function | Gets the advisories from the 'system.sa_fetcher' service. | |
SecurityAdvisoriesFetcherTest:: |
public | function | ||
SecurityAdvisoriesFetcherTest:: |
public | function | Data provider for testIgnoreAdvisories(). | |
SecurityAdvisoriesFetcherTest:: |
public | function | Data provider for testShowAdvisories(). | |
SecurityAdvisoriesFetcherTest:: |
protected | function | Sets the existing version of the project. | |
SecurityAdvisoriesFetcherTest:: |
protected | function | Sets the feed items to be returned for the test. | |
SecurityAdvisoriesFetcherTest:: |
protected | function | Sets test feed responses. | |
SecurityAdvisoriesFetcherTest:: |
protected | function |
Overrides KernelTestBase:: |
|
SecurityAdvisoriesFetcherTest:: |
public | function | @covers ::doRequest @covers ::getSecurityAdvisories | |
SecurityAdvisoriesFetcherTest:: |
public | function | Tests advisories that should be ignored. | |
SecurityAdvisoriesFetcherTest:: |
public | function | Tests that the stored advisories response is deleted on interval decrease. | |
SecurityAdvisoriesFetcherTest:: |
public | function | Tests that invalid JSON feed responses are not stored. | |
SecurityAdvisoriesFetcherTest:: |
public | function | @covers ::doRequest @covers ::getSecurityAdvisories | |
SecurityAdvisoriesFetcherTest:: |
public | function | Tests contrib advisories that should be displayed. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. |