Skip to content
Snippets Groups Projects

fix php-unit

Merged Jean-Philippe Déis Nuel requested to merge s1933/fix-phpunit into 1.x
4 files
+ 46
109
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -2,15 +2,16 @@
namespace Drupal\Tests\domain_unique_path_alias\Functional;
use Drupal\domain_access\DomainAccessManagerInterface;
use Drupal\domain_source\DomainSourceElementManagerInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\domain\Functional\DomainTestBase;
/**
* Tests path alias on different domains.
*
* @group domain_unique_path_alias
*/
class DomainUniquePathAliasTest extends BrowserTestBase {
class DomainUniquePathAliasTest extends DomainTestBase {
/**
* {@inheritdoc}
@@ -22,6 +23,8 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
*/
protected static $modules = [
'domain',
'domain_access',
'domain_source',
'field',
'node',
'path_alias',
@@ -35,10 +38,11 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
parent::setUp();
// Create 2 domains.
$this->createDomainRecord('example.com', 'domain');
$this->createDomainRecord('example.com', 'domain1');
DomainTestBase::domainCreateTestDomains(2, 'example.com', [
'domain',
'domain1',
]);
// Load domain records.
$domains = \Drupal::entityTypeManager()->getStorage('domain')->loadMultiple();
// Create an article on example_com domain.
@@ -47,6 +51,9 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
'path' => [
'alias' => '/contact',
],
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
$domains['example_com']->id(),
],
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
$domains['example_com']->id(),
],
@@ -58,6 +65,9 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
'path' => [
'alias' => '/contact-bis',
],
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
$domains['example_com']->id(),
],
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
$domains['example_com']->id(),
],
@@ -69,26 +79,15 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
'path' => [
'alias' => '/contact',
],
DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD => [
$domains['domain1_example_com']->id(),
],
DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD => [
$domains['domain1_example_com']->id(),
],
]);
}
/**
* {@inheritdoc}
*/
private function createDomainRecord($hostname, $name) {
// Create a new domain programmatically.
$values = [
'hostname' => $hostname,
'name' => $name,
'id' => \Drupal::entityTypeManager()->getStorage('domain')->createMachineName($name . $hostname),
];
$domain = \Drupal::entityTypeManager()->getStorage('domain')->create($values);
$domain->save();
}
/**
* Creates a node and tests the creation of node access rules.
*/
@@ -96,11 +95,11 @@ class DomainUniquePathAliasTest extends BrowserTestBase {
$this->drupalLogin($this->rootUser);
$this->drupalGet('admin/content');
$this->assertSession()->responseContains('<a href="http://example.com/contact" hreflang="en">');
$this->assertSession()->responseContains('<a href="http://example.com/contact-bis" hreflang="en">');
$this->assertSession()->responseContains('<a href="http://domain1.example.com/contact" hreflang="en">');
$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 domain (example_com).';
$constraint_message = 'The alias /contact is already in use in this language.';
$edit = [
'path[0][alias]' => '/contact-bis-bis',
Loading