36/36 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

------ ----------------------------------------------------------------------
Line src/Form/ShareMessageForm.php
------ ----------------------------------------------------------------------
457 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
460 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------

------ ----------------------------------------------------------------------
Line src/Form/SharrreSettingsForm.php
------ ----------------------------------------------------------------------
126 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
130 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ ----------------------------------------------------------------------

------ --------------------------------------------------------------------------------------------------------------------------------------
Line src/SharePluginInterface.php
------ --------------------------------------------------------------------------------------------------------------------------------------
13 Interface Drupal\sharemessage\SharePluginInterface extends deprecated interface Drupal\Component\Plugin\ConfigurablePluginInterface:
Drupal\Component\Plugin\ConfigurablePluginInterface is deprecated
in Drupal 8.7.0 and will be removed before Drupal 9.0.0. You should implement
ConfigurableInterface and/or DependentPluginInterface directly as needed. If
you implement ConfigurableInterface you may choose to implement
ConfigurablePluginInterface in Drupal 8 as well for maximum compatibility,
however this must be removed prior to Drupal 9.
------ --------------------------------------------------------------------------------------------------------------------------------------

------ -------------------------------------------------------------------------------------
Line src/Tests/ShareMessageExtraFieldTest.php
------ -------------------------------------------------------------------------------------
77 Call to deprecated function entity_get_display():
as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
If the display is available in configuration use:
78 Call to deprecated function entity_get_display():
as of Drupal 8.0.x, will be removed before Drupal 9.0.0.
If the display is available in configuration use:
248 Call to deprecated method getVocabularyId() of class Drupal\taxonomy\TermInterface:
Scheduled for removal before Drupal 9.0.0. Use
TermInterface::bundle() instead.
------ -------------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------
Line src/Tests/ShareMessageTestBase.php
------ ----------------------------------------------------------------------------------
278 Call to deprecated method format() of class Drupal\Component\Utility\SafeMarkup:
in Drupal 8.0.0, will be removed before Drupal 9.0.0.
Use \Drupal\Component\Render\FormattableMarkup.
278 Call to method format() of deprecated class Drupal\Component\Utility\SafeMarkup:
Will be removed before Drupal 9.0.0. Use the appropriate
306 Call to deprecated method format() of class Drupal\Component\Utility\SafeMarkup:
in Drupal 8.0.0, will be removed before Drupal 9.0.0.
Use \Drupal\Component\Render\FormattableMarkup.
306 Call to method format() of deprecated class Drupal\Component\Utility\SafeMarkup:
Will be removed before Drupal 9.0.0. Use the appropriate
------ ----------------------------------------------------------------------------------

[ERROR] Found 12 errors

Comments

Sahana _N created an issue. See original summary.

sahana _n’s picture

StatusFileSize
new6.21 KB

A patch is created for Drupal 9 compatibility. please review.

36/36 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

[OK] No errors

sahana _n’s picture

Status: Active » Needs review
kristen pol’s picture

Issue tags: +Drupal 9 compatibility

Per a Slack discussion with Gábor Hojtsy regarding usage of D9 tags (Drupal 9, Drupal 9 compatibility, Drupal 9 readiness, etc.), "Drupal 9 compatibility" should be used for contributed projects that need updating and "Drupal 9" was the old tag for D8 issues before the D9 branch was ready. Doing tag cleanup here based on that discussion.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Form/ShareMessageForm.php
    @@ -454,10 +454,10 @@ class ShareMessageForm extends EntityForm {
         if ($status == SAVED_UPDATED) {
    -      drupal_set_message(t('Share Message %label has been updated.', ['%label' => $sharemessage->label()]));
    +      $this->messenger->addMessage(t('Share Message %label has been updated.', ['%label' => $sharemessage->label()]));
         }
    

    This needs to use $this->messenger() instead

  2. +++ b/src/Tests/ShareMessageExtraFieldTest.php
    @@ -74,8 +74,8 @@ class ShareMessageExtraFieldTest extends ShareMessageTestBase {
         // displays. Explicitly save one for user and terms here.
    -    entity_get_display('user', 'user', 'default')->save();
    -    entity_get_display('taxonomy_term', 'tags', 'default')->save();
    +    \Drupal::service('entity_display.repository')->getViewDisplay('user', 'user', 'default')->save();
    +    \Drupal::service('entity_display.repository')->getViewDisplay('taxonomy_term', 'tags', 'default')->save();
    

    the default argument isn't needed anymore and this means we require ^8.8 || ^9, .info.yml needs to be updated.

  3. +++ b/src/Tests/ShareMessageTestBase.php
    @@ -275,7 +274,7 @@ abstract class ShareMessageTestBase extends WebTestBase {
        */
       protected function assertFieldCheckedByName($name, $message = '', $group = 'Browser') {
         $elements = $this->xpath('//input[@name=:name]', [':name' => $name]);
    -    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : SafeMarkup::format('Checkbox field @name is checked.', ['@name' => $name]), $group);
    +    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : new FormattableMarkup('Checkbox field @name is checked.', ['@name' => $name]), $group);
       }
    

    The test needs to be converted to a phpunit functional test.

    We can also drop this custom assert method and just use $this->assertSession()->checkboxChecked(); and NotChecked() instead.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new31.04 KB
new29.9 KB

Summary:

  • Addressed #5
  • Converted all tests to BrowserTests and fixed those except of Drupal\Tests\sharemessage\Functional\ShareMessageExtraFieldTest. This one needs more work on setEntityRawContent()
  • https://www.drupal.org/docs/8/testing/converting-d7-and-d8-simpletests-t... recommends:

    If there is a test method which does not perform any web request (for example no ->drupalGet() or ->drupalPostForm() calls) then that method should be extracted to a unit test or kernel test. $this->setRawContent() generally means the test should be converted to a Kernel test. This is best done in a follow-up issue, it is best to first convert it to a BrowserTestBase test.

    I think that can be a follow-up or all test conversion can be moved into a separate issue...

Status: Needs review » Needs work

The last submitted patch, 6: 3096177-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

+++ b/tests/src/Functional/Plugin/ShareMessageSocialSharePrivacyTest.php
@@ -27,8 +27,7 @@ class ShareMessageSocialSharePrivacyTest extends ShareMessageTestBase {
 
     // Set a new Share Message.
     $this->drupalGet('admin/config/services/sharemessage/add');
-    $this->drupalPostAjaxForm(NULL, ['plugin' => 'socialshareprivacy'], 'plugin');
-    $this->assertText('Social Share Privacy is a jQuery plugin that lets you add social share buttons to your website that don\'t allow the social sites to track your users.');
+    $this->drupalPostForm(NULL, ['plugin' => 'socialshareprivacy'], 'Select plugin');
     $override_settings = '//details[starts-with(@data-drupal-selector, "edit-settings")]';

the assert text doesn't work anymore here? if the form elements below work then I'd expect the description to show up too?

mbovan’s picture

-    $this->drupalPostAjaxForm(NULL, ['plugin' => 'socialshareprivacy'], 'plugin');
-    $this->assertText('Social Share Privacy is a jQuery plugin that lets you add social share buttons to your website that don\'t allow the social sites to track your users.');
+    $this->drupalPostForm(NULL, ['plugin' => 'socialshareprivacy'], 'Select plugin');

drupalPostAjaxForm -> drupalPostForm does not work here.

The easiest way was to save the plugin, revisit the chosen plugin edit page and assert descriptions.

$override_settings = '//details[starts-with(@data-drupal-selector, "edit-settings")]';
can actually be removed since it always asserts the markup of the first/default plugin or it can be moved to the "Edit" page mentioned above.

mbovan’s picture

Status: Needs work » Needs review
StatusFileSize
new42.55 KB
new20.99 KB

Improved plugin tests as per #10 and fixed Drupal\Tests\sharemessage\Functional\ShareMessageExtraFieldTest.

berdir’s picture

+++ b/tests/src/Functional/Plugin/ShareMessageAddthisTest.php
@@ -25,21 +24,20 @@ class ShareMessageAddthisTest extends ShareMessageTestBase {
 
     // Set a new Share Message.
-    $this->drupalGet('admin/config/services/sharemessage/add');
-    $this->drupalPostAjaxForm(NULL, ['plugin' => 'addthis'], 'plugin');
-    $this->assertText('AddThis plugin for Share Message module.');
-    $override_settings = '//details[starts-with(@data-drupal-selector, "edit-settings")]';
-    $this->assertFieldByXPath($override_settings);
     $sharemessage = [
       'label' => 'ShareMessage Test AddThis',
       'id' => 'sharemessage_test_addthis_label',
       'plugin' => 'addthis',
       'title' => 'AddThis test',
     ];
-    $this->drupalPostForm(NULL, $sharemessage, t('Save'));
+    $this->drupalPostForm('admin/config/services/sharemessage/add', $sharemessage, t('Save'));
+    $this->drupalGet('admin/config/services/sharemessage/manage/sharemessage_test_addthis_label');
+    $this->assertText('AddThis plugin for Share Message module.');
+    $override_settings = '//details[starts-with(@data-drupal-selector, "edit-settings")]';
+    $this->assertFieldByXPath($override_settings);
 
     // Assert that the initial settings are saved correctly.

I'm still struggling to understand all these changes. I locally reverted most of them and just did this, and it passes for me?

diff --git a/src/Tests/Plugin/ShareMessageAddthisTest.php b/tests/src/Functional/Plugin/ShareMessageAddthisTest.php
similarity index 82%
rename from src/Tests/Plugin/ShareMessageAddthisTest.php
rename to tests/src/Functional/Plugin/ShareMessageAddthisTest.php
index b9f005a..d51ca9e 100644
--- a/src/Tests/Plugin/ShareMessageAddthisTest.php
+++ b/tests/src/Functional/Plugin/ShareMessageAddthisTest.php
@@ -1,8 +1,8 @@
 <?php
 
-namespace Drupal\sharemessage\Tests\Plugin;
+namespace Drupal\Tests\sharemessage\Functional\Plugin;
 
-use Drupal\sharemessage\Tests\ShareMessageTestBase;
+use Drupal\Tests\sharemessage\Functional\ShareMessageTestBase;
 
 /**
  * Test class for Share Message AddThis specific plugin.
@@ -16,7 +16,6 @@ class ShareMessageAddthisTest extends ShareMessageTestBase {
    */
   public function testAddThisSettingsFormSave() {
     // Set initial AddThis settings.
-    $this->drupalGet('admin/config/services/sharemessage/addthis-settings');
     $default_settings = [
       'default_services[]' => [
         'facebook',
@@ -25,11 +24,11 @@ class ShareMessageAddthisTest extends ShareMessageTestBase {
       'default_additional_services' => FALSE,
       'default_icon_style' => 'addthis_16x16_style',
     ];
-    $this->drupalPostForm(NULL, $default_settings, t('Save configuration'));
+    $this->drupalPostForm('admin/config/services/sharemessage/addthis-settings', $default_settings, t('Save configuration'));
 
     // Set a new Share Message.
     $this->drupalGet('admin/config/services/sharemessage/add');
-    $this->drupalPostAjaxForm(NULL, ['plugin' => 'addthis'], 'plugin');
+    $this->drupalPostForm(NULL, ['plugin' => 'addthis'], 'plugin');
     $this->assertText('AddThis plugin for Share Message module.');
     $override_settings = '//details[starts-with(@data-drupal-selector, "edit-settings")]';
     $this->assertFieldByXPath($override_settings);
@@ -49,7 +48,6 @@ class ShareMessageAddthisTest extends ShareMessageTestBase {
     $this->assertNoRaw('<a class="addthis_button_compact">');
 
     // Set new AddThis settings.
-    $this->drupalGet('admin/config/services/sharemessage/addthis-settings');
     $default_settings = [
       'default_services[]' => [
         'facebook',
@@ -59,7 +57,7 @@ class ShareMessageAddthisTest extends ShareMessageTestBase {
       'default_additional_services' => TRUE,
       'default_icon_style' => 'addthis_32x32_style',
     ];
-    $this->drupalPostForm(NULL, $default_settings, t('Save configuration'));
+    $this->drupalPostForm('admin/config/services/sharemessage/addthis-settings', $default_settings, t('Save configuration'));
 
     // Check that the saving of the new AddThis settings works correctly.
     $this->drupalGet('sharemessage-test/sharemessage_test_addthis_label');
mbovan’s picture

StatusFileSize
new42.21 KB
new1.55 KB

As far as I can see, this part:

     // Set a new Share Message.
     $this->drupalGet('admin/config/services/sharemessage/add');
-    $this->drupalPostAjaxForm(NULL, ['plugin' => 'addthis'], 'plugin');
+    $this->drupalPostForm(NULL, ['plugin' => 'addthis'], 'plugin');

only passes because addthis is a default plugin and gets preselected when you're on admin/config/services/sharemessage/add. That means, $this->drupalPostForm(NULL, ['plugin' => 'addthis'], 'plugin') doesn't really do anything and that can be confirmed in other similar tests that are testing non-default plugins (ShareMessageOGHeadersTest, ShareMessageSharrreTest, ShareMessageSocialSharePrivacyTest).

Still, I think it makes sense to keep the old behavior (without $this->drupalPostForm(NULL, ['plugin' => 'addthis'], 'plugin') line) so we can also test that addthis is indeed a default plugin.

segovia94’s picture

Status: Needs review » Reviewed & tested by the community

The patch from #12 applied cleanly, local tests passed, and it appears to be working well on a fresh D9 install.

  • Berdir committed 66dbd21 on 8.x-1.x authored by mbovan
    Issue #3096177 by mbovan, Sahana _N: Drupal 9 compatability
    
berdir’s picture

Status: Reviewed & tested by the community » Fixed

Finally committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.