Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713

This commit is contained in:
Pantheon Automation 2016-05-04 14:35:41 -07:00 committed by Greg Anderson
parent c0a0d5a94c
commit 9eae24d844
669 changed files with 3873 additions and 1553 deletions

View file

@ -324,7 +324,7 @@ class DbUpdateController extends ControllerBase {
$text = $this->t('This update will been skipped due to the following missing dependencies:') . '<em>' . implode(', ', $data['missing_dependencies']) . '</em>';
}
else {
$text = $this->t("This update will be skipped due to an error in the module's code.");
$text = $this->t("This update will be skipped due to an error in the module's code.");
}
$build['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
}
@ -374,6 +374,7 @@ class DbUpdateController extends ControllerBase {
'#attributes' => array('class' => array('button', 'button--primary')),
'#weight' => 5,
'#url' => $url,
'#access' => $url->access($this->currentUser()),
);
}

View file

@ -91,7 +91,7 @@ abstract class DateFormatFormBase extends EntityForm {
'#default_value' => $this->entity->id(),
'#machine_name' => array(
'exists' => array($this, 'exists'),
'replace_pattern' =>'([^a-z0-9_]+)|(^custom$)',
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'error' => $this->t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'),
),
);

View file

@ -216,7 +216,7 @@ class ModulesListForm extends FormBase {
'#type' => 'link',
'#title' => $this->t('Help'),
'#url' => Url::fromRoute('help.page', ['name' => $module->getName()]),
'#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))),
'#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))),
);
}

View file

@ -143,7 +143,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
);
// List the dependent entities.
$this->addDependencyListsToForm($form, 'module', $this->modules , $this->configManager, $this->entityManager);
$this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityManager);
return parent::buildForm($form, $form_state);
}

View file

@ -182,7 +182,7 @@ class ModulesUninstallForm extends FormBase {
$account = $this->currentUser()->id();
// Store the values for 6 hours. This expiration time is also used in
// the form cache.
$this->keyValueExpirable->setWithExpire($account, $uninstall, 6*60*60);
$this->keyValueExpirable->setWithExpire($account, $uninstall, 6 * 60 * 60);
// Redirect to the confirm form.
$form_state->setRedirect('system.modules_uninstall_confirm');

View file

@ -109,7 +109,7 @@ class RegionalForm extends ConfigFormBase {
'#default_value' => $configurable_timezones,
);
$form['timezone']['configurable_timezones_wrapper'] = array(
$form['timezone']['configurable_timezones_wrapper'] = array(
'#type' => 'container',
'#states' => array(
// Hide the user configured timezone settings when users are forced to use

View file

@ -136,9 +136,9 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
// /user is just a redirect, so skip it.
// @todo Find a better way to deal with /user.
$exclude['/user'] = TRUE;
// Because this breadcrumb builder is entirely path-based, vary by the
// 'url.path' cache context.
$breadcrumb->addCacheContexts(['url.path']);
// Add the url.path.parent cache context. This code ignores the last path
// part so the result only depends on the path parents.
$breadcrumb->addCacheContexts(['url.path.parent']);
while (count($path_elements) > 1) {
array_pop($path_elements);
// Copy the path elements for up-casting.

View file

@ -147,7 +147,9 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
$request = $this->requestStack->getCurrentRequest();
// Compare the lowercase path alias (if any) and internal path.
$path = rtrim($this->currentPath->getPath($request), '/');
$path = $this->currentPath->getPath($request);
// Do not trim a trailing slash if that is the complete path.
$path = $path === '/' ? $path : rtrim($path, '/');
$path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path));
return $this->pathMatcher->matchPath($path_alias, $pages) || (($path != $path_alias) && $this->pathMatcher->matchPath($path, $pages));

View file

@ -2,6 +2,7 @@
namespace Drupal\system\Tests\Ajax;
use Drupal\ajax_test\Controller\AjaxTestController;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Url;
@ -29,7 +30,7 @@ class DialogTest extends AjaxTestBase {
$this->drupalGet('ajax-test/dialog');
// Set up variables for this test.
$dialog_renderable = \Drupal\ajax_test\Controller\AjaxTestController::dialogContents();
$dialog_renderable = AjaxTestController::dialogContents();
$dialog_contents = \Drupal::service('renderer')->renderRoot($dialog_renderable);
$modal_expected_response = array(
'command' => 'openDialog',

View file

@ -43,7 +43,7 @@ class MultiFormTest extends AjaxTestBase {
->setComponent($field_name, array('type' => 'text_textfield'))
->save();
// Login a user who can create 'page' nodes.
// Log in a user who can create 'page' nodes.
$this->drupalLogin ($this->drupalCreateUser(array('create page content')));
}
@ -88,7 +88,7 @@ class MultiFormTest extends AjaxTestBase {
$form = $this->xpath($form_xpath)[$offset];
$field = $form->xpath('.' . $field_xpath);
$this->assertEqual(count($field[0]->xpath('.' . $field_items_xpath_suffix)), $i+2, 'Found the correct number of field items after an AJAX submission.');
$this->assertEqual(count($field[0]->xpath('.' . $field_items_xpath_suffix)), $i + 2, 'Found the correct number of field items after an AJAX submission.');
$this->assertFieldsByValue($field[0]->xpath('.' . $button_xpath_suffix), NULL, 'Found the "add more" button after an AJAX submission.');
$this->assertNoDuplicateIds(t('Updated page contains unique IDs'), 'Other');
}

View file

@ -4,7 +4,7 @@ namespace Drupal\system\Tests\Asset;
use Drupal\Core\Asset\Exception\InvalidLibrariesExtendSpecificationException;
use Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the library discovery and library discovery parser.

View file

@ -89,7 +89,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
* @return \Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test.
*/
protected function getCacheBackend($bin = null) {
protected function getCacheBackend($bin = NULL) {
if (!isset($bin)) {
$bin = $this->getTestBin();
}

View file

@ -280,7 +280,7 @@ class AttachedAssetsTest extends KernelTestBase {
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
$rendered_js = $this->renderer->renderPlain($js_render_array);
$this->assertTrue(strpos($rendered_js, 'core/assets/vendor/backbone/backbone-min.js?v=1.2.3') > 0 && strpos($rendered_js, 'core/assets/vendor/domready/ready.min.js?v=1.0.8') > 0 , 'JavaScript version identifiers correctly appended to URLs');
$this->assertTrue(strpos($rendered_js, 'core/assets/vendor/backbone/backbone-min.js?v=1.2.3') > 0 && strpos($rendered_js, 'core/assets/vendor/domready/ready.min.js?v=1.0.8') > 0, 'JavaScript version identifiers correctly appended to URLs');
}
/**

View file

@ -31,7 +31,7 @@ class RenderWebTest extends WebTestBase {
$this->assertTitle('Test active link class | Drupal');
$this->assertCacheContext('url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT);
$this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
$this->drupalGet('common-test/type-link-active-class', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'json']]);
$this->assertIdentical('application/json', $this->drupalGetHeader('Content-Type'));
$json = Json::decode($this->getRawContent());
$this->assertEqual(['content', 'title'], array_keys($json));
@ -127,7 +127,7 @@ class RenderWebTest extends WebTestBase {
),
);
$this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(
':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(),
':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(),
':title' => $element['#title'],
));

View file

@ -327,7 +327,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$referencing_entity_url = $this->referencingEntity->urlInfo('canonical');
$non_referencing_entity_url = $this->nonReferencingEntity->urlInfo('canonical');
$listing_url = Url::fromRoute('entity.entity_test.collection_referencing_entities', [
'entity_reference_field_name' => $entity_type . '_reference',
'entity_reference_field_name' => $entity_type . '_reference',
'referenced_entity_type' => $entity_type,
'referenced_entity_id' => $this->entity->id(),
]);
@ -346,7 +346,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
$page_cache_tags = Cache::mergeTags(['rendered'], ['config:user.role.anonymous']);
// If the block module is used, the Block page display variant is used,
// which adds the block config entity type's list cache tags.
$page_cache_tags = Cache::mergeTags($page_cache_tags, \Drupal::moduleHandler()->moduleExists('block') ? ['config:block_list']: []);
$page_cache_tags = Cache::mergeTags($page_cache_tags, \Drupal::moduleHandler()->moduleExists('block') ? ['config:block_list'] : []);
$page_cache_tags_referencing_entity = in_array('user.permissions', $this->getAccessCacheContextsForEntity($this->referencingEntity)) ? ['config:user.role.anonymous'] : [];

View file

@ -24,7 +24,7 @@ class EntityListBuilderTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Create and login user.
// Create and log in user.
$this->webUser = $this->drupalCreateUser(array(
'administer entity_test content',
));

View file

@ -21,7 +21,7 @@ class EntityOperationsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Create and login user.
// Create and log in user.
$this->drupalLogin($this->drupalCreateUser(array('administer permissions')));
}

View file

@ -332,6 +332,25 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
),
);
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
// Check that the Anonymous user is not included in the results when no
// label matching is done, for example when using the 'options_select'
// widget.
$referenceable_tests = array(
array(
'arguments' => array(
array(NULL),
),
'result' => array(
'user' => array(
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
$users['blocked']->id() => $user_labels['blocked'],
),
),
),
);
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
}
/**

View file

@ -29,7 +29,7 @@ class EntityRevisionsTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Create and login user.
// Create and log in user.
$this->webUser = $this->drupalCreateUser(array(
'administer entity_test content',
'view test entity',

View file

@ -0,0 +1,33 @@
<?php
namespace Drupal\system\Tests\Installer;
use Drupal\simpletest\InstallerTestBase;
/**
* Tests the installer when a config_directory has already been set up.
*
* @group Installer
*/
class InstallerExistingConfigDirectoryTest extends InstallerTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) array(
'value' => $this->siteDirectory . '/config',
'required' => TRUE,
);
parent::setUp();
}
/**
* Verifies that installation succeeded.
*/
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertResponse(200);
}
}

View file

@ -4,7 +4,7 @@ namespace Drupal\system\Tests\KeyValueStore;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\entity_test\Entity\EntityTestLabel;
/**

View file

@ -26,7 +26,7 @@ class ClassLoaderTest extends WebTestBase {
\Drupal::service('module_installer')->install(array('module_test', 'module_autoload_test'), FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i=0; $i<2; $i++) {
for ($i = 0; $i < 2; $i++) {
$this->drupalGet('module-test/class-loading');
$this->assertText($this->expected, 'Autoloader loads classes from an enabled module.');
}
@ -42,7 +42,7 @@ class ClassLoaderTest extends WebTestBase {
$this->container->get('module_installer')->uninstall(array('module_autoload_test'), FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i=0; $i<2; $i++) {
for ($i = 0; $i < 2; $i++) {
$this->drupalGet('module-test/class-loading');
$this->assertNoText($this->expected, 'Autoloader does not load classes from a disabled module.');
}

View file

@ -127,5 +127,14 @@ class RequestPathTest extends KernelTestBase {
$this->assertFalse($condition->evaluate(), 'The system_path /my/pass/page4 fails for a missing path.');
// Test a path of '/'.
$this->aliasManager->addAlias('/', '/my/pass/page3');
$this->currentPath->setPath('/', $request);
$this->requestStack->pop();
$this->requestStack->push($request);
$this->assertTrue($condition->evaluate(), 'The system_path my/pass/page3 passes for wildcard paths.');
$this->assertEqual($condition->summary(), 'Return true on the following pages: /my/pass/*', 'The condition summary matches for a wildcard path');
}
}

View file

@ -82,4 +82,3 @@ abstract class DiscoveryTestBase extends KernelTestBase {
}
}

View file

@ -43,4 +43,3 @@ class StaticDiscoveryTest extends DiscoveryTestBase {
$this->emptyDiscovery = $discovery;
}
}

View file

@ -24,7 +24,7 @@ class AjaxPageStateTest extends WebTestBase {
$this->adminUser = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')
->getPermissions()));
// Login so there are more libraries to test with otherwise only html5shiv
// Log in so there are more libraries to test with otherwise only html5shiv
// is the only one in the source we can easily test for.
$this->drupalLogin($this->adminUser);
}

View file

@ -44,7 +44,7 @@ class MatcherDumperTest extends KernelTestBase {
*/
function testCreate() {
$connection = Database::getConnection();
$dumper= new MatcherDumper($connection, $this->state);
$dumper = new MatcherDumper($connection, $this->state);
$class_name = 'Drupal\Core\Routing\MatcherDumper';
$this->assertTrue($dumper instanceof $class_name, 'Dumper created successfully');
@ -55,7 +55,7 @@ class MatcherDumperTest extends KernelTestBase {
*/
function testAddRoutes() {
$connection = Database::getConnection();
$dumper= new MatcherDumper($connection, $this->state);
$dumper = new MatcherDumper($connection, $this->state);
$route = new Route('test');
$collection = new RouteCollection();
@ -76,7 +76,7 @@ class MatcherDumperTest extends KernelTestBase {
*/
function testAddAdditionalRoutes() {
$connection = Database::getConnection();
$dumper= new MatcherDumper($connection, $this->state);
$dumper = new MatcherDumper($connection, $this->state);
$route = new Route('test');
$collection = new RouteCollection();

View file

@ -76,6 +76,10 @@ class MockAliasManager implements AliasManagerInterface {
* @return
*/
public function getAliasByPath($path, $langcode = NULL) {
if ($path[0] !== '/') {
throw new \InvalidArgumentException(sprintf('Source path %s has to start with a slash.', $path));
}
$langcode = $langcode ?: $this->defaultLanguage;
$this->lookedUp[$path] = 1;
return $this->aliases[$path][$langcode];

View file

@ -50,7 +50,7 @@ class SessionTest extends WebTestBase {
$this->drupalGet('session-test/id');
$matches = array();
preg_match('/\s*session_id:(.*)\n/', $this->getRawContent(), $matches);
$this->assertTrue(!empty($matches[1]) , 'Found session ID before logging in.');
$this->assertTrue(!empty($matches[1]), 'Found session ID before logging in.');
$original_session = $matches[1];
// We cannot use $this->drupalLogin($user); because we exit in
@ -67,7 +67,7 @@ class SessionTest extends WebTestBase {
$this->drupalGet('session-test/id');
$matches = array();
preg_match('/\s*session_id:(.*)\n/', $this->getRawContent(), $matches);
$this->assertTrue(!empty($matches[1]) , 'Found session ID after logging in.');
$this->assertTrue(!empty($matches[1]), 'Found session ID after logging in.');
$this->assertTrue($matches[1] != $original_session, 'Session ID changed after login.');
}

View file

@ -56,7 +56,7 @@ class AccessDeniedTest extends WebTestBase {
'site_403' => 'user/' . $this->adminUser->id(),
];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_403']]));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_403']]));
// Use a custom 403 page.
$edit = [

View file

@ -19,13 +19,20 @@ class DateTimeTest extends WebTestBase {
*
* @var array
*/
public static $modules = ['block', 'node', 'language'];
public static $modules = ['block', 'node', 'language', 'field', 'field_ui', 'datetime', 'options'];
protected function setUp() {
parent::setUp();
// Create admin user and log in admin user.
$this->drupalLogin ($this->drupalCreateUser(array('administer site configuration')));
$this->drupalLogin ($this->drupalCreateUser(array(
'administer site configuration',
'administer content types',
'administer nodes',
'administer node fields',
'administer node form display',
'administer node display',
)));
$this->drupalPlaceBlock('local_actions_block');
}
@ -157,4 +164,64 @@ class DateTimeTest extends WebTestBase {
$this->assertEscaped('<em>' . date("Y") . '</em>');
}
/**
* Test handling case with invalid data in selectors (like February, 31st).
*/
function testEnteringDateTimeViaSelectors() {
$this->drupalCreateContentType(array('type' => 'page_with_date', 'name' => 'Page with date'));
$this->drupalGet('admin/structure/types/manage/page_with_date');
$this->assertResponse(200, 'Content type created.');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/add-field');
$edit = array(
'new_storage_type' => 'datetime',
'label' => 'dt',
'field_name' => 'dt',
);
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/add-field', $edit, t('Save and continue'));
$this->assertText(t('These settings apply to the'), 'New datetime field created, now configuring');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage');
$edit = array(
'settings[datetime_type]' => 'datetime',
'cardinality' => 'number',
'cardinality_number' => '1',
);
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage', $edit, t('Save field settings'));
$this->drupalGet('admin/structure/types/manage/page_with_date/fields');
$this->assertText('field_dt', 'New field is in place');
$this->drupalGet('admin/structure/types/manage/page_with_date/form-display');
$edit = array(
'fields[field_dt][type]' => 'datetime_datelist',
);
$this->drupalPostForm('admin/structure/types/manage/page_with_date/form-display', $edit, t('Save'));
$this->drupalLogout();
// Now log in as a regular editor.
$this->drupalLogin($this->drupalCreateUser(array('create page_with_date content')));
$this->drupalGet('node/add/page_with_date');
$edit = array(
'title[0][value]' => 'sample doc',
'field_dt[0][value][year]' => '2016',
'field_dt[0][value][month]' => '2',
'field_dt[0][value][day]' => '31',
'field_dt[0][value][hour]' => '1',
'field_dt[0][value][minute]' => '30',
);
$this->drupalPostForm('node/add/page_with_date', $edit, t('Save'));
$this->assertText(t('Selected combination of day and month is not valid.'), 'Inorrect date failed validation');
$edit['field_dt[0][value][day]'] = '29';
$this->drupalPostForm('node/add/page_with_date', $edit, t('Save'));
$this->assertNoText(t('Selected combination of day and month is not valid.'), 'Correct date passed validation.');
$this->drupalGet('node/1');
$this->assertText(t('Mon, 02/29/2016 - 01:30'), 'Node successfully created with valid date.');
}
}

View file

@ -2,6 +2,8 @@
namespace Drupal\system\Tests\System;
use Drupal\Core\Flood\DatabaseBackend;
use Drupal\Core\Flood\MemoryBackend;
use Drupal\simpletest\WebTestBase;
use Symfony\Component\HttpFoundation\Request;
@ -59,7 +61,7 @@ class FloodTest extends WebTestBase {
$name = 'flood_test_cleanup';
$request_stack = \Drupal::service('request_stack');
$flood = new \Drupal\Core\Flood\MemoryBackend($request_stack);
$flood = new MemoryBackend($request_stack);
// Register expired event.
$flood->register($name, $window_expired);
// Verify event is not allowed.
@ -87,7 +89,7 @@ class FloodTest extends WebTestBase {
$connection = \Drupal::service('database');
$request_stack = \Drupal::service('request_stack');
$flood = new \Drupal\Core\Flood\DatabaseBackend($connection, $request_stack);
$flood = new DatabaseBackend($connection, $request_stack);
// Register expired event.
$flood->register($name, $window_expired);
// Verify event is not allowed.

View file

@ -70,7 +70,7 @@ class FrontPageTest extends WebTestBase {
// Change the front page to a path without a starting slash.
$edit = ['site_frontpage' => $this->nodePath];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']]));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']]));
// Change the front page to a valid path.
$edit['site_frontpage'] = '/' . $this->nodePath;

View file

@ -24,7 +24,7 @@ class MainContentFallbackTest extends WebTestBase {
protected function setUp() {
parent::setUp();
// Create and login admin user.
// Create and log in admin user.
$this->adminUser = $this->drupalCreateUser(array(
'access administration pages',
'administer site configuration',

View file

@ -44,7 +44,7 @@ class PageNotFoundTest extends WebTestBase {
'site_404' => 'user/' . $this->adminUser->id(),
];
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
$this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_404']]));
// Use a custom 404 page.
$edit = array(

View file

@ -29,13 +29,13 @@ class SitesDirectoryHardeningTest extends WebTestBase {
// We intentionally don't check for settings.local.php as that file is
// not created by Drupal.
$this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', array('@file' => $settings_file)));
$this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', array('@file' => $settings_file)));
$this->makeWritable($site_path);
$this->checkSystemRequirements();
$this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $site_path)));
$this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $settings_file)));
$this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $settings_file)));
}
/**

View file

@ -1,156 +0,0 @@
<?php
namespace Drupal\system\Tests\System;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Generates text using placeholders for dummy content to check token
* replacement.
*
* @group system
*/
class TokenReplaceUnitTest extends TokenReplaceUnitTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Set the site name to something other than an empty string.
$this->config('system.site')->set('name', 'Drupal')->save();
}
/**
* Test whether token-replacement works in various contexts.
*/
public function testSystemTokenRecognition() {
// Generate prefixes and suffixes for the token context.
$tests = array(
array('prefix' => 'this is the ', 'suffix' => ' site'),
array('prefix' => 'this is the', 'suffix' => 'site'),
array('prefix' => '[', 'suffix' => ']'),
array('prefix' => '', 'suffix' => ']]]'),
array('prefix' => '[[[', 'suffix' => ''),
array('prefix' => ':[:', 'suffix' => '--]'),
array('prefix' => '-[-', 'suffix' => ':]:'),
array('prefix' => '[:', 'suffix' => ']'),
array('prefix' => '[site:', 'suffix' => ':name]'),
array('prefix' => '[site:', 'suffix' => ']'),
);
// Check if the token is recognized in each of the contexts.
foreach ($tests as $test) {
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
$output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input)));
}
// Test token replacement when the string contains no tokens.
$this->assertEqual($this->tokenService->replace('No tokens here.'), 'No tokens here.');
}
/**
* Tests the clear parameter.
*/
public function testClear() {
// Valid token.
$source = '[site:name]';
// No user passed in, should be untouched.
$source .= '[user:name]';
// Non-existing token.
$source .= '[bogus:token]';
// Replace with the clear parameter, only the valid token should remain.
$target = Html::escape($this->config('system.site')->get('name'));
$result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE));
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
$target .= '[user:name]';
$target .= '[bogus:token]';
$result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
}
/**
* Tests the generation of all system site information tokens.
*/
public function testSystemSiteTokenReplacement() {
$url_options = array(
'absolute' => TRUE,
'language' => $this->interfaceLanguage,
);
$slogan = '<blink>Slogan</blink>';
$safe_slogan = Xss::filterAdmin($slogan);
// Set a few site variables.
$config = $this->config('system.site');
$config
->set('name', '<strong>Drupal<strong>')
->set('slogan', $slogan)
->set('mail', 'simpletest@example.com')
->save();
// Generate and test tokens.
$tests = array();
$tests['[site:name]'] = Html::escape($config->get('name'));
$tests['[site:slogan]'] = $safe_slogan;
$tests['[site:mail]'] = $config->get('mail');
$tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
$tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('<front>', [], $url_options));
$tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
$base_bubbleable_metadata = new BubbleableMetadata();
$metadata_tests = [];
$metadata_tests['[site:name]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:slogan]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:mail]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$bubbleable_metadata = clone $base_bubbleable_metadata;
$metadata_tests['[site:url]'] = $bubbleable_metadata->addCacheContexts(['url.site']);
$metadata_tests['[site:url-brief]'] = $bubbleable_metadata;
$metadata_tests['[site:login-url]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
$output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
}
/**
* Tests the generation of all system date tokens.
*/
public function testSystemDateTokenReplacement() {
// Set time to one hour before request.
$date = REQUEST_TIME - 3600;
// Generate and test tokens.
$tests = array();
$date_formatter = \Drupal::service('date.formatter');
$tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId());
$tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, array('langcode' => $this->interfaceLanguage->getId()));
$tests['[date:raw]'] = Xss::filter($date);
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input)));
}
}
}

View file

@ -1,43 +0,0 @@
<?php
namespace Drupal\system\Tests\System;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Base class for token replacement tests.
*/
abstract class TokenReplaceUnitTestBase extends EntityUnitTestBase {
/**
* The interface language.
*
* @var \Drupal\Core\Language\LanguageInterface
*/
protected $interfaceLanguage;
/**
* Token service.
*
* @var \Drupal\Core\Utility\Token
*/
protected $tokenService;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system');
protected function setUp() {
parent::setUp();
// Install default system configuration.
$this->installConfig(array('system'));
\Drupal::service('router.builder')->rebuild();
$this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage();
$this->tokenService = \Drupal::token();
}
}

View file

@ -128,4 +128,3 @@ class TwigEnvironmentTest extends KernelTestBase {
}
}

View file

@ -2,14 +2,22 @@
namespace Drupal\system\Tests\TypedData;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\ListDataDefinition;
use Drupal\Core\TypedData\MapDataDefinition;
use Drupal\Core\TypedData\Type\BinaryInterface;
use Drupal\Core\TypedData\Type\BooleanInterface;
use Drupal\Core\TypedData\Type\DateTimeInterface;
use Drupal\Core\TypedData\Type\DurationInterface;
use Drupal\Core\TypedData\Type\FloatInterface;
use Drupal\Core\TypedData\Type\IntegerInterface;
use Drupal\Core\TypedData\Type\StringInterface;
use Drupal\Core\TypedData\Type\UriInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\file\Entity\File;
use Drupal\simpletest\KernelTestBase;
use Drupal\Core\Datetime\DrupalDateTime;
/**
* Tests the functionality of all core data types.
@ -49,7 +57,7 @@ class TypedDataTest extends KernelTestBase {
$definition = DataDefinition::create($definition['type']);
}
$data = $this->typedDataManager->create($definition, $value, $name);
$this->assertTrue($data instanceof \Drupal\Core\TypedData\TypedDataInterface, 'Typed data object is an instance of the typed data interface.');
$this->assertTrue($data instanceof TypedDataInterface, 'Typed data object is an instance of the typed data interface.');
return $data;
}
@ -59,7 +67,7 @@ class TypedDataTest extends KernelTestBase {
public function testGetAndSet() {
// Boolean type.
$typed_data = $this->createTypedData(array('type' => 'boolean'), TRUE);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BooleanInterface, 'Typed data object is an instance of BooleanInterface.');
$this->assertTrue($typed_data instanceof BooleanInterface, 'Typed data object is an instance of BooleanInterface.');
$this->assertTrue($typed_data->getValue() === TRUE, 'Boolean value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(FALSE);
@ -75,7 +83,7 @@ class TypedDataTest extends KernelTestBase {
// String type.
$value = $this->randomString();
$typed_data = $this->createTypedData(array('type' => 'string'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'String value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$new_value = $this->randomString();
@ -93,7 +101,7 @@ class TypedDataTest extends KernelTestBase {
// Integer type.
$value = rand();
$typed_data = $this->createTypedData(array('type' => 'integer'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\IntegerInterface, 'Typed data object is an instance of IntegerInterface.');
$this->assertTrue($typed_data instanceof IntegerInterface, 'Typed data object is an instance of IntegerInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'Integer value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$new_value = rand();
@ -110,7 +118,7 @@ class TypedDataTest extends KernelTestBase {
// Float type.
$value = 123.45;
$typed_data = $this->createTypedData(array('type' => 'float'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\FloatInterface, 'Typed data object is an instance of FloatInterface.');
$this->assertTrue($typed_data instanceof FloatInterface, 'Typed data object is an instance of FloatInterface.');
$this->assertTrue($typed_data->getValue() === $value, 'Float value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$new_value = 678.90;
@ -127,7 +135,7 @@ class TypedDataTest extends KernelTestBase {
// Date Time type.
$value = '2014-01-01T20:00:00+00:00';
$typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data->getValue() == $value, 'Date value was fetched.');
$this->assertEqual($typed_data->getValue(), $typed_data->getDateTime()->format('c'), 'Value representation of a date is ISO 8601');
$this->assertEqual($typed_data->validate()->count(), 0);
@ -153,7 +161,7 @@ class TypedDataTest extends KernelTestBase {
// Timestamp type.
$value = REQUEST_TIME;
$typed_data = $this->createTypedData(array('type' => 'timestamp'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.');
$this->assertTrue($typed_data->getValue() == $value, 'Timestamp value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$new_value = REQUEST_TIME + 1;
@ -176,7 +184,7 @@ class TypedDataTest extends KernelTestBase {
// DurationIso8601 type.
$value = 'PT20S';
$typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'DurationIso8601 value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue('P40D');
@ -200,7 +208,7 @@ class TypedDataTest extends KernelTestBase {
// Time span type.
$value = 20;
$typed_data = $this->createTypedData(array('type' => 'timespan'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'Time span value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue(60 * 60 * 4);
@ -223,7 +231,7 @@ class TypedDataTest extends KernelTestBase {
// URI type.
$uri = 'http://example.com/foo/';
$typed_data = $this->createTypedData(array('type' => 'uri'), $uri);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\UriInterface, 'Typed data object is an instance of UriInterface.');
$this->assertTrue($typed_data instanceof UriInterface, 'Typed data object is an instance of UriInterface.');
$this->assertTrue($typed_data->getValue() === $uri, 'URI value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
$typed_data->setValue($uri . 'bar.txt');
@ -251,7 +259,7 @@ class TypedDataTest extends KernelTestBase {
// Email type.
$value = $this->randomString();
$typed_data = $this->createTypedData(array('type' => 'email'), $value);
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.');
$this->assertIdentical($typed_data->getValue(), $value, 'Email value was fetched.');
$new_value = 'test@example.com';
$typed_data->setValue($new_value);
@ -266,7 +274,7 @@ class TypedDataTest extends KernelTestBase {
// Binary type.
$typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->getFileUri());
$this->assertTrue($typed_data instanceof \Drupal\Core\TypedData\Type\BinaryInterface, 'Typed data object is an instance of BinaryInterface.');
$this->assertTrue($typed_data instanceof BinaryInterface, 'Typed data object is an instance of BinaryInterface.');
$this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.');
$this->assertEqual($typed_data->validate()->count(), 0);
// Try setting by URI.
@ -441,7 +449,7 @@ class TypedDataTest extends KernelTestBase {
// Test iterating.
$count = 0;
foreach ($typed_data as $item) {
$this->assertTrue($item instanceof \Drupal\Core\TypedData\TypedDataInterface);
$this->assertTrue($item instanceof TypedDataInterface);
$count++;
}
$this->assertEqual($count, 3);

View file

@ -51,7 +51,7 @@ class LocalActionsAndTasksConvertedIntoBlocksUpdateTest extends UpdatePathTestBa
// after updates in https://www.drupal.org/node/2435135.
\Drupal::state()->set('system.maintenance_mode', FALSE);
// We finished updating so we can login the user now.
// We finished updating so we can log in the user now.
$this->drupalLogin($this->rootUser);
$page = Node::create([

View file

@ -50,7 +50,7 @@ class PageTitleConvertedIntoBlockUpdateTest extends UpdatePathTestBase {
// after updates in https://www.drupal.org/node/2435135.
\Drupal::state()->set('system.maintenance_mode', FALSE);
// We finished updating so we can login the user now.
// We finished updating so we can log in the user now.
$this->drupalLogin($this->rootUser);
$page = Node::create([

View file

@ -45,7 +45,7 @@ class SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest extends UpdatePathTes
// after updates in https://www.drupal.org/node/2435135.
\Drupal::state()->set('system.maintenance_mode', FALSE);
// We finished updating so we can login the user now.
// We finished updating so we can log in the user now.
$this->drupalLogin($this->rootUser);
// Local actions are visible on the content listing page.

View file

@ -45,7 +45,7 @@ class SiteBrandingConvertedIntoBlockUpdateTest extends UpdatePathTestBase {
// after updates in https://www.drupal.org/node/2435135.
\Drupal::state()->set('system.maintenance_mode', FALSE);
// We finished updating so we can login the user now.
// We finished updating so we can log in the user now.
$this->drupalLogin($this->rootUser);
// Site branding is visible on the home page.

View file

@ -14,7 +14,7 @@ class UpdatePathWithBrokenRoutingFilledTest extends UpdatePathWithBrokenRoutingT
*/
protected function setDatabaseDumpFiles() {
parent::setDatabaseDumpFiles();
$this->databaseDumpFiles[0] = __DIR__ . '/../../../tests/fixtures/update/drupal-8.filled.standard.php.gz';
$this->databaseDumpFiles[0] = __DIR__ . '/../../../tests/fixtures/update/drupal-8.filled.standard.php.gz';
}
}

View file

@ -56,20 +56,38 @@ class UpdateScriptTest extends WebTestBase {
$this->drupalGet($this->updateUrl, array('external' => TRUE));
$this->assertResponse(403);
// Check that a link to the update page is not accessible to regular users.
$this->drupalGet('/update-script-test/database-updates-menu-item');
$this->assertNoLink('Run database updates');
// Try accessing update.php as an anonymous user.
$this->drupalLogout();
$this->drupalGet($this->updateUrl, array('external' => TRUE));
$this->assertResponse(403);
// Check that a link to the update page is not accessible to anonymous
// users.
$this->drupalGet('/update-script-test/database-updates-menu-item');
$this->assertNoLink('Run database updates');
// Access the update page with the proper permission.
$this->drupalLogin($this->updateUser);
$this->drupalGet($this->updateUrl, array('external' => TRUE));
$this->assertResponse(200);
// Check that a link to the update page is accessible to users with proper
// permissions.
$this->drupalGet('/update-script-test/database-updates-menu-item');
$this->assertLink('Run database updates');
// Access the update page as user 1.
$this->drupalLogin($this->rootUser);
$this->drupalGet($this->updateUrl, array('external' => TRUE));
$this->assertResponse(200);
// Check that a link to the update page is accessible to user 1.
$this->drupalGet('/update-script-test/database-updates-menu-item');
$this->assertLink('Run database updates');
}
/**