Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -245,8 +245,8 @@ class SystemController extends ControllerBase {
|
|||
// content has a common place in all themes.
|
||||
$theme->incompatible_region = !isset($theme->info['regions']['content']);
|
||||
$theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0;
|
||||
// Confirmed that the base theme is available.
|
||||
$theme->incompatible_base = isset($theme->info['base theme']) && !isset($themes[$theme->info['base theme']]);
|
||||
// Confirm that all base themes are available.
|
||||
$theme->incompatible_base = (isset($theme->info['base theme']) && !($theme->base_themes === array_filter($theme->base_themes)));
|
||||
// Confirm that the theme engine is available.
|
||||
$theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner);
|
||||
}
|
||||
|
|
38
core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php
Normal file
38
core/modules/system/src/Tests/Ajax/AjaxInGroupTest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Ajax\AjaxInGroupTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\DataCommand;
|
||||
|
||||
/**
|
||||
* Tests that form elements in groups work correctly with AJAX.
|
||||
*
|
||||
* @group Ajax
|
||||
*/
|
||||
class AjaxInGroupTest extends AjaxTestBase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(array('access content')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits forms with select and checkbox elements via Ajax.
|
||||
*/
|
||||
function testSimpleAjaxFormValue() {
|
||||
$this->drupalGet('/ajax_forms_test_get_form');
|
||||
$this->assertText('Test group');
|
||||
$this->assertText('AJAX checkbox in a group');
|
||||
|
||||
$this->drupalPostAjaxForm(NULL, ['checkbox_in_group' => TRUE], 'checkbox_in_group');
|
||||
$this->assertText('Test group');
|
||||
$this->assertText('AJAX checkbox in a group');
|
||||
$this->assertText('AJAX checkbox in a nested group');
|
||||
$this->assertText('Another AJAX checkbox in a nested group');
|
||||
}
|
||||
}
|
|
@ -492,5 +492,124 @@ class TransactionTest extends DatabaseTestBase {
|
|||
$this->assertRowAbsent('inner');
|
||||
$this->assertRowAbsent('inner2');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that transactions can continue to be used if a query fails.
|
||||
*/
|
||||
public function testQueryFailureInTransaction() {
|
||||
$connection = Database::getConnection();
|
||||
$transaction = $connection->startTransaction('test_transaction');
|
||||
$connection->schema()->dropTable('test');
|
||||
|
||||
// Test a failed query using the query() method.
|
||||
try {
|
||||
$connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField();
|
||||
$this->fail('Using the query method failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Using the query method failed.');
|
||||
}
|
||||
|
||||
// Test a failed select query.
|
||||
try {
|
||||
$connection->select('test')
|
||||
->fields('test', ['name'])
|
||||
->execute();
|
||||
|
||||
$this->fail('Select query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Select query failed.');
|
||||
}
|
||||
|
||||
// Test a failed insert query.
|
||||
try {
|
||||
$connection->insert('test')
|
||||
->fields([
|
||||
'name' => 'David',
|
||||
'age' => '24',
|
||||
])
|
||||
->execute();
|
||||
|
||||
$this->fail('Insert query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Insert query failed.');
|
||||
}
|
||||
|
||||
// Test a failed update query.
|
||||
try {
|
||||
$connection->update('test')
|
||||
->fields(['name' => 'Tiffany'])
|
||||
->condition('id', 1)
|
||||
->execute();
|
||||
|
||||
$this->fail('Update query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Update query failed.');
|
||||
}
|
||||
|
||||
// Test a failed delete query.
|
||||
try {
|
||||
$connection->delete('test')
|
||||
->condition('id', 1)
|
||||
->execute();
|
||||
|
||||
$this->fail('Delete query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Delete query failed.');
|
||||
}
|
||||
|
||||
// Test a failed merge query.
|
||||
try {
|
||||
$connection->merge('test')
|
||||
->key('job', 'Presenter')
|
||||
->fields([
|
||||
'age' => '31',
|
||||
'name' => 'Tiffany',
|
||||
])
|
||||
->execute();
|
||||
|
||||
$this->fail('Merge query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Merge query failed.');
|
||||
}
|
||||
|
||||
// Test a failed upsert query.
|
||||
try {
|
||||
$connection->upsert('test')
|
||||
->key('job')
|
||||
->fields(['job', 'age', 'name'])
|
||||
->values([
|
||||
'job' => 'Presenter',
|
||||
'age' => 31,
|
||||
'name' => 'Tiffany',
|
||||
])
|
||||
->execute();
|
||||
|
||||
$this->fail('Upset query failed.');
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->pass('Upset query failed.');
|
||||
}
|
||||
|
||||
// Create the missing schema and insert a row.
|
||||
$this->installSchema('database_test', ['test']);
|
||||
$connection->insert('test')
|
||||
->fields(array(
|
||||
'name' => 'David',
|
||||
'age' => '24',
|
||||
))
|
||||
->execute();
|
||||
|
||||
// Commit the transaction.
|
||||
unset($transaction);
|
||||
|
||||
$saved_age = $connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField();
|
||||
$this->assertEqual('24', $saved_age);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ class EntityQueryTest extends EntityUnitTestBase {
|
|||
// decimal 13 is binary 1101 so unit 3,2 and 0 will be added to the
|
||||
// entity.
|
||||
for ($i = 1; $i <= 15; $i++) {
|
||||
$entity = entity_create('entity_test_mulrev', array(
|
||||
$entity = EntityTestMulRev::create(array(
|
||||
'type' => $bundles[$i & 1],
|
||||
'name' => $this->randomMachineName(),
|
||||
'langcode' => 'en',
|
||||
|
|
|
@ -371,6 +371,10 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
// Save the translation and check that the expected hooks are fired.
|
||||
$translation->save();
|
||||
$hooks = $this->getHooksInfo();
|
||||
|
||||
$this->assertEqual($hooks['entity_translation_create'], $langcode, 'The generic entity translation creation hook has fired.');
|
||||
$this->assertEqual($hooks[$entity_type . '_translation_create'], $langcode, 'The entity-type-specific entity translation creation hook has fired.');
|
||||
|
||||
$this->assertEqual($hooks['entity_translation_insert'], $langcode, 'The generic entity translation insertion hook has fired.');
|
||||
$this->assertEqual($hooks[$entity_type . '_translation_insert'], $langcode, 'The entity-type-specific entity translation insertion hook has fired.');
|
||||
|
||||
|
@ -436,6 +440,10 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
$this->assertEqual($entity->language()->getId(), $default_langcode, 'The original language has been preserved.');
|
||||
$translation->save();
|
||||
$hooks = $this->getHooksInfo();
|
||||
|
||||
$this->assertEqual($hooks['entity_translation_create'], $langcode2, 'The generic entity translation creation hook has fired.');
|
||||
$this->assertEqual($hooks[$entity_type . '_translation_create'], $langcode2, 'The entity-type-specific entity translation creation hook has fired.');
|
||||
|
||||
$this->assertEqual($hooks['entity_translation_insert'], $langcode2, 'The generic entity translation insertion hook has fired.');
|
||||
$this->assertEqual($hooks[$entity_type . '_translation_insert'], $langcode2, 'The entity-type-specific entity translation insertion hook has fired.');
|
||||
|
||||
|
@ -483,7 +491,13 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
$entity->removeTranslation($langcode2);
|
||||
$entity->save();
|
||||
$hooks = $this->getHooksInfo();
|
||||
$this->assertFalse($hooks, 'No hooks are run when adding and removing a translation without storing it.');
|
||||
|
||||
$this->assertTrue(isset($hooks['entity_translation_create']), 'The generic entity translation creation hook is run when adding and removing a translation without storing it.');
|
||||
unset($hooks['entity_translation_create']);
|
||||
$this->assertTrue(isset($hooks[$entity_type . '_translation_create']), 'The entity-type-specific entity translation creation hook is run when adding and removing a translation without storing it.');
|
||||
unset($hooks[$entity_type . '_translation_create']);
|
||||
|
||||
$this->assertFalse($hooks, 'No other hooks beyond the entity translation creation hooks are run when adding and removing a translation without storing it.');
|
||||
|
||||
// Check that hooks are fired only when actually storing data.
|
||||
$entity = $this->reloadEntity($entity);
|
||||
|
@ -554,6 +568,9 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
);
|
||||
$this->assertEqual($translation->description->getValue(), $expected, 'Language-aware default values correctly populated.');
|
||||
$this->assertEqual($translation->description->getLangcode(), $langcode2, 'Field object has the expected langcode.');
|
||||
|
||||
// Reset hook firing information.
|
||||
$this->getHooksInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ class UrlRewritingTest extends FileTestBase {
|
|||
* Tests the rewriting of shipped file URLs by hook_file_url_alter().
|
||||
*/
|
||||
function testShippedFileURL() {
|
||||
// Test generating an URL to a shipped file (i.e. a file that is part of
|
||||
// Test generating a URL to a shipped file (i.e. a file that is part of
|
||||
// Drupal core, a module or a theme, for example a JavaScript file).
|
||||
|
||||
// Test alteration of file URLs to use a CDN.
|
||||
|
@ -74,7 +74,7 @@ class UrlRewritingTest extends FileTestBase {
|
|||
* Tests the rewriting of public managed file URLs by hook_file_url_alter().
|
||||
*/
|
||||
function testPublicManagedFileURL() {
|
||||
// Test generating an URL to a managed file.
|
||||
// Test generating a URL to a managed file.
|
||||
|
||||
// Test alteration of file URLs to use a CDN.
|
||||
\Drupal::state()->set('file_test.hook_file_url_alter', 'cdn');
|
||||
|
|
|
@ -319,6 +319,9 @@ class ThemeTest extends WebTestBase {
|
|||
|
||||
/**
|
||||
* Test themes can't be installed when the base theme or engine is missing.
|
||||
*
|
||||
* Include test for themes that have a missing base theme somewhere further up
|
||||
* the chain than the immediate base theme.
|
||||
*/
|
||||
function testInvalidTheme() {
|
||||
// theme_page_test_system_info_alter() un-hides all hidden themes.
|
||||
|
@ -327,6 +330,7 @@ class ThemeTest extends WebTestBase {
|
|||
$this->container->get('theme_handler')->reset();
|
||||
$this->drupalGet('admin/appearance');
|
||||
$this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'not_real_test_basetheme')));
|
||||
$this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'test_invalid_basetheme')));
|
||||
$this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine')));
|
||||
// Check for the error text of a theme with the wrong core version.
|
||||
$this->assertText("This theme is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value.");
|
||||
|
|
|
@ -82,6 +82,17 @@ class UpdatePathTestBaseTest extends UpdatePathTestBase {
|
|||
// Increment the schema version.
|
||||
\Drupal::state()->set('update_test_schema_version', 8001);
|
||||
$this->runUpdates();
|
||||
|
||||
$select = \Drupal::database()->select('watchdog');
|
||||
$select->orderBy('wid', 'DESC');
|
||||
$select->range(0, 5);
|
||||
$select->fields('watchdog', ['message']);
|
||||
|
||||
$container_cannot_be_saved_messages = array_filter(iterator_to_array($select->execute()), function($row) {
|
||||
return strpos($row->message, 'Container cannot be saved to cache.') !== FALSE;
|
||||
});
|
||||
$this->assertEqual([], $container_cannot_be_saved_messages);
|
||||
|
||||
// Ensure schema has changed.
|
||||
$this->assertEqual(drupal_get_installed_schema_version('update_test_schema', TRUE), 8001);
|
||||
// Ensure the index was added for column a.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\system\Tests\Update;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +23,7 @@ class UpdateScriptTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('update_script_test', 'dblog');
|
||||
public static $modules = array('update_script_test', 'dblog', 'language');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -218,6 +219,57 @@ class UpdateScriptTest extends WebTestBase {
|
|||
$this->assertEqual($final_maintenance_mode, $initial_maintenance_mode, 'Maintenance mode should not have changed after database updates.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests perfoming updates with update.php in a multilingual environment.
|
||||
*/
|
||||
function testSuccessfulMultilingualUpdateFunctionality() {
|
||||
// Add some custom languages.
|
||||
foreach (array('aa', 'bb') as $language_code) {
|
||||
ConfigurableLanguage::create(array(
|
||||
'id' => $language_code,
|
||||
'label' => $this->randomMachineName(),
|
||||
))->save();
|
||||
}
|
||||
|
||||
$config = \Drupal::service('config.factory')->getEditable('language.negotiation');
|
||||
// Ensure path prefix is used to determine the language.
|
||||
$config->set('url.source', 'path_prefix');
|
||||
// Ensure that there's a path prefix set for english as well.
|
||||
$config->set('url.prefixes.en', 'en');
|
||||
$config->save();
|
||||
|
||||
// Reset the static cache to ensure we have the most current setting.
|
||||
$schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
|
||||
$this->assertEqual($schema_version, 8001, 'update_script_test schema version is 8001 after updating.');
|
||||
|
||||
// Set the installed schema version to one less than the current update.
|
||||
drupal_set_installed_schema_version('update_script_test', $schema_version - 1);
|
||||
$schema_version = drupal_get_installed_schema_version('update_script_test', TRUE);
|
||||
$this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.');
|
||||
|
||||
// Create admin user.
|
||||
$admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode', 'administer site configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Visit status report page and ensure, that link to update.php has no path prefix set.
|
||||
$this->drupalGet('en/admin/reports/status', array('external' => TRUE));
|
||||
$this->assertResponse(200);
|
||||
$this->assertLinkByHref('/update.php');
|
||||
$this->assertNoLinkByHref('en/update.php');
|
||||
|
||||
// Click through update.php with 'access administration pages' and
|
||||
// 'access site reports' permissions.
|
||||
$this->drupalGet($this->updateUrl, array('external' => TRUE));
|
||||
$this->clickLink(t('Continue'));
|
||||
$this->clickLink(t('Apply pending updates'));
|
||||
$this->assertText('Updates were attempted.');
|
||||
$this->assertLink('logged');
|
||||
$this->assertLink('Administration pages');
|
||||
$this->assertNoLinkByHrefInMainRegion('update.php', 1);
|
||||
$this->clickLink('Administration pages');
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to run updates via the browser.
|
||||
*/
|
||||
|
|
Reference in a new issue