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
+ 95
33
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,29 +2,34 @@
namespace Drupal\Tests\domain_unique_path_alias\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
use Drupal\domain_access\DomainAccessManagerInterface;
use Drupal\domain_source\DomainSourceElementManagerInterface;
use Drupal\Tests\domain\Functional\DomainTestBase;
/**
* 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}
*/
protected static $modules = [
'node',
];
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
protected static $modules = [
'domain',
'domain_access',
'domain_source',
'field',
'node',
'path_alias',
'pathauto',
];
/**
* {@inheritdoc}
@@ -32,36 +37,83 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
protected function setUp(): void {
parent::setUp();
// Create the "Basic page" node type.
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
// Create 2 domains.
DomainTestBase::domainCreateTestDomains(2, 'example.com', [
'domain',
'domain1',
]);
// Create some languages.
ConfigurableLanguage::create(['id' => 'fr'])->save();
ConfigurableLanguage::create(['id' => 'it'])->save();
$domains = \Drupal::entityTypeManager()->getStorage('domain')->loadMultiple();
// Create the address field on the "Basic page" node type.
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_address',
'entity_type' => 'node',
'type' => 'address',
// 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(),
],
]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
'label' => 'Address',
// 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(),
],
]);
$field->save();
}
/**
* Tests synced address fields on translated nodes.
* Creates a node and tests the creation of node access rules.
*/
public function testSyncedAddressFields() {
$user = $this->drupalCreateUser([], NULL, TRUE);
public function testDomainUniquePathAlias() {
$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