PrefilledOptionTest.php in Automatic Entity Label 8.3
File
tests/src/Functional/PrefilledOptionTest.php
View source
<?php
namespace Drupal\Tests\auto_entitylabel\Functional;
use Drupal\auto_entitylabel\AutoEntityLabelManager;
use Drupal\Tests\BrowserTestBase;
class PrefilledOptionTest extends BrowserTestBase {
protected $nodeType;
protected $configFactory;
protected $user;
public static $modules = [
'system',
'user',
'node',
'filter',
'token',
'auto_entitylabel',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this->user = $this
->drupalCreateUser([], '', TRUE);
$this
->drupalLogin($this->user);
$this->nodeType = $this
->createContentType([
'type' => 'page',
]);
$this->configFactory = $this->container
->get('config.factory');
}
public function testPrefilledOption() {
$webAssert = $this
->assertSession();
$this->configFactory
->getEditable("auto_entitylabel.settings.node.{$this->nodeType->id()}")
->set('status', AutoEntityLabelManager::PREFILLED)
->set('pattern', 'Test node [current-user:account-name]')
->save();
$this
->drupalGet('/node/add/page');
$webAssert
->fieldExists('Title');
$webAssert
->fieldValueEquals('Title', 'Test node ' . $this->user
->getAccountName());
}
}