Skip to content
Snippets Groups Projects
Commit 71325752 authored by Adam Bramley's avatar Adam Bramley Committed by Adam Bramley
Browse files

Issue #3350607 by mcaddz, acbramley: Add Script form broken on Drupal 10

parent 030d9c8b
No related branches found
No related tags found
No related merge requests found
......@@ -88,14 +88,14 @@ class Script extends ConfigEntityBase implements ScriptInterface, EntityWithPlug
* {@inheritdoc}
*/
public function getSnippet(): string {
return $this->snippet;
return $this->snippet ?? '';
}
/**
* {@inheritdoc}
*/
public function getPosition(): string {
return $this->position;
return $this->position ?? '';
}
/**
......
<?php
declare(strict_types = 1);
namespace Drupal\Tests\script_manager\Functional;
use Drupal\Core\Url;
use Drupal\script_manager\Entity\Script;
use Drupal\script_manager\Entity\ScriptInterface;
use Drupal\Tests\BrowserTestBase;
/**
* Test the script manager admin UI.
*
* @group script_manager
*/
final class ScriptManagerAdminTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'script_manager',
'block',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalPlaceBlock('local_actions_block');
}
/**
* Test the admin UI.
*/
public function testAdminUi(): void {
$this->drupalLogin($this->drupalCreateUser([
'administer scripts',
]));
$collectionUrl = Url::fromRoute('entity.script.collection');
$this->drupalGet($collectionUrl);
$assert = $this->assertSession();
$assert->statusCodeEquals(200);
$assert->pageTextContains('There are no script entities yet');
$assert->linkExists('Add Script');
$this->clickLink('Add Script');
$assert->statusCodeEquals(200);
$this->submitForm([
'label' => 'Foo',
'id' => 'foo',
'position' => ScriptInterface::POSITION_TOP,
'snippet' => 'bar',
], 'Save');
$script = Script::load('foo');
$assert->addressEquals($collectionUrl->toString());
$assert->pageTextContains('Foo');
$assert->linkByHrefExists($script->toUrl('edit-form')->toString());
$assert->linkByHrefExists($script->toUrl('delete-form')->toString());
$this->clickLink('Edit');
$assert->fieldValueEquals('label', 'Foo');
$assert->fieldValueEquals('position', ScriptInterface::POSITION_TOP);
$assert->fieldValueEquals('snippet', 'bar');
$this->drupalGet($script->toUrl('delete-form'));
$this->submitForm([], 'Delete');
$assert->pageTextContains('The script Foo has been deleted.');
$assert->pageTextContains('There are no script entities yet');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment