Skip to content
Snippets Groups Projects

fix php-unit

Merged Jean-Philippe Déis Nuel requested to merge s1933/fix-phpunit into 1.x
3 files
+ 97
27
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,34 +2,34 @@
@@ -2,34 +2,34 @@
namespace Drupal\Tests\domain_unique_path_alias\Functional;
namespace Drupal\Tests\domain_unique_path_alias\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\domain_access\DomainAccessManagerInterface;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\domain_source\DomainSourceElementManagerInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\domain\Functional\DomainTestBase;
use Drupal\Tests\BrowserTestBase;
/**
/**
* Tests the Address field translatability.
* Tests path alias on different domains.
*
*
* @group domain
* @group domain_unique_path_alias
*/
*/
class DomainUniquePathAliasTest extends BrowserTestBase {
class DomainUniquePathAliasTest extends DomainTestBase {
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
protected static $modules = [
protected $defaultTheme = 'stark';
'domain_unique_path_alias',
'node',
'user',
'language',
'content_translation',
'field_ui',
];
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
protected $defaultTheme = 'stark';
protected static $modules = [
 
'domain',
 
'domain_access',
 
'domain_source',
 
'field',
 
'node',
 
'path_alias',
 
'pathauto',
 
];
/**
/**
* {@inheritdoc}
* {@inheritdoc}
@@ -37,23 +37,83 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
@@ -37,23 +37,83 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
protected function setUp(): void {
protected function setUp(): void {
parent::setUp();
parent::setUp();
// Create the "Basic page" node type.
// Create 2 domains.
$this->drupalCreateContentType([
DomainTestBase::domainCreateTestDomains(2, 'example.com', [
'type' => 'page',
'domain',
'name' => 'Basic page',
'domain1',
]);
]);
// Create some languages.
$domains = \Drupal::entityTypeManager()->getStorage('domain')->loadMultiple();
ConfigurableLanguage::create(['id' => 'fr'])->save();
ConfigurableLanguage::create(['id' => 'it'])->save();
 
// Create an article on example_com domain.
 
$this->drupalCreateNode([
 
'type' => 'article',
 
'path' => [
 
'alias' => '/contact',
 
],
 
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
 
$domains['example_com']->id(),
 
],
 
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
 
$domains['example_com']->id(),
 
],
 
]);
 
 
// Create an article on example_com domain.
 
$this->drupalCreateNode([
 
'type' => 'article',
 
'path' => [
 
'alias' => '/contact-bis',
 
],
 
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
 
$domains['example_com']->id(),
 
],
 
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
 
$domains['example_com']->id(),
 
],
 
]);
 
 
// Create an article on domain1_example_com domain.
 
$this->drupalCreateNode([
 
'type' => 'article',
 
'path' => [
 
'alias' => '/contact',
 
],
 
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
 
$domains['domain1_example_com']->id(),
 
],
 
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
 
$domains['domain1_example_com']->id(),
 
],
 
]);
}
}
/**
/**
* Tests synced address fields on translated nodes.
* Creates a node and tests the creation of node access rules.
*/
*/
public function testSyncedAddressFields() {
public function testDomainUniquePathAlias() {
$this->drupalCreateUser([], NULL, TRUE);
$this->drupalLogin($this->rootUser);
 
 
$this->drupalGet('admin/content');
 
$this->assertSession()->responseContains('<a href="http://example.com/web/contact" hreflang="en">');
 
$this->assertSession()->responseContains('<a href="http://example.com/web/contact-bis" hreflang="en">');
 
$this->assertSession()->responseContains('<a href="http://domain1.example.com/web/contact" hreflang="en">');
 
 
$constraint_message = 'The alias /contact is already in use in this language.';
 
 
$edit = [
 
'path[0][alias]' => '/contact-bis-bis',
 
];
 
$this->drupalGet('node/2/edit');
 
$this->submitForm($edit, 'Save');
 
$this->assertSession()->pageTextNotContains($constraint_message);
 
 
$edit = [
 
'path[0][alias]' => '/contact',
 
];
 
$this->drupalGet('node/2/edit');
 
$this->submitForm($edit, 'Save');
 
$this->assertSession()->pageTextContains($constraint_message);
}
}
}
}
Loading