Commit 3954b30b authored by git's avatar git Committed by Adrian Cid Almaguer
Browse files

Issue #3297527 by Project Update Bot, adriancid: Automated Drupal 10 compatibility fixes

parent 12689ba3
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
***************
*** 5,11 ****
  use Drupal\Core\Config\ConfigFactoryInterface;
  use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
  use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
- use Drupal\Core\Entity\EntityTypeManager;
  use Drupal\Core\StringTranslation\StringTranslationTrait;
  use Drupal\votingapi\Entity\VoteType;
  use Symfony\Component\DependencyInjection\ContainerInterface;
--- 5,11 ----
  use Drupal\Core\Config\ConfigFactoryInterface;
  use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
  use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
+ use Drupal\Core\Entity\EntityTypeManagerInterface;
  use Drupal\Core\StringTranslation\StringTranslationTrait;
  use Drupal\votingapi\Entity\VoteType;
  use Symfony\Component\DependencyInjection\ContainerInterface;
***************
*** 41,54 ****
    /**
     * Constructs a \Drupal\like_and_dislike\Form\SettingsForm object.
     *
-    * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
     *   The entity type manager.
     * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
     *   The factory for configuration objects.
     * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service
     *   The bundle info service.
     */
-   public function __construct(EntityTypeManager $entity_type_manager, ConfigFactoryInterface $config_factory, EntityTypeBundleInfoInterface $bundle_info_service) {
      $this->entityTypeManager = $entity_type_manager;
      $this->configFactory = $config_factory;
      $this->bundleInfoService = $bundle_info_service;
--- 41,54 ----
    /**
     * Constructs a \Drupal\like_and_dislike\Form\SettingsForm object.
     *
+    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
     *   The entity type manager.
     * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
     *   The factory for configuration objects.
     * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service
     *   The bundle info service.
     */
+   public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, EntityTypeBundleInfoInterface $bundle_info_service) {
      $this->entityTypeManager = $entity_type_manager;
      $this->configFactory = $config_factory;
      $this->bundleInfoService = $bundle_info_service;
+37 −27
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class LikeAndDislikeTest extends WebDriverTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp() {
  protected function setUp(): void {
    parent::setUp();

    // Create a node type.
@@ -105,7 +105,7 @@ class LikeAndDislikeTest extends WebDriverTestBase {
    $edit = [
      'display_modes_custom[teaser]' => TRUE,
    ];
    $this->drupalPostForm(NULL, $edit, 'Save');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('Your settings have been saved.');

    // Enable like an dislike for our article node type, disable for our
@@ -118,15 +118,16 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'allow_cancel_vote' => TRUE,
      'hide_vote_widget' => FALSE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    $this->assertFieldChecked('edit-enabled-types-node-enabled');
    $this->assertFieldChecked('edit-enabled-types-comment-enabled');
    $this->assertFieldChecked('edit-enabled-types-node-bundle-info-bundles-article');
    $this->assertNoFieldChecked('edit-enabled-types-comment-bundle-info-bundles-comment');
    $this->assertFieldChecked('edit-enabled-types-comment-bundle-info-bundles-test-comment-type');
    $this->assertFieldChecked('edit-allow-cancel-vote');
    $this->assertNoFieldChecked('edit-hide-vote-widget');
    $this->assertSession()->checkboxChecked('edit-enabled-types-node-enabled');
    $this->assertSession()->checkboxChecked('edit-enabled-types-comment-enabled');
    $this->assertSession()->checkboxChecked('edit-enabled-types-node-bundle-info-bundles-article');
    $this->assertSession()->checkboxNotChecked('edit-enabled-types-comment-bundle-info-bundles-comment');
    $this->assertSession()->checkboxChecked('edit-enabled-types-comment-bundle-info-bundles-test-comment-type');
    $this->assertSession()->checkboxChecked('edit-allow-cancel-vote');
    $this->assertSession()->checkboxNotChecked('edit-hide-vote-widget');

    // Verify there are new like and dislike permissions.
    $this->drupalGet('admin/people/permissions');
@@ -146,17 +147,17 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      $user_role . '[add or remove like votes on test_comment_type of comment]' => TRUE,
      $user_role . '[add or remove dislike votes on test_comment_type of comment]' => TRUE,
    ];
    $this->drupalPostForm(NULL, $edit, 'Save permissions');
    $this->submitForm($edit, 'Save permissions');

    // Verify that like and dislike field is showing up as a field for default
    // view mode and that it is disabled by default.
    $this->drupalGet('admin/structure/types/manage/article/display');
    $this->assertSession()->pageTextContains('Like and dislike');
    $this->assertOptionSelected('edit-fields-like-and-dislike-region', 'hidden');
    $this->assertTrue($this->assertSession()->optionExists('edit-fields-like-and-dislike-region', 'hidden')->hasAttribute('selected'));
    // Same for teaser view mode.
    $this->drupalGet('admin/structure/types/manage/article/display/teaser');
    $this->assertSession()->pageTextContains('Like and dislike');
    $this->assertOptionSelected('edit-fields-like-and-dislike-region', 'hidden');
    $this->assertTrue($this->assertSession()->optionExists('edit-fields-like-and-dislike-region', 'hidden')->hasAttribute('selected'));

    // Toggle on visibility of the extra field for default view mode.
    $this->drupalGet('admin/structure/types/manage/article/display');
@@ -186,8 +187,9 @@ class LikeAndDislikeTest extends WebDriverTestBase {
    $this->assertTrue($this->assertSession()->optionExists('fields[like_and_dislike][region]', 'hidden')->isSelected());
    $this->submitForm([], 'Save');
    $this->assertSession()->pageTextContains('Your settings have been saved.');
    $this->assertOptionSelected('edit-fields-like-and-dislike-region', 'hidden');
    $this->drupalPostForm('admin/structure/types/manage/article/display/teaser', ['fields[like_and_dislike][region]' => 'content'], 'Save');
    $this->assertTrue($this->assertSession()->optionExists('edit-fields-like-and-dislike-region', 'hidden')->hasAttribute('selected'));
    $this->drupalGet('admin/structure/types/manage/article/display/teaser');
    $this->submitForm(['fields[like_and_dislike][region]' => 'content'], 'Save');
    $this->assertSession()->pageTextContains('Your settings have been saved.');
    $this->assertFalse($this->assertSession()->optionExists('edit-fields-like-and-dislike-region', 'hidden')->isSelected());

@@ -227,7 +229,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'enabled_types[comment][bundle_info][bundles][test_comment_type]' => TRUE,
      'allow_cancel_vote' => TRUE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');

    // Verify that like and dislike are no longer showing up for nodes.
@@ -258,7 +261,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'enabled_types[node][bundle_info][bundles][article]' => TRUE,
      'allow_cancel_vote' => TRUE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    $this->drupalGet('admin/structure/types/manage/article/display');
    $this->getSession()->getPage()->selectFieldOption('fields[like_and_dislike][region]', 'content');
@@ -274,9 +278,10 @@ class LikeAndDislikeTest extends WebDriverTestBase {
    $edit = [
      'hide_vote_widget' => TRUE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    $this->assertFieldChecked('edit-hide-vote-widget');
    $this->assertSession()->checkboxChecked('edit-hide-vote-widget');

    // Turn off dislike permission for node and comment.
    $this->drupalGet('admin/people/permissions');
@@ -284,7 +289,7 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      $user_role . '[add or remove dislike votes on article of node]' => FALSE,
      $user_role . '[add or remove dislike votes on test_comment_type of comment]' => FALSE,
    ];
    $this->drupalPostForm(NULL, $edit, 'Save permissions');
    $this->submitForm($edit, 'Save permissions');

    // Verify that dislike icon is not showed in default view mode.
    $this->drupalGet('node/' . $node_id);
@@ -299,7 +304,7 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      $user_role . '[add or remove like votes on article of node]' => FALSE,
      $user_role . '[add or remove like votes on test_comment_type of comment]' => FALSE,
    ];
    $this->drupalPostForm(NULL, $edit, 'Save permissions');
    $this->submitForm($edit, 'Save permissions');

    // Verify that both like and dislike icons are not showed in default view
    // mode.
@@ -319,9 +324,10 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'enabled_types[user][enabled]' => TRUE,
      'allow_cancel_vote' => TRUE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    $this->assertFieldChecked('edit-enabled-types-user-enabled');
    $this->assertSession()->checkboxChecked('edit-enabled-types-user-enabled');

    // Make "like and dislike" component visible.
    $this->drupalGet('admin/config/people/accounts/display');
@@ -342,7 +348,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
    $edit = [
      $user_role . '[add or remove like votes on user]' => TRUE,
    ];
    $this->drupalPostForm('admin/people/permissions', $edit, 'Save permissions');
    $this->drupalGet('admin/people/permissions');
    $this->submitForm($edit, 'Save permissions');
    $this->drupalGet('user/' . $user_id);

    // Assert user is able to like, but not to dislike.
@@ -392,7 +399,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'enabled_types[comment][bundle_info][bundles][test_comment_type]' => TRUE,
      'allow_cancel_vote' => TRUE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');

    // Update user with voting permissions.
@@ -404,7 +412,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      $user_role . '[add or remove like votes on test_comment_type of comment]' => TRUE,
      $user_role . '[add or remove dislike votes on test_comment_type of comment]' => TRUE,
    ];
    $this->drupalPostForm('admin/people/permissions', $edit, 'Save permissions');
    $this->drupalGet('admin/people/permissions');
    $this->submitForm($edit, 'Save permissions');

    // Toggle on visibility of the extra fields.
    $this->drupalGet('admin/structure/types/manage/article/display');
@@ -489,7 +498,8 @@ class LikeAndDislikeTest extends WebDriverTestBase {
      'enabled_types[comment][bundle_info][bundles][test_comment_type]' => TRUE,
      'allow_cancel_vote' => FALSE,
    ];
    $this->drupalPostForm('admin/config/search/votingapi/like_and_dislike', $edit, t('Save configuration'));
    $this->drupalGet('admin/config/search/votingapi/like_and_dislike');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()->pageTextContains('The configuration options have been saved.');
    $this->drupalLogin($user2);