Commit 484d80db authored by catch's avatar catch

Issue #3172438 by mondrake, kishor_kolekar, longwave, NitinLama, mikelutz,...

Issue #3172438 by mondrake, kishor_kolekar, longwave, NitinLama, mikelutz, jungle: Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead
parent c79ad7c7
......@@ -19,9 +19,9 @@ class LayoutBuilderElementTest extends KernelTestBase {
/**
* @group legacy
* @expectedDeprecation The event_dispatcher service should be passed to LayoutBuilder::__construct() instead of the layout_builder.tempstore_repository service since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3152690
*/
public function testConstructorTempStoreDeprecation() {
$this->expectDeprecation('The event_dispatcher service should be passed to LayoutBuilder::__construct() instead of the layout_builder.tempstore_repository service since 9.1.0. This will be required in Drupal 10.0.0. See https://www.drupal.org/node/3152690');
$layout_temp_storage = $this->prophesize(LayoutTempstoreRepositoryInterface::class);
$element = new LayoutBuilder(
[],
......@@ -34,9 +34,9 @@ public function testConstructorTempStoreDeprecation() {
/**
* @group legacy
* @expectedDeprecation Calling LayoutBuilder::__construct() with the $messenger argument is deprecated in drupal:9.1.0 and will be removed in drupal:10.0.0. See https://www.drupal.org/node/3152690
*/
public function testConstructorMessengerDeprecation() {
$this->expectDeprecation('Calling LayoutBuilder::__construct() with the $messenger argument is deprecated in drupal:9.1.0 and will be removed in drupal:10.0.0. See https://www.drupal.org/node/3152690');
$event_dispatcher = $this->prophesize(EventDispatcherInterface::class);
$messenger = $this->prophesize(MessengerInterface::class);
......
......@@ -47,9 +47,10 @@ protected function setUp(): void {
/**
* @covers ::defineValueProcessPipeline
* @expectedDeprecation The Drupal\migrate_drupal\Plugin\migrate\field\NodeReference is deprecated in drupal:9.1.0 and will be removed from drupal:10.0.0. Instead use \Drupal\migrate_drupal\Plugin\migrate\field\d6\NodeReference. See https://www.drupal.org/node/3159537.
* @runInSeparateProcess
*/
public function testDefineValueProcessPipeline() {
$this->expectDeprecation('The Drupal\migrate_drupal\Plugin\migrate\field\NodeReference is deprecated in drupal:9.1.0 and will be removed from drupal:10.0.0. Instead use \Drupal\migrate_drupal\Plugin\migrate\field\d6\NodeReference. See https://www.drupal.org/node/3159537.');
$this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []);
$expected = [
......
......@@ -30,32 +30,24 @@ protected function setUp(): void {
$this->installConfig(['search']);
}
/**
* @expectedDeprecation search_index_split() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\search\SearchTextProcessorInterface::process() instead. See https://www.drupal.org/node/3078162
*/
public function testDeprecatedIndexSplit() {
$this->expectDeprecation('search_index_split() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\search\SearchTextProcessorInterface::process() instead. See https://www.drupal.org/node/3078162');
$this->assertEquals(["two", "words"], search_index_split("two words"));
}
/**
* @expectedDeprecation search_simplify() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\search\SearchTextProcessorInterface::analyze() instead. See https://www.drupal.org/node/3078162
*/
public function testDeprecatedSimplify() {
$this->expectDeprecation('search_simplify() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\search\SearchTextProcessorInterface::analyze() instead. See https://www.drupal.org/node/3078162');
// cSpell:disable-next-line
$this->assertEquals("vogel", search_simplify("Vögel"));
}
/**
* @expectedDeprecation search_expand_cjk() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use a custom implementation of SearchTextProcessorInterface instead. instead. See https://www.drupal.org/node/3078162
*/
public function testExpandCjk() {
$this->expectDeprecation('search_expand_cjk() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use a custom implementation of SearchTextProcessorInterface instead. instead. See https://www.drupal.org/node/3078162');
$this->assertEquals(" 이런 ", search_expand_cjk(["이런"]));
}
/**
* @expectedDeprecation search_invoke_preprocess() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use a custom implementation of SearchTextProcessorInterface instead. See https://www.drupal.org/node/3078162
*/
public function testInvokePreprocess() {
$this->expectDeprecation('search_invoke_preprocess() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use a custom implementation of SearchTextProcessorInterface instead. See https://www.drupal.org/node/3078162');
$text = $this->randomString();
search_invoke_preprocess($text);
$this->assertIsString($text);
......
......@@ -31,9 +31,9 @@ class CsrfRequestHeaderTest extends BrowserTestBase {
* uses the deprecated _access_rest_csrf.
*
* @group legacy
* @expectedDeprecation Route requirement _access_rest_csrf is deprecated in drupal:8.2.0 and is removed in drupal:10.0.0. Use _csrf_request_header_token instead. See https://www.drupal.org/node/2772399
*/
public function testRouteAccess() {
$this->expectDeprecation('Route requirement _access_rest_csrf is deprecated in drupal:8.2.0 and is removed in drupal:10.0.0. Use _csrf_request_header_token instead. See https://www.drupal.org/node/2772399');
$client = $this->getHttpClient();
$csrf_token_paths = ['deprecated/session/token', 'session/token'];
// Test using the both the current path and a test path that returns
......
......@@ -29,10 +29,9 @@ protected function setUp(): void {
* Tests the stylesheets-remove key.
*
* @throws \Behat\Mink\Exception\ExpectationException
*
* @expectedDeprecation The theme info key stylesheets-remove implemented by theme test_legacy_stylesheets_remove is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/2497313
*/
public function testStyleSheetsRemove() {
$this->expectDeprecation('The theme info key stylesheets-remove implemented by theme test_legacy_stylesheets_remove is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/2497313');
\Drupal::configFactory()->getEditable('system.theme')->set('default', 'classy')->save();
$this->drupalGet('<front>');
$this->assertSession()->responseContains('css/components/action-links.css?');
......
......@@ -43,13 +43,12 @@ protected function setUp(): void {
* Tests password widget theme functions and its deprecations.
*
* @group legacy
*
* @expectedDeprecation Javascript Deprecation: Returning <span> without data-drupal-selector="password-match-status-text" attribute is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3152101
* @expectedDeprecation Javascript Deprecation: The js-password-strength__indicator class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__indicator with a data-drupal-selector="password-strength-indicator" attribute. See https://www.drupal.org/node/3152101
* @expectedDeprecation Javascript Deprecation: The js-password-strength__text class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__text with a data-drupal-selector="password-strength-text" attribute. See https://www.drupal.org/node/3152101
* @expectedDeprecation Javascript Deprecation: The message property is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The markup should be constructed using messageTips property and Drupal.theme.passwordSuggestions. See https://www.drupal.org/node/3130352
*/
public function testPasswordConfirmWidgetJsComponents() {
$this->expectDeprecation('Javascript Deprecation: Returning <span> without data-drupal-selector="password-match-status-text" attribute is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3152101');
$this->expectDeprecation('Javascript Deprecation: The js-password-strength__indicator class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__indicator with a data-drupal-selector="password-strength-indicator" attribute. See https://www.drupal.org/node/3152101');
$this->expectDeprecation('Javascript Deprecation: The js-password-strength__text class is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Replace js-password-strength__text with a data-drupal-selector="password-strength-text" attribute. See https://www.drupal.org/node/3152101');
$this->expectDeprecation('Javascript Deprecation: The message property is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The markup should be constructed using messageTips property and Drupal.theme.passwordSuggestions. See https://www.drupal.org/node/3130352');
$assert_session = $this->assertSession();
$this->drupalGet($this->testUser->toUrl('edit-form'));
......
......@@ -25,9 +25,9 @@ class UserAuthenticationControllerTest extends KernelTestBase {
/**
* @group legacy
* @expectedDeprecation Passing the flood service to Drupal\user\Controller\UserAuthenticationController::__construct is deprecated in drupal:9.1.0 and is replaced by user.flood_control in drupal:10.0.0. See https://www.drupal.org/node/3067148
*/
public function testConstructorDeprecations() {
$this->expectDeprecation('Passing the flood service to Drupal\user\Controller\UserAuthenticationController::__construct is deprecated in drupal:9.1.0 and is replaced by user.flood_control in drupal:10.0.0. See https://www.drupal.org/node/3067148');
$flood = $this->prophesize(FloodInterface::class);
$user_storage = $this->prophesize(UserStorageInterface::class);
$csrf_token = $this->prophesize(CsrfTokenGenerator::class);
......
......@@ -22,9 +22,9 @@ class UserLoginFormTest extends KernelTestBase {
/**
* @group legacy
* @expectedDeprecation Passing the flood service to Drupal\user\Form\UserLoginForm::__construct is deprecated in drupal:9.1.0 and is replaced by user.flood_control in drupal:10.0.0. See https://www.drupal.org/node/3067148
*/
public function testConstructorDeprecations() {
$this->expectDeprecation('Passing the flood service to Drupal\user\Form\UserLoginForm::__construct is deprecated in drupal:9.1.0 and is replaced by user.flood_control in drupal:10.0.0. See https://www.drupal.org/node/3067148');
$flood = $this->prophesize(FloodInterface::class);
$user_storage = $this->prophesize(UserStorageInterface::class);
$user_auth = $this->prophesize(UserAuthInterface::class);
......
......@@ -17,10 +17,8 @@ class UserLegacyTest extends KernelTestBase {
*/
protected static $modules = ['user'];
/**
* @expectedDeprecation user_password() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Password\PasswordGeneratorInterface::generate() instead. See https://www.drupal.org/node/3153113
*/
public function testUserPassword() {
$this->expectDeprecation('user_password() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Drupal\Core\Password\PasswordGeneratorInterface::generate() instead. See https://www.drupal.org/node/3153113');
$this->assertNotEmpty(user_password());
}
......
......@@ -71,10 +71,9 @@ public function testNeedsEntityLinkUrlUpdate() {
/**
* @covers ::needsEntityLinkUrlUpdate
*
* @expectedDeprecation The entity link url update for the "node_link_update_test" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.
*/
public function testNeedsEntityLinkUrlUpdateDeprecation() {
$this->expectDeprecation('The entity link url update for the "node_link_update_test" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.');
$test_view = $this->loadTestView('views.view.node_link_update_test');
$needs_update = $this->configUpdater->needsEntityLinkUrlUpdate($test_view);
$this->assertTrue($needs_update);
......@@ -92,10 +91,9 @@ public function testNeedsOperatorUpdateDefaults() {
/**
* @covers ::needsOperatorDefaultsUpdate
*
* @expectedDeprecation The operator defaults update for the "test_exposed_filters" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.
*/
public function testNeedsOperatorDefaultsUpdateDeprecation() {
$this->expectDeprecation('The operator defaults update for the "test_exposed_filters" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.');
$test_view = $this->loadTestView('views.view.test_exposed_filters');
$needs_update = $this->configUpdater->needsOperatorDefaultsUpdate($test_view);
$this->assertTrue($needs_update);
......@@ -113,10 +111,9 @@ public function testNeedsFieldNamesForMultivalueBaseFieldsUpdate() {
/**
* @covers ::needsMultivalueBaseFieldUpdate
*
* @expectedDeprecation The multivalue base field update for the "test_user_multi_value" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2900684.
*/
public function testNeedsFieldNamesForMultivalueBaseUpdateFieldsDeprecation() {
$this->expectDeprecation('The multivalue base field update for the "test_user_multi_value" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2900684.');
$test_view = $this->loadTestView('views.view.test_user_multi_value');
$needs_update = $this->configUpdater->needsMultivalueBaseFieldUpdate($test_view);
$this->assertTrue($needs_update);
......@@ -124,12 +121,11 @@ public function testNeedsFieldNamesForMultivalueBaseUpdateFieldsDeprecation() {
/**
* @covers ::updateAll
*
* @expectedDeprecation The entity link url update for the "node_link_update_test" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.
* @expectedDeprecation The operator defaults update for the "test_exposed_filters" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.
* @expectedDeprecation The multivalue base field update for the "test_user_multi_value" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2900684.
*/
public function testUpdateAll() {
$this->expectDeprecation('The entity link url update for the "node_link_update_test" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2857891.');
$this->expectDeprecation('The operator defaults update for the "test_exposed_filters" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2869168.');
$this->expectDeprecation('The multivalue base field update for the "test_user_multi_value" view is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Module-provided Views configuration should be updated to accommodate the changes described at https://www.drupal.org/node/2900684.');
$view_ids = [
'views.view.node_link_update_test',
'views.view.test_exposed_filters',
......
......@@ -18,10 +18,11 @@ class JavascriptDeprecationTest extends WebDriverTestBase {
protected $defaultTheme = 'stark';
/**
* @expectedDeprecation Javascript Deprecation: This function is deprecated for testing purposes.
* @expectedDeprecation Javascript Deprecation: This property is deprecated for testing purposes.
* Tests Javascript deprecation notices.
*/
public function testJavascriptDeprecation() {
$this->expectDeprecation('Javascript Deprecation: This function is deprecated for testing purposes.');
$this->expectDeprecation('Javascript Deprecation: This property is deprecated for testing purposes.');
$this->drupalGet('js_deprecation_test');
// Ensure that deprecation message from previous page loads will be
// detected.
......
......@@ -26,10 +26,9 @@ class AssertLegacyTraitDeprecatedTest extends BrowserTestBase {
/**
* Tests getAllOptions().
*
* @expectedDeprecation AssertLegacyTrait::getAllOptions() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $element->findAll('xpath', 'option') instead. See https://www.drupal.org/node/3129738
*/
public function testGetAllOptions() {
$this->expectDeprecation('AssertLegacyTrait::getAllOptions() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $element->findAll(\'xpath\', \'option\') instead. See https://www.drupal.org/node/3129738');
$this->drupalGet('/form-test/select');
$this->assertCount(6, $this->getAllOptions($this->cssSelect('select[name="opt_groups"]')[0]));
}
......
......@@ -21,16 +21,18 @@ class PhpUnitBridgeTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
/**
* @expectedDeprecation This is the deprecation message for deprecation_test_function().
* Tests deprecation message from deprecation_test_function().
*/
public function testSilencedError() {
$this->expectDeprecation('This is the deprecation message for deprecation_test_function().');
$this->assertEquals('known_return_value', deprecation_test_function());
}
/**
* @expectedDeprecation This is the deprecation message for deprecation_test_function().
* Tests deprecation message from deprecated route.
*/
public function testErrorOnSiteUnderTest() {
$this->expectDeprecation('This is the deprecation message for deprecation_test_function().');
$this->drupalGet(Url::fromRoute('deprecation_test.route'));
}
......
......@@ -217,13 +217,12 @@ public function testLibrariesExtend() {
* Test deprecated libraries.
*
* @group legacy
*
* @expectedDeprecation Theme "theme_test" is overriding a deprecated library. The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com
* @expectedDeprecation Theme "theme_test" is extending a deprecated library. The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com
* @expectedDeprecation The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com
* @expectedDeprecation The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com
*/
public function testDeprecatedLibrary() {
$this->expectDeprecation('Theme "theme_test" is overriding a deprecated library. The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
$this->expectDeprecation('Theme "theme_test" is extending a deprecated library. The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
$this->expectDeprecation('The "theme_test/deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
$this->expectDeprecation('The "theme_test/another_deprecated_library" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
$this->activateTheme('test_legacy_theme');
$this->libraryDiscovery->getLibraryByName('theme_test', 'deprecated_library');
$this->libraryDiscovery->getLibraryByName('theme_test', 'another_deprecated_library');
......
......@@ -21,10 +21,9 @@ class ConfigSchemaDeprecationTest extends KernelTestBase {
/**
* Tests config schema deprecation.
*
* @expectedDeprecation The 'complex_structure_deprecated' config schema is deprecated in drupal:9.1.0 and is removed from drupal 10.0.0. Use the 'complex_structure' config schema instead. See http://drupal.org/node/the-change-notice-nid.
*/
public function testConfigSchemaDeprecation() {
$this->expectDeprecation('The \'complex_structure_deprecated\' config schema is deprecated in drupal:9.1.0 and is removed from drupal 10.0.0. Use the \'complex_structure\' config schema instead. See http://drupal.org/node/the-change-notice-nid.');
$config = $this->config('config_schema_deprecated_test.settings');
$config
->set('complex_structure_deprecated.type', 'fruits')
......
......@@ -14,9 +14,10 @@
class ConfigStorageStagingTest extends KernelTestBase {
/**
* @expectedDeprecation The "config.storage.staging" service is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use the "config.storage.sync" service instead. See https://www.drupal.org/node/2574957
* Tests deprecation of the "config.storage.staging" service.
*/
public function testConfigStorageStagingDeprecation() {
$this->expectDeprecation('The "config.storage.staging" service is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use the "config.storage.sync" service instead. See https://www.drupal.org/node/2574957');
$storage_staging = \Drupal::service('config.storage.staging');
// Ensure at least one assertion.
$this->assertInstanceOf(FileStorage::class, $storage_staging);
......
......@@ -122,10 +122,10 @@ public function testConnectionOptions() {
* Tests the deprecation of the 'transactions' connection option.
*
* @group legacy
* @expectedDeprecation Passing a 'transactions' connection option to Drupal\Core\Database\Connection::__construct is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745
* @expectedDeprecation Drupal\Core\Database\Connection::supportsTransactions is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745
*/
public function testTransactionsOptionDeprecation() {
$this->expectDeprecation('Passing a \'transactions\' connection option to Drupal\Core\Database\Connection::__construct is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745');
$this->expectDeprecation('Drupal\Core\Database\Connection::supportsTransactions is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745');
$connection_info = Database::getConnectionInfo('default');
$connection_info['default']['transactions'] = FALSE;
Database::addConnectionInfo('default', 'foo', $connection_info['default']);
......
......@@ -17,9 +17,9 @@ class DatabaseExceptionWrapperTest extends KernelTestBase {
* Tests deprecation of Connection::prepare.
*
* @group legacy
* @expectedDeprecation Connection::prepare() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Database drivers should instantiate \PDOStatement objects by calling \PDO::prepare in their Connection::prepareStatement method instead. \PDO::prepare should not be called outside of driver code. See https://www.drupal.org/node/3137786
*/
public function testPrepare() {
$this->expectDeprecation('Connection::prepare() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Database drivers should instantiate \PDOStatement objects by calling \PDO::prepare in their Connection::prepareStatement method instead. \PDO::prepare should not be called outside of driver code. See https://www.drupal.org/node/3137786');
$connection = Database::getConnection();
try {
// SQLite validates the syntax upon preparing a statement already.
......@@ -41,9 +41,9 @@ public function testPrepare() {
* Tests deprecation of Connection::prepareQuery.
*
* @group legacy
* @expectedDeprecation Connection::prepareQuery() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::prepareStatement() instead. See https://www.drupal.org/node/3137786
*/
public function testPrepareQuery() {
$this->expectDeprecation('Connection::prepareQuery() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::prepareStatement() instead. See https://www.drupal.org/node/3137786');
$this->expectException(\PDOException::class);
$stmt = Database::getConnection()->prepareQuery('bananas');
$stmt->execute();
......
......@@ -18,9 +18,9 @@ class ModuleHandlerDeprecatedHookTest extends KernelTestBase {
/**
* @covers ::invokeDeprecated
* @expectedDeprecation The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.
*/
public function testInvokeDeprecated() {
$this->expectDeprecation('The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.');
/* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
$module_handler = $this->container->get('module_handler');
$arg = 'an_arg';
......@@ -32,9 +32,9 @@ public function testInvokeDeprecated() {
/**
* @covers ::invokeAllDeprecated
* @expectedDeprecation The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.
*/
public function testInvokeAllDeprecated() {
$this->expectDeprecation('The deprecated hook hook_deprecated_hook() is implemented in these functions: deprecation_test_deprecated_hook(). Use something else.');
/* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
$module_handler = $this->container->get('module_handler');
$arg = 'an_arg';
......@@ -46,9 +46,9 @@ public function testInvokeAllDeprecated() {
/**
* @covers ::alterDeprecated
* @expectedDeprecation The deprecated alter hook hook_deprecated_alter_alter() is implemented in these functions: deprecation_test_deprecated_alter_alter. Alter something else.
*/
public function testAlterDeprecated() {
$this->expectDeprecation('The deprecated alter hook hook_deprecated_alter_alter() is implemented in these functions: deprecation_test_deprecated_alter_alter. Alter something else.');
/* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
$module_handler = $this->container->get('module_handler');
$data = [];
......
......@@ -2,6 +2,7 @@
namespace Drupal\KernelTests\Core\Extension;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\KernelTests\KernelTestBase;
/**
......@@ -17,13 +18,13 @@ class ModuleHandlerDeprecatedHookUnimplementedTest extends KernelTestBase {
* @covers ::alterDeprecated
* @covers ::invokeAllDeprecated
* @covers ::invokeDeprecated
* @doesNotPerformAssertions
*/
public function testUnimplementedHooks() {
$unimplemented_hook_name = 'unimplemented_hook_name';
/* @var $module_handler \Drupal\Core\Extension\ModuleHandlerInterface */
$module_handler = $this->container->get('module_handler');
$this->assertInstanceOf(ModuleHandlerInterface::class, $module_handler);
$module_handler->invokeDeprecated('Use something else.', 'deprecation_test', $unimplemented_hook_name);
$module_handler->invokeAllDeprecated('Use something else.', $unimplemented_hook_name);
......
......@@ -24,10 +24,9 @@ protected function setUp(): void {
/**
* Tests update_check_incompatibility() function.
*
* @expectedDeprecation update_check_incompatibility() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3150727
*/
public function testUpdateCheckIncompatibility() {
$this->expectDeprecation('update_check_incompatibility() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3150727');
$this->assertTrue(update_check_incompatibility('incompatible_module'));
$this->assertFalse(update_check_incompatibility('system'));
}
......
......@@ -93,12 +93,12 @@ public function testFileMimeTypeDetection() {
* Test deprecations.
*
* @group legacy
* @expectedDeprecation The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead.
* @expectedDeprecation The "Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileBinaryMimeTypeGuesser" instead.
* @expectedDeprecation The "Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileinfoMimeTypeGuesser" instead.
* @expectedDeprecation Drupal\Core\File\MimeType\MimeTypeGuesser::guess() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::guessMimeType() instead. See https://www.drupal.org/node/3133341
*/
public function testFileMimeTypeDetectionDeprecation() {
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\MimeTypes" instead.');
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileBinaryMimeTypeGuesser" instead.');
$this->expectDeprecation('The "Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser" class is deprecated since Symfony 4.3, use "Symfony\Component\Mime\FileinfoMimeTypeGuesser" instead.');
$this->expectDeprecation('Drupal\Core\File\MimeType\MimeTypeGuesser::guess() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::guessMimeType() instead. See https://www.drupal.org/node/3133341');
$guesser = $this->container->get('file.mime_type.guesser');
$output = $guesser->guess('public://test.jar');
$this->assertSame('application/java-archive', $output);
......
......@@ -14,21 +14,19 @@ class LegacyServiceTest extends KernelTestBase {
/**
* Tests the site.path service.
*
* @expectedDeprecation The "site.path" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612
* @expectedDeprecation The "site.path.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612
*/
public function testSitePath() {
$this->expectDeprecation('The "site.path" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612');
$this->expectDeprecation('The "site.path.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the site.path parameter instead. See https://www.drupal.org/node/3080612');
$this->assertSame($this->container->get('site.path'), (string) $this->container->getParameter('site.path'));
}
/**
* Tests the app.root service.
*
* @expectedDeprecation The "app.root" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612
* @expectedDeprecation The "app.root.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612
*/
public function testAppRoot() {
$this->expectDeprecation('The "app.root" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612');
$this->expectDeprecation('The "app.root.factory" service is deprecated in drupal:9.0.0 and is removed from drupal:10.0.0. Use the app.root parameter instead. See https://www.drupal.org/node/3080612');
$this->assertSame($this->container->get('app.root'), (string) $this->container->getParameter('app.root'));
}
......
......@@ -736,9 +736,9 @@ public function testGetRoutesByPatternWithLongPatterns() {
* Tests getRoutesPaged().
*
* @group legacy
* @expectedDeprecation Drupal\Core\Routing\RouteProvider::getRoutesPaged() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009
*/
public function testGetRoutesPaged() {
$this->expectDeprecation('Drupal\Core\Routing\RouteProvider::getRoutesPaged() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009');
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
......@@ -766,9 +766,9 @@ public function testGetRoutesPaged() {
* Tests getRoutesCount().
*
* @group legacy
* @expectedDeprecation Drupal\Core\Routing\RouteProvider::getRoutesCount() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009
*/
public function testGetRoutesCount() {
$this->expectDeprecation('Drupal\Core\Routing\RouteProvider::getRoutesCount() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3151009');
$connection = Database::getConnection();
$provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
......
......@@ -15,18 +15,14 @@ class PhpUnitBridgeTest extends KernelTestBase {
protected static $modules = ['deprecation_test'];
/**
* @expectedDeprecation Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass is deprecated.
*/
public function testDeprecatedClass() {
$this->expectDeprecation('Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass is deprecated.');
$deprecated = new FixtureDeprecatedClass();
$this->assertEquals('test', $deprecated->testFunction());
}
/**
* @expectedDeprecation This is the deprecation message for deprecation_test_function().
*/
public function testDeprecatedFunction() {
$this->expectDeprecation('This is the deprecation message for deprecation_test_function().');
$this->assertEquals('known_return_value', \deprecation_test_function());
}
......
......@@ -26,10 +26,9 @@ class RegistryLegacyTest extends KernelTestBase {
/**
* Tests the theme registry with theme functions and multiple subthemes.
*
* @expectedDeprecation Unsilenced deprecation: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of theme_theme_test(). See https://www.drupal.org/node/1831138
*/
public function testMultipleSubThemes() {
$this->expectDeprecation('Unsilenced deprecation: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of theme_theme_test(). See https://www.drupal.org/node/1831138');
$theme_handler = \Drupal::service('theme_handler');
\Drupal::service('module_installer')->install(['theme_legacy_test']);
\Drupal::service('theme_installer')->install(['test_basetheme']);
......@@ -46,10 +45,9 @@ public function testMultipleSubThemes() {
/**
* Tests the theme registry with theme functions with suggestions.
*
* @expectedDeprecation Unsilenced deprecation: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of test_legacy_theme_theme_test_preprocess_suggestions__kitten__meerkat(). See https://www.drupal.org/node/1831138
*/
public function testSuggestionPreprocessFunctions() {
$this->expectDeprecation('Unsilenced deprecation: Theme functions are deprecated in drupal:8.0.0 and are removed from drupal:10.0.0. Use Twig templates instead of test_legacy_theme_theme_test_preprocess_suggestions__kitten__meerkat(). See https://www.drupal.org/node/1831138');
$theme_handler = \Drupal::service('theme_handler');
\Drupal::service('theme_installer')->install(['test_legacy_theme']);
......
......@@ -30,6 +30,7 @@
use org\bovigo\vfs\visitor\vfsStreamPrintVisitor;
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\Routing\Route;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
/**
* Base class for functional integration tests.
......@@ -81,6 +82,7 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
use TestRequirementsTrait;
use PhpUnitWarnings;
use PhpUnitCompatibilityTrait;
use ExpectDeprecationTrait;
/**
* {@inheritdoc}
......
......@@ -322,9 +322,9 @@ public function testProfileModules() {
* Tests the deprecation of AssertLegacyTrait::assert.
*
* @group legacy
* @expectedDeprecation AssertLegacyTrait::assert() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertTrue() instead. See https://www.drupal.org/node/3129738
*/
public function testAssert() {
$this->expectDeprecation('AssertLegacyTrait::assert() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertTrue() instead. See https://www.drupal.org/node/3129738');
$this->assert(TRUE);
}
......@@ -332,9 +332,9 @@ public function testAssert() {
* Tests the deprecation of AssertLegacyTrait::assertIdenticalObject.
*
* @group legacy
* @expectedDeprecation AssertLegacyTrait::assertIdenticalObject() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertEquals() instead. See https://www.drupal.org/node/3129738
*/
public function testAssertIdenticalObject() {
$this->expectDeprecation('AssertLegacyTrait::assertIdenticalObject() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertEquals() instead. See https://www.drupal.org/node/3129738');
$this->assertIdenticalObject((object) ['foo' => 'bar'], (object) ['foo' => 'bar']);
}
......@@ -342,9 +342,9 @@ public function testAssertIdenticalObject() {
* Tests the deprecation of ::installSchema with the tables key_value(_expire).
*
* @group legacy
* @expectedDeprecation Installing the tables key_value and key_value_expire with the method KernelTestBase::installSchema() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The tables are now lazy loaded and therefore will be installed automatically when used. See https://www.drupal.org/node/3143286
*/
public function testKernelTestBaseInstallSchema() {
$this->expectDeprecation('Installing the tables key_value and key_value_expire with the method KernelTestBase::installSchema() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. The tables are now lazy loaded and therefore will be installed automatically when used. See https://www.drupal.org/node/3143286');
$this->enableModules(['system']);
$this->installSchema('system', ['key_value', 'key_value_expire']);
$this->assertFalse(Database::getConnection()->schema()->tableExists('key_value'));
......
......@@ -15,9 +15,9 @@ class AssertHelperTraitTest extends UnitTestCase {
/**
* @covers ::castSafeStrings
* @dataProvider providerCastSafeStrings
* @expectDeprecation AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638
*/
public function testCastSafeStrings($expected, $value) {
$this->expectDeprecation('AssertHelperTrait::castSafeStrings() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. There is no replacement; assertEquals() will automatically cast MarkupInterface to strings when needed. See https://www.drupal.org/node/3123638');
$class = new AssertHelperTestClass();
$this->assertSame($expected, $class->testMethod($value));
}
......
......@@ -23,6 +23,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\CssSelector\CssSelectorConverter;
/**
......@@ -66,6 +67,7 @@ abstract class BrowserTestBase extends TestCase {
use XdebugRequestTrait;
use PhpUnitWarnings;
use PhpUnitCompatibilityTrait;
use ExpectDeprecationTrait;
/**
* The database prefix of this test run.
......