Commit 72fb4235 authored by zeuty's avatar zeuty Committed by Berdir

Issue #3061563 by zeuty: Convert simpletest to PHPUnit tests

parent 5a436346
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\pathauto\PathautoGeneratorInterface; use Drupal\pathauto\PathautoGeneratorInterface;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Bulk update functionality tests. * Bulk update functionality tests.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoBulkUpdateTest extends WebTestBase { class PathautoBulkUpdateTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\comment\Tests\CommentTestTrait; use Drupal\comment\Tests\CommentTestTrait;
/** /**
...@@ -10,7 +10,7 @@ use Drupal\comment\Tests\CommentTestTrait; ...@@ -10,7 +10,7 @@ use Drupal\comment\Tests\CommentTestTrait;
* *
* @group pathauto * @group pathauto
*/ */
class PathautoEnablingEntityTypesTest extends WebTestBase { class PathautoEnablingEntityTypesTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Mass delete functionality tests. * Mass delete functionality tests.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoMassDeleteTest extends WebTestBase { class PathautoMassDeleteTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\pathauto\Entity\PathautoPattern; use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Tests pathauto node UI integration. * Tests pathauto node UI integration.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoNodeWebTest extends WebTestBase { class PathautoNodeWebTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\pathauto\PathautoGeneratorInterface; use Drupal\pathauto\PathautoGeneratorInterface;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Tests pathauto settings form. * Tests pathauto settings form.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoSettingsFormWebTest extends WebTestBase { class PathautoSettingsFormWebTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/** /**
* Tests pathauto taxonomy UI integration. * Tests pathauto taxonomy UI integration.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoTaxonomyWebTest extends WebTestBase { class PathautoTaxonomyWebTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
...@@ -60,7 +61,7 @@ class PathautoTaxonomyWebTest extends WebTestBase { ...@@ -60,7 +61,7 @@ class PathautoTaxonomyWebTest extends WebTestBase {
$automatic_alias = '/tags/testing-term-name'; $automatic_alias = '/tags/testing-term-name';
$this->drupalPostForm('admin/structure/taxonomy/manage/tags/add', ['name[0][value]' => $name], 'Save'); $this->drupalPostForm('admin/structure/taxonomy/manage/tags/add', ['name[0][value]' => $name], 'Save');
$name = trim($name); $name = trim($name);
$this->assertText("Created new term $name."); $this->assertSession()->pageTextContains("Created new term $name.");
$term = $this->drupalGetTermByName($name); $term = $this->drupalGetTermByName($name);
// Look for alias generated in the form. // Look for alias generated in the form.
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
...@@ -73,7 +73,7 @@ trait PathautoTestHelperTrait { ...@@ -73,7 +73,7 @@ trait PathautoTestHelperTrait {
$bubbleable_metadata = new BubbleableMetadata(); $bubbleable_metadata = new BubbleableMetadata();
$tokens = \Drupal::token()->generate($type, [$token => $token], [$type => $object], [], $bubbleable_metadata); $tokens = \Drupal::token()->generate($type, [$token => $token], [$type => $object], [], $bubbleable_metadata);
$tokens += [$token => '']; $tokens += [$token => ''];
$this->assertIdentical($tokens[$token], $expected, t("Token value for [@type:@token] was '@actual', expected value '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $tokens[$token], '@expected' => $expected])); $this->assertSame($tokens[$token], $expected, t("Token value for [@type:@token] was '@actual', expected value '@expected'.", ['@type' => $type, '@token' => $token, '@actual' => $tokens[$token], '@expected' => $expected]));
} }
public function saveAlias($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { public function saveAlias($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
...@@ -119,7 +119,7 @@ trait PathautoTestHelperTrait { ...@@ -119,7 +119,7 @@ trait PathautoTestHelperTrait {
public function assertAlias($source, $expected_alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { public function assertAlias($source, $expected_alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
\Drupal::service('path.alias_manager')->cacheClear($source); \Drupal::service('path.alias_manager')->cacheClear($source);
$this->assertEqual($expected_alias, \Drupal::service('path.alias_manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", $this->assertEquals($expected_alias, \Drupal::service('path.alias_manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.",
['%source' => $source, '@language' => $langcode])); ['%source' => $source, '@language' => $langcode]));
} }
...@@ -176,7 +176,7 @@ trait PathautoTestHelperTrait { ...@@ -176,7 +176,7 @@ trait PathautoTestHelperTrait {
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->create($values); $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->create($values);
$pattern = \Drupal::service('pathauto.generator')->getPatternByEntity($entity); $pattern = \Drupal::service('pathauto.generator')->getPatternByEntity($entity);
$this->assertIdentical($expected, $pattern->getPattern()); $this->assertSame($expected, $pattern->getPattern());
} }
public function drupalGetTermByName($name, $reset = FALSE) { public function drupalGetTermByName($name, $reset = FALSE) {
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\Functional;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\views\Views; use Drupal\views\Views;
/** /**
...@@ -10,7 +10,7 @@ use Drupal\views\Views; ...@@ -10,7 +10,7 @@ use Drupal\views\Views;
* *
* @group pathauto * @group pathauto
*/ */
class PathautoUserWebTest extends WebTestBase { class PathautoUserWebTest extends BrowserTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\FunctionalJavascript;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\simpletest\WebTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\pathauto\Functional\PathautoTestHelperTrait;
/** /**
* Test pathauto functionality with localization and translation. * Test pathauto functionality with localization and translation.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoLocaleTest extends WebTestBase { class PathautoLocaleTest extends WebDriverTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
...@@ -113,35 +114,33 @@ class PathautoLocaleTest extends WebTestBase { ...@@ -113,35 +114,33 @@ class PathautoLocaleTest extends WebTestBase {
// Create a pattern for English articles. // Create a pattern for English articles.
$this->drupalGet('admin/config/search/path/patterns/add'); $this->drupalGet('admin/config/search/path/patterns/add');
$edit = [
'type' => 'canonical_entities:node', $session = $this->getSession();
]; $page = $session->getPage();
$this->drupalPostAjaxForm(NULL, $edit, 'type'); $page->fillField('type', 'canonical_entities:node');
$edit += [ $this->assertSession()->assertWaitOnAjaxRequest();
'pattern' => '/the-articles/[node:title]',
'label' => 'English articles', $page->fillField('pattern', '/the-articles/[node:title]');
'id' => 'english_articles', $page->fillField('bundles[article]', TRUE);
'bundles[article]' => TRUE, $page->fillField('languages[en]', TRUE);
'languages[en]' => TRUE, $page->fillField('label', 'English articles');
]; $this->assertSession()->waitForElementVisible('css', '#edit-label-machine-name-suffix .machine-name-value');
$this->drupalPostForm(NULL, $edit, 'Save'); $page->pressButton('Save');
$this->assertText('Pattern English articles saved.'); $this->assertSession()->pageTextContains('Pattern English articles saved.');
// Create a pattern for French articles. // Create a pattern for French articles.
$this->drupalGet('admin/config/search/path/patterns/add'); $this->drupalGet('admin/config/search/path/patterns/add');
$edit = [
'type' => 'canonical_entities:node', $page->fillField('type', 'canonical_entities:node');
]; $this->assertSession()->assertWaitOnAjaxRequest();
$this->drupalPostAjaxForm(NULL, $edit, 'type');
$edit += [ $page->fillField('pattern', '/les-articles/[node:title]');
'pattern' => '/les-articles/[node:title]', $page->fillField('bundles[article]', TRUE);
'label' => 'French articles', $page->fillField('languages[fr]', TRUE);
'id' => 'french_articles', $page->fillField('label', 'French articles');
'bundles[article]' => TRUE, $this->assertSession()->waitForElementVisible('css', '#edit-label-machine-name-suffix .machine-name-value');
'languages[fr]' => TRUE, $page->pressButton('Save');
]; $this->assertSession()->pageTextContains('Pattern French articles saved.');
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('Pattern French articles saved.');
// Create a node and its translation. Assert aliases. // Create a node and its translation. Assert aliases.
$edit = [ $edit = [
...@@ -171,7 +170,7 @@ class PathautoLocaleTest extends WebTestBase { ...@@ -171,7 +170,7 @@ class PathautoLocaleTest extends WebTestBase {
'update[canonical_entities:node]' => TRUE, 'update[canonical_entities:node]' => TRUE,
]; ];
$this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update')); $this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this->assertText(t('Generated 2 URL aliases.')); $this->assertSession()->pageTextContains(t('Generated 2 URL aliases.'));
$this->assertAlias('/node/' . $english_node->id(), '/the-articles/english-node', 'en'); $this->assertAlias('/node/' . $english_node->id(), '/the-articles/english-node', 'en');
$this->assertAlias('/node/' . $french_node->id(), '/les-articles/french-node', 'fr'); $this->assertAlias('/node/' . $french_node->id(), '/les-articles/french-node', 'fr');
} }
...@@ -196,7 +195,7 @@ class PathautoLocaleTest extends WebTestBase { ...@@ -196,7 +195,7 @@ class PathautoLocaleTest extends WebTestBase {
// Check that the alias works. // Check that the alias works.
$this->drupalGet('content/test-node'); $this->drupalGet('content/test-node');
$this->assertResponse(200); $this->assertSession()->pageTextContains(t('Test node'));
} }
/** /**
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\Tests\pathauto\FunctionalJavascript;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\pathauto\Entity\PathautoPattern; use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\Tests\pathauto\Functional\PathautoTestHelperTrait;
/** /**
* Test basic pathauto functionality. * Test basic pathauto functionality.
* *
* @group pathauto * @group pathauto
*/ */
class PathautoUiTest extends WebTestBase { class PathautoUiTest extends WebDriverTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
...@@ -52,73 +53,56 @@ class PathautoUiTest extends WebTestBase { ...@@ -52,73 +53,56 @@ class PathautoUiTest extends WebTestBase {
} }
function testSettingsValidation() { function testSettingsValidation() {
$edit = []; $this->drupalGet('/admin/config/search/path/settings');
$edit['max_length'] = 'abc';
$edit['max_component_length'] = 'abc'; $this->assertSession()->fieldExists('max_length');
$this->drupalPostForm('admin/config/search/path/settings', $edit, 'Save configuration'); $this->assertSession()->elementAttributeContains('css', '#edit-max-length', 'min', '1');
/*$this->assertText('The field Maximum alias length is not a valid number.');
$this->assertText('The field Maximum component length is not a valid number.');*/ $this->assertSession()->fieldExists('max_component_length');
$this->assertNoText('The configuration options have been saved.'); $this->assertSession()->elementAttributeContains('css', '#edit-max-component-length', 'min', '1');
$edit['max_length'] = '0';
$edit['max_component_length'] = '0';
$this->drupalPostForm('admin/config/search/path/settings', $edit, 'Save configuration');
/*$this->assertText('The field Maximum alias length cannot be less than 1.');
$this->assertText('The field Maximum component length cannot be less than 1.');*/
$this->assertNoText('The configuration options have been saved.');
$edit['max_length'] = '999';
$edit['max_component_length'] = '999';
$this->drupalPostForm('admin/config/search/path/settings', $edit, 'Save configuration');
/*$this->assertText('The field Maximum alias length cannot be greater than 255.');
$this->assertText('The field Maximum component length cannot be greater than 255.');*/
$this->assertNoText('The configuration options have been saved.');
$edit['max_length'] = '50';
$edit['max_component_length'] = '50';
$this->drupalPostForm('admin/config/search/path/settings', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.');
} }
function testPatternsWorkflow() { function testPatternsWorkflow() {
// Try to save an empty pattern, should not be allowed.
$this->drupalGet('admin/config/search/path/patterns/add'); $this->drupalGet('admin/config/search/path/patterns/add');
$session = $this->getSession();
$session->getPage()->fillField('type', 'canonical_entities:node');
$this->assertSession()->assertWaitOnAjaxRequest();
$edit = [ $edit = [
'type' => 'canonical_entities:node', 'type' => 'canonical_entities:node',
];
$this->drupalPostAjaxForm(NULL, $edit, 'type');
$edit += [
'bundles[page]' => TRUE, 'bundles[page]' => TRUE,
'label' => 'Page pattern', 'label' => 'Page pattern',
'id' => 'page_pattern', 'pattern' => '[node:title]/[user:name]/[term:name]',
]; ];
$this->drupalPostForm(NULL, $edit, 'Save'); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('Path pattern field is required.');
$this->assertNoText('The configuration options have been saved.');
// Try to save an invalid pattern. $this->assertSession()->waitForElementVisible('css', '[name="id"]');
$edit += [ $edit += [
'pattern' => '[node:title]/[user:name]/[term:name]', 'id' => 'page_pattern',
]; ];
$this->drupalPostForm(NULL, $edit, 'Save'); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('Path pattern is using the following invalid tokens: [user:name], [term:name].');
$this->assertNoText('The configuration options have been saved.');
$this->assertSession()->pageTextContains('Path pattern is using the following invalid tokens: [user:name], [term:name].');
$this->assertSession()->pageTextNotContains('The configuration options have been saved.');
// We do not need ID anymore, it is already set in previous step and made a label by browser
unset($edit['id']);
$edit['pattern'] = '#[node:title]'; $edit['pattern'] = '#[node:title]';
$this->drupalPostForm(NULL, $edit, 'Save'); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('The Path pattern is using the following invalid characters: #.'); $this->assertSession()->pageTextContains('The Path pattern is using the following invalid characters: #.');
$this->assertNoText('The configuration options have been saved.'); $this->assertSession()->pageTextNotContains('The configuration options have been saved.');
// Checking whitespace ending of the string. // Checking whitespace ending of the string.
$edit['pattern'] = '[node:title] '; $edit['pattern'] = '[node:title] ';
$this->drupalPostForm(NULL, $edit, 'Save'); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('The Path pattern doesn\'t allow the patterns ending with whitespace.'); $this->assertSession()->pageTextContains('The Path pattern doesn\'t allow the patterns ending with whitespace.');
$this->assertNoText('The configuration options have been saved.'); $this->assertSession()->pageTextNotContains('The configuration options have been saved.');
// Fix the pattern, then check that it gets saved successfully. // Fix the pattern, then check that it gets saved successfully.
$edit['pattern'] = '[node:title]'; $edit['pattern'] = '[node:title]';
$this->drupalPostForm(NULL, $edit, 'Save'); $this->drupalPostForm(NULL, $edit, 'Save');
$this->assertText('Pattern Page pattern saved.'); $this->assertSession()->pageTextContains('Pattern Page pattern saved.');
\Drupal::service('pathauto.generator')->resetCaches(); \Drupal::service('pathauto.generator')->resetCaches();
...@@ -127,11 +111,15 @@ class PathautoUiTest extends WebTestBase { ...@@ -127,11 +111,15 @@ class PathautoUiTest extends WebTestBase {
$alias = '/page-pattern-enabled'; $alias = '/page-pattern-enabled';
$node = $this->createNode(['title' => $title, 'type' => 'page']); $node = $this->createNode(['title' => $title, 'type' => 'page']);
$this->drupalGet($alias); $this->drupalGet($alias);
$this->assertResponse(200); $this->assertSession()->pageTextContains($title);
$this->assertEntityAlias($node, $alias); $this->assertEntityAlias($node, $alias);
// Edit workflow, set a new label and weight for the pattern. // Edit workflow, set a new label and weight for the pattern.
$this->drupalPostForm('/admin/config/search/path/patterns', ['entities[page_pattern][weight]' => '4'], t('Save')); $this->drupalGet('/admin/config/search/path/patterns');
$session->getPage()->pressButton('Show row weights');
$this->drupalPostForm(NULL, ['entities[page_pattern][weight]' => '4'], t('Save'));
$session->getPage()->find('css', '.dropbutton-toggle > button')->press();
$this->clickLink(t('Edit')); $this->clickLink(t('Edit'));
$destination_query = ['query' => ['destination' => Url::fromRoute('entity.pathauto_pattern.collection')->toString()]]; $destination_query = ['query' => ['destination' => Url::fromRoute('entity.pathauto_pattern.collection')->toString()]];
$this->assertUrl('/admin/config/search/path/patterns/page_pattern', $destination_query); $this->assertUrl('/admin/config/search/path/patterns/page_pattern', $destination_query);
...@@ -142,22 +130,26 @@ class PathautoUiTest extends WebTestBase { ...@@ -142,22 +130,26 @@ class PathautoUiTest extends WebTestBase {
$edit = ['label' => 'Test']; $edit = ['label' => 'Test'];
$this->drupalPostForm('/admin/config/search/path/patterns/page_pattern', $edit, t('Save')); $this->drupalPostForm('/admin/config/search/path/patterns/page_pattern', $edit, t('Save'));
$this->assertText('Pattern Test saved.'); $this->assertSession()->pageTextContains('Pattern Test saved.');
// Check that the pattern weight did not change. // Check that the pattern weight did not change.
$this->assertOptionSelected('edit-entities-page-pattern-weight', '4'); $this->assertOptionSelected('edit-entities-page-pattern-weight', '4');
$this->drupalGet('/admin/config/search/path/patterns/page_pattern/duplicate');
$session->getPage()->pressButton('Edit');
$edit = array('label' => 'Test Duplicate', 'id' => 'page_pattern_test_duplicate'); $edit = array('label' => 'Test Duplicate', 'id' => 'page_pattern_test_duplicate');
$this->drupalPostForm('/admin/config/search/path/patterns/page_pattern/duplicate', $edit, t('Save')); $this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText('Pattern Test Duplicate saved.'); $this->assertSession()->pageTextContains('Pattern Test Duplicate saved.');
PathautoPattern::load('page_pattern_test_duplicate')->delete(); PathautoPattern::load('page_pattern_test_duplicate')->delete();
// Disable workflow. // Disable workflow.
$this->drupalGet('/admin/config/search/path/patterns'); $this->drupalGet('/admin/config/search/path/patterns');
$session->getPage()->find('css', '.dropbutton-toggle > button')->press();
$this->assertNoLink(t('Enable')); $this->assertNoLink(t('Enable'));
$this->clickLink(t('Disable')); $this->clickLink(t('Disable'));
$this->assertUrl('/admin/config/search/path/patterns/page_pattern/disable', $destination_query); $this->assertUrl('/admin/config/search/path/patterns/page_pattern/disable', $destination_query);
$this->drupalPostForm(NULL, [], t('Disable')); $this->drupalPostForm(NULL, [], t('Disable'));
$this->assertText('Disabled pattern Test.'); $this->assertSession()->pageTextContains('Disabled pattern Test.');
// Load the pattern from storage and check if its disabled. // Load the pattern from storage and check if its disabled.
$pattern = PathautoPattern::load('page_pattern'); $pattern = PathautoPattern::load('page_pattern');
...@@ -176,7 +168,7 @@ class PathautoUiTest extends WebTestBase { ...@@ -176,7 +168,7 @@ class PathautoUiTest extends WebTestBase {
$this->clickLink(t('Enable')); $this->clickLink(t('Enable'));
$this->assertUrl('/admin/config/search/path/patterns/page_pattern/enable', $destination_query); $this->assertUrl('/admin/config/search/path/patterns/page_pattern/enable', $destination_query);
$this->drupalPostForm(NULL, [], t('Enable')); $this->drupalPostForm(NULL, [], t('Enable'));
$this->assertText('Enabled pattern Test.'); $this->assertSession()->pageTextContains('Enabled pattern Test.');
// Reload pattern from storage and check if its enabled. // Reload pattern from storage and check if its enabled.
$pattern = PathautoPattern::load('page_pattern'); $pattern = PathautoPattern::load('page_pattern');
...@@ -184,11 +176,12 @@ class PathautoUiTest extends WebTestBase { ...@@ -184,11 +176,12 @@ class PathautoUiTest extends WebTestBase {
// Delete workflow. // Delete workflow.
$this->drupalGet('/admin/config/search/path/patterns'); $this->drupalGet('/admin/config/search/path/patterns');
$session->getPage()->find('css', '.dropbutton-toggle > button')->press();
$this->clickLink(t('Delete')); $this->clickLink(t('Delete'));
$this->assertUrl('/admin/config/search/path/patterns/page_pattern/delete', $destination_query); $this->assertUrl('/admin/config/search/path/patterns/page_pattern/delete', $destination_query);
$this->assertText(t('This action cannot be undone.')); $this->assertSession()->pageTextContains(t('This action cannot be undone.'));
$this->drupalPostForm(NULL, [], t('Delete')); $this->drupalPostForm(NULL, [], t('Delete'));
$this->assertText('The pathauto pattern Test has been deleted.'); $this->assertSession()->pageTextContains('The pathauto pattern Test has been deleted.');
$this->assertFalse(PathautoPattern::load('page_pattern')); $this->assertFalse(PathautoPattern::load('page_pattern'));
} }
......
...@@ -7,7 +7,7 @@ use Drupal\Component\Utility\Crypt; ...@@ -7,7 +7,7 @@ use Drupal\Component\Utility\Crypt;
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\KeyValueStore\KeyValueDatabaseFactory; use Drupal\Core\KeyValueStore\KeyValueDatabaseFactory;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\pathauto\Tests\PathautoTestHelperTrait; use Drupal\Tests\pathauto\Functional\PathautoTestHelperTrait;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\pathauto_string_id_test\Entity\PathautoStringIdTest; use Drupal\pathauto_string_id_test\Entity\PathautoStringIdTest;
......
...@@ -11,7 +11,7 @@ use Drupal\field\Entity\FieldStorageConfig; ...@@ -11,7 +11,7 @@ use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
use Drupal\pathauto\PathautoGeneratorInterface; use Drupal\pathauto\PathautoGeneratorInterface;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
use Drupal\pathauto\Tests\PathautoTestHelperTrait; use Drupal\Tests\pathauto\Functional\PathautoTestHelperTrait;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary; use Drupal\taxonomy\Entity\Vocabulary;
...@@ -72,7 +72,7 @@ class PathautoKernelTest extends KernelTestBase { ...@@ -72,7 +72,7 @@ class PathautoKernelTest extends KernelTestBase {
* Test _pathauto_get_schema_alias_maxlength(). * Test _pathauto_get_schema_alias_maxlength().
*/ */
public function testGetSchemaAliasMaxLength() { public function testGetSchemaAliasMaxLength() {
$this->assertIdentical(\Drupal::service('pathauto.alias_storage_helper')->getAliasSchemaMaxlength(), 255); $this->assertSame(\Drupal::service('pathauto.alias_storage_helper')->getAliasSchemaMaxlength(), 255);
} }
/** /**
...@@ -153,7 +153,7 @@ class PathautoKernelTest extends KernelTestBase { ...@@ -153,7 +153,7 @@ class PathautoKernelTest extends KernelTestBase {
$entity = \Drupal::entityTypeManager()->getStorage($test['entity'])->create($test['values']); $entity = \Drupal::entityTypeManager()->getStorage($test['entity'])->create($test['values']);
$entity->save(); $entity->save();
$actual = \Drupal::service('pathauto.generator')->getPatternByEntity($entity); $actual = \Drupal::service('pathauto.generator')->getPatternByEntity($entity);
$this->assertIdentical($actual->getPattern(), $test['expected'], t("Correct pattern returned for @entity_type with @values", [ $this->assertSame($actual->getPattern(), $test['expected'], t("Correct pattern returned for @entity_type with @values", [
'@entity' => $test['entity'], '@entity' => $test['entity'],
'@values' => print_r($test['values'], TRUE), '@values' => print_r($test['values'], TRUE),
])); ]));
...@@ -215,7 +215,7 @@ class PathautoKernelTest extends KernelTestBase { ...@@ -215,7 +215,7 @@ class PathautoKernelTest extends KernelTestBase {