default services conflit ?

This commit is contained in:
armansansd
2022-04-27 11:30:43 +02:00
parent 28190a5749
commit 8bb1064a3b
8132 changed files with 900138 additions and 426 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Drupal\Tests\{{ machine_name }}\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Test description.
*
* @group {{ machine_name }}
*/
class {{ class }} extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stable';
/**
* {@inheritdoc}
*/
public static $modules = ['{{ machine_name }}'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Set up the test here.
}
/**
* Test callback.
*/
public function testSomething() {
$admin_user = $this->drupalCreateUser(['access administration pages']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin');
$this->assertSession()->elementExists('xpath', '//h1[text() = "Administration"]');
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Drupal\Tests\{{ machine_name }}\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Test description.
*
* @group {{ machine_name }}
*/
class {{ class }} extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['{{ machine_name }}'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Mock required services here.
}
/**
* Test callback.
*/
public function testSomething() {
$result = $this->container->get('transliteration')->transliterate('Друпал');
$this->assertEquals('Drupal', $result);
}
}

View File

@@ -0,0 +1,16 @@
module.exports = {
'@tags': ['{{ machine_name }}'],
before(browser) {
browser.drupalInstall();
},
after(browser) {
browser.drupalUninstall();
},
'Front page': browser => {
browser
.drupalRelativeURL('/')
.waitForElementVisible('body', 1000)
.assert.containsText('h1', 'Log in')
.drupalLogAndEnd({onlyOnError: false});
},
};

View File

@@ -0,0 +1,29 @@
<?php
namespace Drupal\Tests\{{ machine_name }}\Unit;
use Drupal\Tests\UnitTestCase;
/**
* Test description.
*
* @group {{ machine_name }}
*/
class {{ class }} extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// @TODO: Mock required classes here.
}
/**
* Tests something.
*/
public function testSomething() {
$this->assertTrue(TRUE, 'This is TRUE!');
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Drupal\{{ machine_name }}\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests site configuration.
*
* @group {{ machine_name }}
*/
class {{ class }} extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'node',
'field',
'contact',
'views',
'taxonomy',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($user);
}
/**
* Test site information form.
*/
public function testFieldStorageSettingsForm() {
$edit = [
'site_name' => 'Drupal',
'site_slogan' => 'Community plumbing',
'site_mail' => 'admin@example.local',
'site_frontpage' => '/user',
];
$this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration');
$this->assertText('The configuration options have been saved.', 'Configuration options have been saved');
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Drupal\Tests\{{ machine_name }}\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the JavaScript functionality of the {{ name }} module.
*
* @group {{ machine_name }}
*/
class {{ class }} extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stable';
/**
* {@inheritdoc}
*/
public static $modules = ['{{ machine_name }}'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Set up the test here.
}
/**
* Test callback.
*/
public function testSomething() {
// Let's test password strength widget.
\Drupal::configFactory()->getEditable('user.settings')
->set('verify_mail', FALSE)
->save();
$this->drupalGet('user/register');
$page = $this->getSession()->getPage();
$password_field = $page->findField('Password');
$password_strength = $page->find('css', '.js-password-strength__text');
$this->assertEquals('', $password_strength->getText());
$password_field->setValue('abc');
$this->assertEquals('Weak', $password_strength->getText());
$password_field->setValue('abcABC123!');
$this->assertEquals('Fair', $password_strength->getText());
$password_field->setValue('abcABC123!sss');
$this->assertEquals('Strong', $password_strength->getText());
}
}