Commit 31a142a9 authored by Project Update Bot's avatar Project Update Bot Committed by Clemens Tolboom
Browse files

Issue #3299337 by Project Update Bot: Automated Drupal 10 compatibility fixes

parent 1a6f6d83
Loading
Loading
Loading
Loading
+31 −25
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ class TourUITest extends BrowserTestBase {
   *
   * @var array
   */
  public static $modules = ['tour_ui', 'tour_test'];
  protected static $modules = ['tour_ui', 'tour_test'];


  /**
@@ -62,11 +62,11 @@ class TourUITest extends BrowserTestBase {
    // jQuery('table > tbody > tr:first').hasClass('tour-test')
    // jQuery('table > tbody > tr.tip-edit > td:first').text()
    $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[1]', [':class' => 'tour-test']);
    $this->assertIdentical($elements[0]->getText(), 'tour-test');
    $this->assertSame($elements[0]->getText(), 'tour-test');

    // The second column contains the title.
    $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[2]', [':class' => 'tour-test']);
    $this->assertIdentical($elements[0]->getText(), t('Tour test english')->render());
    $this->assertSame($elements[0]->getText(), t('Tour test english')->render());

    // The third column contains the routes.
    // Running "jQuery('table > tbody > tr.tour-test > td:nth(2)').html()"
@@ -78,8 +78,8 @@ class TourUITest extends BrowserTestBase {

    // The fourth column contains the number of tips.
    $elements = $this->xpath('//table/tbody/tr[contains(@class, :class)]/td[4]', [':class' => 'tour-test']);
    $this->assertIdentical($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip');
    $this->assertIdentical($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips');
    $this->assertSame($elements[0]->getText(), '1', 'Core tour_test/config/tour-test-2 has 1 tip');
    $this->assertSame($elements[1]->getText(), '3', 'Core tour_test/config/tour-test-1 has 3 tips');
  }

  /**
@@ -92,15 +92,16 @@ class TourUITest extends BrowserTestBase {
      'id' => strtolower($this->randomMachineName()),
      'module' => strtolower($this->randomMachineName()),
    ];
    $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save'));
    $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']]));
    $this->drupalGet('admin/config/user-interface/tour/add');
    $this->submitForm($edit, t('Save'));
    $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']]));
    $elements = $this->xpath('//table/tbody/tr');
    $this->assertEquals(1, count($elements));

    // Edit and re-save an existing tour.
    $this->assertTitle(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')]));
    $this->drupalPostForm(NULL, [], t('Save'));
    $this->assertRaw(t('Updated the %tour tour', ['%tour' => $edit['label']]));
    $this->assertSession()->titleEquals(t('Edit tour | @site-name', ['@site-name' => \Drupal::config('system.site')->get('name')]));
    $this->submitForm([], t('Save'));
    $this->assertSession()->responseContains(t('Updated the %tour tour', ['%tour' => $edit['label']]));

    // Reorder the tour tips.
    $this->drupalGet('admin/config/user-interface/tour/manage/tour-test');
@@ -108,7 +109,7 @@ class TourUITest extends BrowserTestBase {
      'tips[tour-test-1][weight]' => '2',
      'tips[tour-test-3][weight]' => '1',
    ];
    $this->drupalPostForm(NULL, $weights, t('Save'));
    $this->submitForm($weights, t('Save'));
    $this->drupalGet('admin/config/user-interface/tour/manage/tour-test');
    $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [
      ':class' => 'draggable odd',
@@ -124,7 +125,7 @@ class TourUITest extends BrowserTestBase {
      'tips[tour-test-1][weight]' => '1',
      'tips[tour-test-3][weight]' => '2',
    ];
    $this->drupalPostForm(NULL, $weights, t('Save'));
    $this->submitForm($weights, t('Save'));
    $this->drupalGet('admin/config/user-interface/tour/manage/tour-test');
    $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [
      ':class' => 'draggable odd',
@@ -136,21 +137,22 @@ class TourUITest extends BrowserTestBase {
      ':text' => 'The awesome image',
    ]);
    $this->assertEquals(1, count($elements), 'Found even tip "The awesome image".');
    $this->drupalGet('admin/config/user-interface/tour/add');

    // Attempt to create a duplicate tour.
    $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save'));
    $this->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
    $this->submitForm($edit, t('Save'));
    $this->assertSession()->responseContains(t('The machine-readable name is already in use. It must be unique.'));

    // Delete a tour.
    $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']);
    $this->drupalPostForm(NULL, NULL, t('Delete'));
    $this->assertRaw(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']]));
    $this->submitForm(NULL, t('Delete'));
    $this->assertSession()->responseContains(t('Are you sure you want to delete the %tour tour?', ['%tour' => $edit['label']]));
    $this->clickLink(t('Cancel'));
    $this->clickLink(t('Delete'));
    $this->drupalPostForm(NULL, NULL, t('Delete'));
    $this->submitForm(NULL, t('Delete'));
    $elements = $this->xpath('//table/tbody/tr');
    $this->assertEquals(2, count($elements));
    $this->assertRaw(t('Deleted the %tour tour.', ['%tour' => $edit['label']]));
    $this->assertSession()->responseContains(t('Deleted the %tour tour.', ['%tour' => $edit['label']]));
  }

  /**
@@ -164,21 +166,23 @@ class TourUITest extends BrowserTestBase {
      'module' => $this->randomString(),
      'paths' => '',
    ];
    $this->drupalPostForm('admin/config/user-interface/tour/add', $edit, t('Save'));
    $this->assertRaw(t('The %tour tour has been created.', ['%tour' => $edit['label']]));
    $this->drupalGet('admin/config/user-interface/tour/add');
    $this->submitForm($edit, t('Save'));
    $this->assertSession()->responseContains(t('The %tour tour has been created.', ['%tour' => $edit['label']]));

    // Add a new tip.
    $tip = [
      'new' => 'image',
    ];
    $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'], $tip, t('Add'));
    $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id']);
    $this->submitForm($tip, t('Add'));
    $tip = [
      'label' => 'a' . $this->randomString(),
      'id' => 'tour-ui-test-image-tip',
      'url' => 'http://testimage.png',
      'alt' => 'Testing a new image tip through Tour UI.',
    ];
    $this->drupalPostForm(NULL, $tip, t('Save'));
    $this->submitForm($tip, t('Save'));
    $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [
      ':class' => 'draggable odd',
      ':text' => $tip['label'],
@@ -189,20 +193,22 @@ class TourUITest extends BrowserTestBase {
    $tip_id = $tip['id'];
    unset($tip['id']);
    $tip['label'] = 'a' . $this->randomString();
    $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id, $tip, t('Save'));
    $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/edit/' . $tip_id);
    $this->submitForm($tip, t('Save'));
    $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [
      ':class' => 'draggable odd',
      ':text' => $tip['label'],
    ]);
    $this->assertEquals(1, count($elements), 'Found tip "' . $tip['label'] . '".');
    $this->drupalGet('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id);

    // Delete the tip.
    $this->drupalPostForm('admin/config/user-interface/tour/manage/' . $edit['id'] . '/tip/delete/' . $tip_id, [], t('Delete'));
    $this->submitForm([], t('Delete'));
    $elements = $this->xpath('//tr[@class=:class and ./td[contains(., :text)]]', [
      ':class' => 'draggable odd',
      ':text' => $tip['label'],
    ]);
    $this->assertNotEqual(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".');
    $this->assertNotEquals(count($elements), 1, 'Did not find tip "' . $tip['label'] . '".');
  }

}
+1 −2
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ type: module
description : 'Provides a UI to manage guided tours.'
package: Development
configure: entity.tour.collection
core: 8.x
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.1 || ^10
dependencies:
  - drupal:tour