Issue #1624278 by quietone, longwave: cleanup of docblock to UI text in update_get_update_list() is weak
parent
1e7f978400
commit
fe06cae4df
|
@ -397,7 +397,14 @@ function update_get_update_list() {
|
|||
if ($update > $schema_version) {
|
||||
// The description for an update comes from its Doxygen.
|
||||
$func = new ReflectionFunction($module . '_update_' . $update);
|
||||
$description = str_replace(["\n", '*', '/'], '', $func->getDocComment());
|
||||
$patterns = [
|
||||
'/^\s*[\/*]*/',
|
||||
'/(\n\s*\**)(.*)/',
|
||||
'/\/$/',
|
||||
'/^\s*/',
|
||||
];
|
||||
$replacements = ['', '$2', '', ''];
|
||||
$description = preg_replace($patterns, $replacements, $func->getDocComment());
|
||||
$ret[$module]['pending'][$update] = "$update - $description";
|
||||
if (!isset($ret[$module]['start'])) {
|
||||
$ret[$module]['start'] = $update;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
name: Update test description
|
||||
type: module
|
||||
description: Support module for update testing.
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update and uninstall functions for the update_test_descriptions module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Update test of slash in description and/or.
|
||||
*/
|
||||
function update_test_description_update_8001() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update test with multiline description, the quick brown fox jumped over the
|
||||
* lazy dog.
|
||||
*/
|
||||
function update_test_description_update_8002() {
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Functional\UpdateSystem;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the display of the description for hook_update().
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class UpdateDescriptionTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaultTheme = 'stark';
|
||||
|
||||
/**
|
||||
* Tests displayed description.
|
||||
*/
|
||||
public function testDescription() {
|
||||
$user = $this->drupalCreateUser([
|
||||
'administer software updates',
|
||||
'access site in maintenance mode',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
$connection = Database::getConnection();
|
||||
// Set the schema version.
|
||||
$connection->merge('key_value')
|
||||
->condition('collection', 'system.schema')
|
||||
->condition('name', 'update_test_description')
|
||||
->fields([
|
||||
'collection' => 'system.schema',
|
||||
'name' => 'update_test_description',
|
||||
'value' => 'i:8000;',
|
||||
])
|
||||
->execute();
|
||||
// Update core.extension.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$extensions['module']['update_test_description'] = 8000;
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize($extensions),
|
||||
])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
||||
|
||||
// Go to the update page.
|
||||
$update_url = Url::fromRoute('system.db_update');
|
||||
|
||||
$this->drupalGet($update_url);
|
||||
$this->clickLink(t('Continue'));
|
||||
|
||||
// Check that the description is displayed correctly.
|
||||
$this->assertSession()->responseContains('8001 - Update test of slash in description and/or.');
|
||||
$this->assertSession()->responseContains('8002 - Update test with multiline description, the quick brown fox jumped over the lazy dog.');
|
||||
}
|
||||
|
||||
}
|
|
@ -76,8 +76,8 @@ class UpdatePostUpdateFailingTest extends BrowserTestBase {
|
|||
*/
|
||||
protected function doSelectionTest() {
|
||||
// First update, should not be run since this module's update hooks fail.
|
||||
$this->assertRaw('8001 - This update will fail.');
|
||||
$this->assertRaw('8002 - A further update.');
|
||||
$this->assertSession()->responseContains('8001 - This update will fail.');
|
||||
$this->assertSession()->responseContains('8002 - A further update');
|
||||
$this->assertSession()->assertEscaped("First update, should not be run since this module's update hooks fail.");
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class UpdatePostUpdateTest extends BrowserTestBase {
|
|||
protected function doSelectionTest() {
|
||||
// Ensure that normal and post_update updates are merged together on the
|
||||
// selection page.
|
||||
$this->assertRaw('<ul><li>8001 - Normal update_N() function. </li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>');
|
||||
$this->assertSession()->responseContains('<ul><li>8001 - Normal update_N() function.</li><li>First update.</li><li>Second update.</li><li>Test0 update.</li><li>Test1 update.</li><li>Testing batch processing in post updates update.</li></ul>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue