MenuLinkContentFormTest.php in Zircon Profile 8
File
core/modules/menu_link_content/src/Tests/MenuLinkContentFormTest.php
View source
<?php
namespace Drupal\menu_link_content\Tests;
use Drupal\simpletest\WebTestBase;
class MenuLinkContentFormTest extends WebTestBase {
public static $modules = array(
'menu_link_content',
);
protected function setUp() {
parent::setUp();
$web_user = $this
->drupalCreateUser(array(
'administer menu',
));
$this
->drupalLogin($web_user);
}
public function testMenuLinkContentForm() {
$this
->drupalGet('admin/structure/menu/manage/admin/add');
$element = $this
->xpath('//select[@id = :id]/option[@selected]', array(
':id' => 'edit-menu-parent',
));
$this
->assertTrue($element, 'A default menu parent was found.');
$this
->assertEqual('admin:', $element[0]['value'], '<Administration> menu is the parent.');
$this
->drupalPostForm(NULL, array(
'title[0][value]' => t('Front page'),
'link[0][uri]' => '<front>',
), t('Save'));
$this
->assertText(t('The menu link has been saved.'));
}
public function testMenuLinkContentFormValidation() {
$this
->drupalGet('admin/structure/menu/manage/admin/add');
$this
->drupalPostForm(NULL, array(
'title[0][value]' => t('Test page'),
'link[0][uri]' => '<test>',
), t('Save'));
$this
->assertText(t('Manually entered paths should start with /, ? or #.'));
}
}