updated core to 8.6.1 via composer
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -112,7 +112,7 @@ class SimpletestResultsForm extends FormBase {
|
||||
// performed.
|
||||
$results = [];
|
||||
if (is_numeric($test_id) && !$results = $this->getResults($test_id)) {
|
||||
drupal_set_message($this->t('No test results to display.'), 'error');
|
||||
$this->messenger()->addError($this->t('No test results to display.'));
|
||||
return new RedirectResponse($this->url('simpletest.test_form', [], ['absolute' => TRUE]));
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ class SimpletestResultsForm extends FormBase {
|
||||
'Filename',
|
||||
'Line',
|
||||
'Function',
|
||||
['colspan' => 2, 'data' => 'Status']
|
||||
['colspan' => 2, 'data' => 'Status'],
|
||||
];
|
||||
$form['result']['results'] = [];
|
||||
foreach ($test_results as $group => $assertions) {
|
||||
|
||||
@@ -110,6 +110,10 @@ class SimpletestTestForm extends FormBase {
|
||||
];
|
||||
|
||||
$form['tests'] = [
|
||||
'#cache' => [
|
||||
'keys' => ['simpletest_ui_table'],
|
||||
'contexts' => ['test_discovery'],
|
||||
],
|
||||
'#type' => 'table',
|
||||
'#id' => 'simpletest-form-table',
|
||||
'#tableselect' => TRUE,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
@trigger_error(__NAMESPACE__ . '\InstallerTestBase is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\FunctionalTests\Installer\InstallerTestBase, see https://www.drupal.org/node/2988752.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Session\UserSession;
|
||||
@@ -13,6 +15,10 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* Base class for testing the interactive installer.
|
||||
*
|
||||
* @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0.
|
||||
* Use \Drupal\FunctionalTests\Installer\InstallerTestBase. See
|
||||
* https://www.drupal.org/node/2988752
|
||||
*/
|
||||
abstract class InstallerTestBase extends WebTestBase {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Variable;
|
||||
use Drupal\Core\Config\Development\ConfigSchemaChecker;
|
||||
use Drupal\Core\Database\Database;
|
||||
@@ -14,6 +14,7 @@ use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\KeyValueStore\KeyValueMemoryFactory;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\KernelTests\TestServiceProvider;
|
||||
use Symfony\Component\DependencyInjection\Parameter;
|
||||
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@@ -101,7 +102,7 @@ abstract class KernelTestBase extends TestBase {
|
||||
/**
|
||||
* A KeyValueMemoryFactory instance to use when building the container.
|
||||
*
|
||||
* @var \Drupal\Core\KeyValueStore\KeyValueMemoryFactory.
|
||||
* @var \Drupal\Core\KeyValueStore\KeyValueMemoryFactory
|
||||
*/
|
||||
protected $keyValueFactory;
|
||||
|
||||
@@ -198,7 +199,7 @@ EOD;
|
||||
|
||||
// Add this test class as a service provider.
|
||||
// @todo Remove the indirection; implement ServiceProviderInterface instead.
|
||||
$GLOBALS['conf']['container_service_providers']['TestServiceProvider'] = 'Drupal\simpletest\TestServiceProvider';
|
||||
$GLOBALS['conf']['container_service_providers']['TestServiceProvider'] = TestServiceProvider::class;
|
||||
|
||||
// Bootstrap a new kernel.
|
||||
$class_loader = require DRUPAL_ROOT . '/autoload.php';
|
||||
@@ -477,7 +478,6 @@ EOD;
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installs the storage schema for a specific entity type.
|
||||
*
|
||||
@@ -499,7 +499,7 @@ EOD;
|
||||
$all_tables_exist = TRUE;
|
||||
foreach ($tables as $table) {
|
||||
if (!$db_schema->tableExists($table)) {
|
||||
$this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', [
|
||||
$this->fail(new FormattableMarkup('Installed entity type table for the %entity_type entity type: %table', [
|
||||
'%entity_type' => $entity_type_id,
|
||||
'%table' => $table,
|
||||
]));
|
||||
@@ -507,7 +507,7 @@ EOD;
|
||||
}
|
||||
}
|
||||
if ($all_tables_exist) {
|
||||
$this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', [
|
||||
$this->pass(new FormattableMarkup('Installed entity type tables for the %entity_type entity type: %tables', [
|
||||
'%entity_type' => $entity_type_id,
|
||||
'%tables' => '{' . implode('}, {', $tables) . '}',
|
||||
]));
|
||||
|
||||
@@ -2,111 +2,15 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Core\Routing\PreloadableRouteProviderInterface;
|
||||
use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Drupal\KernelTests\RouteProvider as CoreRouteProvider;
|
||||
|
||||
/**
|
||||
* Rebuilds the router when the provider is instantiated.
|
||||
*
|
||||
* @todo Move this outside of simpletest namespace to the Drupal\Tests, see
|
||||
* https://www.drupal.org/node/2672762
|
||||
* @deprecated in 8.6.0 for removal before 9.0.0. Use
|
||||
* Drupal\KernelTests\RouteProvider instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2943146
|
||||
*/
|
||||
class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
|
||||
|
||||
use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* Loads the real route provider from the container and rebuilds the router.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
|
||||
* The route provider.
|
||||
*/
|
||||
protected function lazyLoadItself() {
|
||||
if (!isset($this->service)) {
|
||||
$container = \Drupal::getContainer();
|
||||
$this->service = $container->get('simpletest.router.route_provider');
|
||||
$container->get('router.builder')->rebuild();
|
||||
}
|
||||
|
||||
return $this->service;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteCollectionForRequest(Request $request) {
|
||||
return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteByName($name) {
|
||||
return $this->lazyLoadItself()->getRouteByName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function preLoadRoutes($names) {
|
||||
return $this->lazyLoadItself()->preLoadRoutes($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByNames($names) {
|
||||
return $this->lazyLoadItself()->getRoutesByNames($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCandidateOutlines(array $parts) {
|
||||
return $this->lazyLoadItself()->getCandidateOutlines($parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesByPattern($pattern) {
|
||||
return $this->lazyLoadItself()->getRoutesByPattern($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function routeProviderRouteCompare(array $a, array $b) {
|
||||
return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAllRoutes() {
|
||||
return $this->lazyLoadItself()->getAllRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset() {
|
||||
return $this->lazyLoadItself()->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesPaged($offset, $length = NULL) {
|
||||
return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRoutesCount() {
|
||||
return $this->lazyLoadItself()->getRoutesCount();
|
||||
}
|
||||
|
||||
class RouteProvider extends CoreRouteProvider {
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Drupal\simpletest;
|
||||
use Drupal\Component\Assertion\Handle;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
@@ -15,7 +15,6 @@ use Drupal\Core\Utility\Error;
|
||||
use Drupal\Tests\AssertHelperTrait as BaseAssertHelperTrait;
|
||||
use Drupal\Tests\ConfigTestTrait;
|
||||
use Drupal\Tests\RandomGeneratorTrait;
|
||||
use Drupal\Tests\SessionTestTrait;
|
||||
use Drupal\Tests\Traits\Core\GeneratePermutationsTrait;
|
||||
|
||||
/**
|
||||
@@ -27,7 +26,6 @@ abstract class TestBase {
|
||||
|
||||
use BaseAssertHelperTrait;
|
||||
use TestSetupTrait;
|
||||
use SessionTestTrait;
|
||||
use RandomGeneratorTrait;
|
||||
use GeneratePermutationsTrait;
|
||||
// For backwards compatibility switch the visbility of the methods to public.
|
||||
@@ -248,6 +246,20 @@ abstract class TestBase {
|
||||
$this->testId = $test_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fail the test if it belongs to a PHPUnit-based framework.
|
||||
*
|
||||
* This would probably be caused by automated test conversions such as those
|
||||
* in https://www.drupal.org/project/drupal/issues/2770921.
|
||||
*/
|
||||
public function checkTestHierarchyMismatch() {
|
||||
// We can use getPhpunitTestSuite() because it uses a regex on the class'
|
||||
// namespace to deduce the PHPUnit test suite.
|
||||
if (TestDiscovery::getPhpunitTestSuite(get_class($this)) !== FALSE) {
|
||||
$this->fail(get_class($this) . ' incorrectly subclasses ' . __CLASS__ . ', it should probably extend \Drupal\Tests\BrowserTestBase instead.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs setup tasks before each individual test method is run.
|
||||
*/
|
||||
@@ -291,7 +303,7 @@ abstract class TestBase {
|
||||
* TRUE is a synonym for 'pass', FALSE for 'fail'.
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -449,7 +461,7 @@ abstract class TestBase {
|
||||
* The value on which the assertion is to be done.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -462,7 +474,7 @@ abstract class TestBase {
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertTrue($value, $message = '', $group = 'Other') {
|
||||
return $this->assert((bool) $value, $message ? $message : SafeMarkup::format('Value @value is TRUE.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
return $this->assert((bool) $value, $message ? $message : new FormattableMarkup('Value @value is TRUE.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -474,7 +486,7 @@ abstract class TestBase {
|
||||
* The value on which the assertion is to be done.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -487,7 +499,7 @@ abstract class TestBase {
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertFalse($value, $message = '', $group = 'Other') {
|
||||
return $this->assert(!$value, $message ? $message : SafeMarkup::format('Value @value is FALSE.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
return $this->assert(!$value, $message ? $message : new FormattableMarkup('Value @value is FALSE.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -497,7 +509,7 @@ abstract class TestBase {
|
||||
* The value on which the assertion is to be done.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -510,7 +522,7 @@ abstract class TestBase {
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertNull($value, $message = '', $group = 'Other') {
|
||||
return $this->assert(!isset($value), $message ? $message : SafeMarkup::format('Value @value is NULL.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
return $this->assert(!isset($value), $message ? $message : new FormattableMarkup('Value @value is NULL.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,7 +532,7 @@ abstract class TestBase {
|
||||
* The value on which the assertion is to be done.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -533,7 +545,7 @@ abstract class TestBase {
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertNotNull($value, $message = '', $group = 'Other') {
|
||||
return $this->assert(isset($value), $message ? $message : SafeMarkup::format('Value @value is not NULL.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
return $this->assert(isset($value), $message ? $message : new FormattableMarkup('Value @value is not NULL.', ['@value' => var_export($value, TRUE)]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,7 +557,7 @@ abstract class TestBase {
|
||||
* The second value to check.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -565,7 +577,7 @@ abstract class TestBase {
|
||||
$second = $this->castSafeStrings($second);
|
||||
$is_equal = $first == $second;
|
||||
if (!$is_equal || !$message) {
|
||||
$default_message = SafeMarkup::format('Value @first is equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$default_message = new FormattableMarkup('Value @first is equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
|
||||
}
|
||||
return $this->assert($is_equal, $message, $group);
|
||||
@@ -580,7 +592,7 @@ abstract class TestBase {
|
||||
* The second value to check.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -600,7 +612,7 @@ abstract class TestBase {
|
||||
$second = $this->castSafeStrings($second);
|
||||
$not_equal = $first != $second;
|
||||
if (!$not_equal || !$message) {
|
||||
$default_message = SafeMarkup::format('Value @first is not equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$default_message = new FormattableMarkup('Value @first is not equal to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
|
||||
}
|
||||
return $this->assert($not_equal, $message, $group);
|
||||
@@ -615,7 +627,7 @@ abstract class TestBase {
|
||||
* The second value to check.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -630,7 +642,7 @@ abstract class TestBase {
|
||||
protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
|
||||
$is_identical = $first === $second;
|
||||
if (!$is_identical || !$message) {
|
||||
$default_message = SafeMarkup::format('Value @first is identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$default_message = new FormattableMarkup('Value @first is identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
|
||||
}
|
||||
return $this->assert($is_identical, $message, $group);
|
||||
@@ -645,7 +657,7 @@ abstract class TestBase {
|
||||
* The second value to check.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -660,7 +672,7 @@ abstract class TestBase {
|
||||
protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
|
||||
$not_identical = $first !== $second;
|
||||
if (!$not_identical || !$message) {
|
||||
$default_message = SafeMarkup::format('Value @first is not identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$default_message = new FormattableMarkup('Value @first is not identical to value @second.', ['@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE)]);
|
||||
$message = $message ? $message . PHP_EOL . $default_message : $default_message;
|
||||
}
|
||||
return $this->assert($not_identical, $message, $group);
|
||||
@@ -675,7 +687,7 @@ abstract class TestBase {
|
||||
* The second object to check.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -688,7 +700,7 @@ abstract class TestBase {
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
|
||||
$message = $message ?: SafeMarkup::format('@object1 is identical to @object2', [
|
||||
$message = $message ?: new FormattableMarkup('@object1 is identical to @object2', [
|
||||
'@object1' => var_export($object1, TRUE),
|
||||
'@object2' => var_export($object2, TRUE),
|
||||
]);
|
||||
@@ -755,7 +767,7 @@ abstract class TestBase {
|
||||
*
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -776,7 +788,7 @@ abstract class TestBase {
|
||||
*
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -797,7 +809,7 @@ abstract class TestBase {
|
||||
*
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -864,6 +876,7 @@ abstract class TestBase {
|
||||
* methods during debugging.
|
||||
*/
|
||||
public function run(array $methods = []) {
|
||||
$this->checkTestHierarchyMismatch();
|
||||
$class = get_class($this);
|
||||
|
||||
if ($missing_requirements = $this->checkRequirements()) {
|
||||
@@ -985,7 +998,7 @@ abstract class TestBase {
|
||||
|
||||
TestServiceProvider::$currentTest = NULL;
|
||||
// Clear out the error messages and restore error handler.
|
||||
drupal_get_messages();
|
||||
\Drupal::messenger()->deleteAll();
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
@@ -1326,7 +1339,7 @@ abstract class TestBase {
|
||||
]);
|
||||
$decoded_exception = Error::decodeException($exception);
|
||||
unset($decoded_exception['backtrace']);
|
||||
$message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + [
|
||||
$message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $decoded_exception + [
|
||||
'@backtrace' => Error::formatBacktrace($verbose_backtrace),
|
||||
]);
|
||||
$this->error($message, 'Uncaught exception', Error::getLastCaller($backtrace));
|
||||
|
||||
@@ -6,7 +6,6 @@ use Doctrine\Common\Annotations\SimpleAnnotationReader;
|
||||
use Doctrine\Common\Reflection\StaticReflectionParser;
|
||||
use Drupal\Component\Annotation\Reflection\MockFileFinder;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\simpletest\Exception\MissingGroupException;
|
||||
@@ -25,11 +24,11 @@ class TestDiscovery {
|
||||
protected $classLoader;
|
||||
|
||||
/**
|
||||
* Backend for caching discovery results.
|
||||
* Statically cached list of test classes.
|
||||
*
|
||||
* @var \Drupal\Core\Cache\CacheBackendInterface
|
||||
* @var array
|
||||
*/
|
||||
protected $cacheBackend;
|
||||
protected $testClasses;
|
||||
|
||||
/**
|
||||
* Cached map of all test namespaces to respective directories.
|
||||
@@ -70,14 +69,11 @@ class TestDiscovery {
|
||||
* \Symfony\Component\ClassLoader\ApcClassLoader.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
|
||||
* (optional) Backend for caching discovery results.
|
||||
*/
|
||||
public function __construct($root, $class_loader, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend = NULL) {
|
||||
public function __construct($root, $class_loader, ModuleHandlerInterface $module_handler) {
|
||||
$this->root = $root;
|
||||
$this->classLoader = $class_loader;
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->cacheBackend = $cache_backend;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,9 +155,9 @@ class TestDiscovery {
|
||||
$reader = new SimpleAnnotationReader();
|
||||
$reader->addNamespace('Drupal\\simpletest\\Annotation');
|
||||
|
||||
if (!isset($extension)) {
|
||||
if ($this->cacheBackend && $cache = $this->cacheBackend->get('simpletest:discovery:classes')) {
|
||||
return $cache->data;
|
||||
if (!isset($extension) && empty($types)) {
|
||||
if (!empty($this->testClasses)) {
|
||||
return $this->testClasses;
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
@@ -213,12 +209,10 @@ class TestDiscovery {
|
||||
}
|
||||
|
||||
// Allow modules extending core tests to disable originals.
|
||||
$this->moduleHandler->alter('simpletest', $list);
|
||||
$this->moduleHandler->alterDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See: https://www.drupal.org/node/2939892', 'simpletest', $list);
|
||||
|
||||
if (!isset($extension)) {
|
||||
if ($this->cacheBackend) {
|
||||
$this->cacheBackend->set('simpletest:discovery:classes', $list);
|
||||
}
|
||||
if (!isset($extension) && empty($types)) {
|
||||
$this->testClasses = $list;
|
||||
}
|
||||
|
||||
if ($types) {
|
||||
@@ -288,13 +282,21 @@ class TestDiscovery {
|
||||
$flags |= \FilesystemIterator::SKIP_DOTS;
|
||||
$flags |= \FilesystemIterator::FOLLOW_SYMLINKS;
|
||||
$flags |= \FilesystemIterator::CURRENT_AS_SELF;
|
||||
$flags |= \FilesystemIterator::KEY_AS_FILENAME;
|
||||
|
||||
$iterator = new \RecursiveDirectoryIterator($path, $flags);
|
||||
$filter = new \RecursiveCallbackFilterIterator($iterator, function ($current, $key, $iterator) {
|
||||
$filter = new \RecursiveCallbackFilterIterator($iterator, function ($current, $file_name, $iterator) {
|
||||
if ($iterator->hasChildren()) {
|
||||
return TRUE;
|
||||
}
|
||||
return $current->isFile() && $current->getExtension() === 'php';
|
||||
// We don't want to discover abstract TestBase classes, traits or
|
||||
// interfaces. They can be deprecated and will call @trigger_error()
|
||||
// during discovery.
|
||||
return
|
||||
substr($file_name, -4) === '.php' &&
|
||||
substr($file_name, -12) !== 'TestBase.php' &&
|
||||
substr($file_name, -9) !== 'Trait.php' &&
|
||||
substr($file_name, -13) !== 'Interface.php';
|
||||
});
|
||||
$files = new \RecursiveIteratorIterator($filter);
|
||||
$classes = [];
|
||||
@@ -331,7 +333,7 @@ class TestDiscovery {
|
||||
* If the class does not have a @group annotation.
|
||||
*/
|
||||
public static function getTestInfo($classname, $doc_comment = NULL) {
|
||||
if (!$doc_comment) {
|
||||
if ($doc_comment === NULL) {
|
||||
$reflection = new \ReflectionClass($classname);
|
||||
$doc_comment = $reflection->getDocComment();
|
||||
}
|
||||
|
||||
@@ -2,54 +2,16 @@
|
||||
|
||||
namespace Drupal\simpletest;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
|
||||
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Drupal\KernelTests\TestServiceProvider as CoreTestServiceProvider;
|
||||
|
||||
class TestServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\simpletest\TestBase;
|
||||
*/
|
||||
public static $currentTest;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(ContainerBuilder $container) {
|
||||
if (static::$currentTest && method_exists(static::$currentTest, 'containerBuild')) {
|
||||
static::$currentTest->containerBuild($container);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function alter(ContainerBuilder $container) {
|
||||
if (static::$currentTest instanceof KernelTestBase) {
|
||||
static::addRouteProvider($container);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the on demand rebuild route provider service.
|
||||
*
|
||||
* @param \Drupal\Core\DependencyInjection\ContainerBuilder $container
|
||||
*/
|
||||
public static function addRouteProvider(ContainerBuilder $container) {
|
||||
foreach (['router.route_provider' => 'RouteProvider'] as $original_id => $class) {
|
||||
// While $container->get() does a recursive resolve, getDefinition() does
|
||||
// not, so do it ourselves.
|
||||
// @todo Make the code more readable in
|
||||
// https://www.drupal.org/node/2911498.
|
||||
for ($id = $original_id; $container->hasAlias($id); $id = (string) $container->getAlias($id)) {
|
||||
}
|
||||
$definition = $container->getDefinition($id);
|
||||
$definition->clearTag('needs_destruction');
|
||||
$container->setDefinition("simpletest.$original_id", $definition);
|
||||
$container->setDefinition($id, new Definition('Drupal\simpletest\\' . $class));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Provides special routing services for tests.
|
||||
*
|
||||
* @deprecated in 8.6.0 for removal before Drupal 9.0.0. Use
|
||||
* Drupal\KernelTests\TestServiceProvider instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2943146
|
||||
*/
|
||||
class TestServiceProvider extends CoreTestServiceProvider {
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
|
||||
* - but still install the drupal_system_listing_compatible_test.module
|
||||
* contained in the Testing profile.
|
||||
*
|
||||
* @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
|
||||
* @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
@@ -53,12 +53,18 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
|
||||
*/
|
||||
public function testInstallationProfileTests() {
|
||||
$this->drupalGet('admin/config/development/testing');
|
||||
$this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
|
||||
$this->assertText('Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest');
|
||||
$edit = [
|
||||
'tests[Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest]' => TRUE,
|
||||
'tests[Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest]' => TRUE,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Run tests'));
|
||||
$this->assertText('SystemListingCompatibleTest test executed.');
|
||||
|
||||
// Verifies that tests in installation profile modules are passed.
|
||||
$element = $this->xpath('//tr[contains(@class, :class)]/td[contains(text(), :value)]', [
|
||||
':class' => 'simpletest-pass',
|
||||
':value' => 'Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCrossProfileCompatibleTest',
|
||||
]);
|
||||
$this->assertTrue(!empty($element));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ EOS;
|
||||
$this->assertIdentical(\Drupal::moduleHandler()->getImplementations('entity_type_alter'), ['entity_test']);
|
||||
|
||||
// Verify that no modules have been installed.
|
||||
$this->assertFalse(db_table_exists($table), "'$table' database table not found.");
|
||||
$this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found.");
|
||||
|
||||
// Verify that the settings.testing.php got taken into account.
|
||||
$this->assertTrue(function_exists('simpletest_test_stub_settings_function'));
|
||||
@@ -114,7 +114,7 @@ EOS;
|
||||
$list = \Drupal::moduleHandler()->getImplementations('hook_info');
|
||||
$this->assertFalse(in_array($module, $list), "{$module}_hook_info() in \Drupal::moduleHandler()->getImplementations() not found.");
|
||||
|
||||
$this->assertFalse(db_table_exists($table), "'$table' database table not found.");
|
||||
$this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found.");
|
||||
|
||||
// Install the module.
|
||||
\Drupal::service('module_installer')->install([$module]);
|
||||
@@ -126,7 +126,7 @@ EOS;
|
||||
$list = \Drupal::moduleHandler()->getImplementations('hook_info');
|
||||
$this->assertTrue(in_array($module, $list), "{$module}_hook_info() in \Drupal::moduleHandler()->getImplementations() found.");
|
||||
|
||||
$this->assertTrue(db_table_exists($table), "'$table' database table found.");
|
||||
$this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found.");
|
||||
$schema = drupal_get_module_schema($module, $table);
|
||||
$this->assertTrue($schema, "'$table' table schema found.");
|
||||
}
|
||||
@@ -156,7 +156,7 @@ EOS;
|
||||
$table = 'entity_test_example';
|
||||
// Verify that we can install a table from the module schema.
|
||||
$this->installSchema($module, $table);
|
||||
$this->assertTrue(db_table_exists($table), "'$table' database table found.");
|
||||
$this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found.");
|
||||
|
||||
// Verify that the schema is known to Schema API.
|
||||
$schema = drupal_get_module_schema($module, $table);
|
||||
@@ -171,7 +171,7 @@ EOS;
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Exception for non-retrievable schema found.');
|
||||
}
|
||||
$this->assertFalse(db_table_exists($table), "'$table' database table not found.");
|
||||
$this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found.");
|
||||
$schema = drupal_get_module_schema($module, $table);
|
||||
$this->assertFalse($schema, "'$table' table schema not found.");
|
||||
|
||||
@@ -185,14 +185,14 @@ EOS;
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Exception for non-retrievable schema found.');
|
||||
}
|
||||
$this->assertFalse(db_table_exists($table), "'$table' database table not found.");
|
||||
$this->assertFalse(Database::getConnection()->schema()->tableExists($table), "'$table' database table not found.");
|
||||
$schema = drupal_get_module_schema($module, $table);
|
||||
$this->assertTrue($schema, "'$table' table schema found.");
|
||||
|
||||
// Verify that the same table can be installed after enabling the module.
|
||||
$this->enableModules([$module]);
|
||||
$this->installSchema($module, $table);
|
||||
$this->assertTrue(db_table_exists($table), "'$table' database table found.");
|
||||
$this->assertTrue(Database::getConnection()->schema()->tableExists($table), "'$table' database table found.");
|
||||
$schema = drupal_get_module_schema($module, $table);
|
||||
$this->assertTrue($schema, "'$table' table schema found.");
|
||||
}
|
||||
@@ -206,7 +206,7 @@ EOS;
|
||||
$this->enableModules(['user']);
|
||||
// Verity that the entity schema is created properly.
|
||||
$this->installEntitySchema($entity);
|
||||
$this->assertTrue(db_table_exists($entity), "'$entity' database table found.");
|
||||
$this->assertTrue(Database::getConnection()->schema()->tableExists($entity), "'$entity' database table found.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +278,7 @@ EOS;
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => 'test_field',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'test_field'
|
||||
'type' => 'test_field',
|
||||
]);
|
||||
$field_storage->save();
|
||||
FieldConfig::create([
|
||||
@@ -354,7 +354,7 @@ EOS;
|
||||
$info = Database::getConnectionInfo();
|
||||
$connection->query('ATTACH DATABASE :database AS :prefix', [
|
||||
':database' => $info['default']['database'] . '-' . $this->databasePrefix,
|
||||
':prefix' => $this->databasePrefix
|
||||
':prefix' => $this->databasePrefix,
|
||||
]);
|
||||
|
||||
$result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [
|
||||
|
||||
@@ -30,7 +30,7 @@ class MissingCheckedRequirementsTest extends WebTestBase {
|
||||
protected function checkRequirements() {
|
||||
if ($this->isInChildSite()) {
|
||||
return [
|
||||
'Test is not allowed to run.'
|
||||
'Test is not allowed to run.',
|
||||
];
|
||||
}
|
||||
return parent::checkRequirements();
|
||||
|
||||
@@ -59,7 +59,7 @@ class SimpleTestBrowserTest extends WebTestBase {
|
||||
$this->maximumRedirects = 1;
|
||||
$edit = [
|
||||
'name' => $user->getUsername(),
|
||||
'pass' => $user->pass_raw
|
||||
'pass' => $user->pass_raw,
|
||||
];
|
||||
$this->drupalPostForm('user/login', $edit, t('Log in'), [
|
||||
'query' => ['destination' => 'user/logout'],
|
||||
|
||||
@@ -7,7 +7,7 @@ use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
|
||||
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
@@ -19,11 +19,11 @@ use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
use Drupal\Tests\EntityViewTrait;
|
||||
use Drupal\Tests\block\Traits\BlockCreationTrait as BaseBlockCreationTrait;
|
||||
use Drupal\Tests\Listeners\DeprecationListenerTrait;
|
||||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\Tests\node\Traits\ContentTypeCreationTrait as BaseContentTypeCreationTrait;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait as BaseNodeCreationTrait;
|
||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
use Drupal\Tests\TestFileCreationTrait;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait;
|
||||
use Drupal\Tests\user\Traits\UserCreationTrait as BaseUserCreationTrait;
|
||||
use Drupal\Tests\XdebugRequestTrait;
|
||||
use Zend\Diactoros\Uri;
|
||||
|
||||
@@ -44,18 +44,18 @@ abstract class WebTestBase extends TestBase {
|
||||
use BaseBlockCreationTrait {
|
||||
placeBlock as drupalPlaceBlock;
|
||||
}
|
||||
use ContentTypeCreationTrait {
|
||||
use BaseContentTypeCreationTrait {
|
||||
createContentType as drupalCreateContentType;
|
||||
}
|
||||
use CronRunTrait;
|
||||
use AssertMailTrait {
|
||||
getMails as drupalGetMails;
|
||||
}
|
||||
use NodeCreationTrait {
|
||||
use BaseNodeCreationTrait {
|
||||
getNodeByTitle as drupalGetNodeByTitle;
|
||||
createNode as drupalCreateNode;
|
||||
}
|
||||
use UserCreationTrait {
|
||||
use BaseUserCreationTrait {
|
||||
createUser as drupalCreateUser;
|
||||
createRole as drupalCreateRole;
|
||||
createAdminRole as drupalCreateAdminRole;
|
||||
@@ -286,7 +286,7 @@ abstract class WebTestBase extends TestBase {
|
||||
|
||||
$edit = [
|
||||
'name' => $account->getUsername(),
|
||||
'pass' => $account->pass_raw
|
||||
'pass' => $account->pass_raw,
|
||||
];
|
||||
$this->drupalPostForm('user/login', $edit, t('Log in'));
|
||||
|
||||
@@ -660,9 +660,9 @@ abstract class WebTestBase extends TestBase {
|
||||
'@method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
|
||||
'@url' => isset($original_url) ? $original_url : $url,
|
||||
'@status' => $status,
|
||||
'@length' => format_size(strlen($this->getRawContent()))
|
||||
'@length' => format_size(strlen($this->getRawContent())),
|
||||
];
|
||||
$message = SafeMarkup::format('@method @url returned @status (@length).', $message_vars);
|
||||
$message = new FormattableMarkup('@method @url returned @status (@length).', $message_vars);
|
||||
$this->assertTrue($this->getRawContent() !== FALSE, $message, 'Browser');
|
||||
return $this->getRawContent();
|
||||
}
|
||||
@@ -698,7 +698,8 @@ abstract class WebTestBase extends TestBase {
|
||||
if ($parameters[1] === 'User deprecated function') {
|
||||
if (getenv('SYMFONY_DEPRECATIONS_HELPER') !== 'disabled') {
|
||||
$message = (string) $parameters[0];
|
||||
if (!in_array($message, DeprecationListenerTrait::getSkippedDeprecations())) {
|
||||
$test_info = TestDiscovery::getTestInfo(get_called_class());
|
||||
if ($test_info['group'] !== 'legacy' && !in_array($message, DeprecationListenerTrait::getSkippedDeprecations())) {
|
||||
call_user_func_array([&$this, 'error'], $parameters);
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1054,7 @@ abstract class WebTestBase extends TestBase {
|
||||
}
|
||||
// We have not found a form which contained all fields of $edit.
|
||||
foreach ($edit as $name => $value) {
|
||||
$this->fail(SafeMarkup::format('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
|
||||
$this->fail(new FormattableMarkup('Failed to set field @name to @value', ['@name' => $name, '@value' => $value]));
|
||||
}
|
||||
if (!$ajax && isset($submit)) {
|
||||
$this->assertTrue($submit_matches, format_string('Found the @submit button', ['@submit' => $submit]));
|
||||
@@ -1725,10 +1726,10 @@ abstract class WebTestBase extends TestBase {
|
||||
$urls = $this->xpath($pattern, [':label' => $label]);
|
||||
if (isset($urls[$index])) {
|
||||
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
|
||||
$this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', ['%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
|
||||
$this->pass(new FormattableMarkup('Clicked link %label (@url_target) from @url_before', ['%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
|
||||
return $this->drupalGet($url_target);
|
||||
}
|
||||
$this->fail(SafeMarkup::format('Link %label does not exist on @url_before', ['%label' => $label, '@url_before' => $url_before]), 'Browser');
|
||||
$this->fail(new FormattableMarkup('Link %label does not exist on @url_before', ['%label' => $label, '@url_before' => $url_before]), 'Browser');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1904,7 +1905,7 @@ abstract class WebTestBase extends TestBase {
|
||||
* (optional) Any additional options to pass for $path to the url generator.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -1931,7 +1932,7 @@ abstract class WebTestBase extends TestBase {
|
||||
}
|
||||
$url = $url_obj->setAbsolute()->toString();
|
||||
if (!$message) {
|
||||
$message = SafeMarkup::format('Expected @url matches current URL (@current_url).', [
|
||||
$message = new FormattableMarkup('Expected @url matches current URL (@current_url).', [
|
||||
'@url' => var_export($url, TRUE),
|
||||
'@current_url' => $this->getUrl(),
|
||||
]);
|
||||
@@ -1951,7 +1952,7 @@ abstract class WebTestBase extends TestBase {
|
||||
* of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -1966,7 +1967,7 @@ abstract class WebTestBase extends TestBase {
|
||||
protected function assertResponse($code, $message = '', $group = 'Browser') {
|
||||
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
||||
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
|
||||
return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
|
||||
return $this->assertTrue($match, $message ? $message : new FormattableMarkup('HTTP response expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1977,7 +1978,7 @@ abstract class WebTestBase extends TestBase {
|
||||
* of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* messages: use \Drupal\Component\Render\FormattableMarkup to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
@@ -1992,7 +1993,7 @@ abstract class WebTestBase extends TestBase {
|
||||
protected function assertNoResponse($code, $message = '', $group = 'Browser') {
|
||||
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
||||
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
|
||||
return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
|
||||
return $this->assertFalse($match, $message ? $message : new FormattableMarkup('HTTP response not expected @code, actual @curl_code', ['@code' => $code, '@curl_code' => $curl_code]), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user