Commit 2fc85e7f authored by catch's avatar catch

Issue #2901572 by Jo Fitzgerald, bluccas, mfernea, klausi: Fix...

Issue #2901572 by Jo Fitzgerald, bluccas, mfernea, klausi: Fix 'Drupal.Commenting.PostStatementComment' coding standard
parent 3c76c819
......@@ -252,7 +252,8 @@ function format_size($size, $langcode = NULL) {
return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', [], ['langcode' => $langcode]);
}
else {
$size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes.
// Convert bytes to kilobytes.
$size = $size / Bytes::KILOBYTE;
$units = ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
foreach ($units as $unit) {
if (round($size, 2) >= Bytes::KILOBYTE) {
......
......@@ -716,8 +716,10 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
// Split the filename up by periods. The first part becomes the basename
// the last part the final extension.
$filename_parts = explode('.', $filename);
$new_filename = array_shift($filename_parts); // Remove file basename.
$final_extension = array_pop($filename_parts); // Remove final extension.
// Remove file basename.
$new_filename = array_shift($filename_parts);
// Remove final extension.
$final_extension = array_pop($filename_parts);
// Loop through the middle parts of the name and add an underscore to the
// end of each section that could be a file extension but isn't in the list
......
......@@ -609,7 +609,8 @@ public static function strcasecmp($str1 , $str2) {
*/
public static function mimeHeaderEncode($string) {
if (preg_match('/[^\x20-\x7E]/', $string)) {
$chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
// floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
$chunk_size = 47;
$len = strlen($string);
$output = '';
while ($len > 0) {
......
......@@ -231,7 +231,8 @@ public function __get($name) {
*/
final protected function fixRemotePath($path, $strip_chroot = TRUE) {
$path = $this->sanitizePath($path);
$path = preg_replace('|^([a-z]{1}):|i', '', $path); // Strip out windows driveletter if its there.
// Strip out windows driveletter if its there.
$path = preg_replace('|^([a-z]{1}):|i', '', $path);
if ($strip_chroot) {
if ($this->chroot && strpos($path, $this->chroot) === 0) {
$path = ($path == $this->chroot) ? '' : substr($path, strlen($this->chroot));
......@@ -250,7 +251,8 @@ public function __get($name) {
* The modified path.
*/
public function sanitizePath($path) {
$path = str_replace('\\', '/', $path); // Windows path sanitization.
// Windows path sanitization.
$path = str_replace('\\', '/', $path);
if (substr($path, -1) == '/') {
$path = substr($path, 0, -1);
}
......
......@@ -65,8 +65,10 @@ class UrlGenerator implements UrlGeneratorInterface {
// the slash can be used to designate a hierarchical structure and we want allow using it with this meaning
// some webservers don't allow the slash in encoded form in the path for security reasons anyway
// see http://stackoverflow.com/questions/4069002/http-400-if-2f-part-of-get-url-in-jboss
'%2F', // Map from these encoded characters.
'/', // Map to these decoded characters.
// Map from these encoded characters.
'%2F',
// Map to these decoded characters.
'/',
];
/**
......
......@@ -152,7 +152,8 @@ public function testBook() {
* |- Node 5
* |- Node 4
*/
$nodes[] = $this->createBookNode($book->id(), $nodes[3]->book['nid']); // Node 5.
// Node 5.
$nodes[] = $this->createBookNode($book->id(), $nodes[3]->book['nid']);
$this->drupalLogout();
$this->drupalLogin($this->webUser);
// Verify the new outline - make sure we don't get stale cached data.
......
......@@ -51,11 +51,16 @@ public function createBook($edit = []) {
* |- Node 4
*/
$nodes = [];
$nodes[] = $this->createBookNode($book->id(), NULL, $edit); // Node 0.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit); // Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit); // Node 2.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit); // Node 3.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit); // Node 4.
// Node 0.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
// Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit);
// Node 2.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid'], $edit);
// Node 3.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
// Node 4.
$nodes[] = $this->createBookNode($book->id(), NULL, $edit);
$this->drupalLogout();
......@@ -179,7 +184,8 @@ public function generateOutlinePattern($nodes) {
public function createBookNode($book_nid, $parent = NULL, $edit = []) {
// $number does not use drupal_static as it should not be reset
// since it uniquely identifies each call to createBookNode().
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
// Used to ensure that when sorted nodes stay in same order.
static $number = 0;
$edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10);
$edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32);
......
......@@ -101,7 +101,8 @@ public function getFile() {
public function getConfig(Editor $editor) {
// Reasonable defaults that provide expected basic behavior.
$config = [
'customConfig' => '', // Don't load CKEditor's config.js file.
// Don't load CKEditor's config.js file.
'customConfig' => '',
'pasteFromWordPromptCleanup' => TRUE,
'resize_dir' => 'vertical',
'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
......
......@@ -266,12 +266,18 @@ public function testCommentNewPageIndicator() {
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.');
$expected_pages = [
1 => 5, // Page of comment 5
2 => 4, // Page of comment 4
3 => 3, // Page of comment 3
4 => 2, // Page of comment 2
5 => 1, // Page of comment 1
6 => 0, // Page of comment 0
// Page of comment 5
1 => 5,
// Page of comment 4
2 => 4,
// Page of comment 3
3 => 3,
// Page of comment 2
4 => 2,
// Page of comment 1
5 => 1,
// Page of comment 0
6 => 0,
];
$node = Node::load($node->id());
......@@ -284,12 +290,18 @@ public function testCommentNewPageIndicator() {
$this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.');
$expected_pages = [
1 => 5, // Page of comment 5
2 => 1, // Page of comment 4
3 => 1, // Page of comment 4
4 => 1, // Page of comment 4
5 => 1, // Page of comment 4
6 => 0, // Page of comment 0
// Page of comment 5
1 => 5,
// Page of comment 4
2 => 1,
// Page of comment 4
3 => 1,
// Page of comment 4
4 => 1,
// Page of comment 4
5 => 1,
// Page of comment 0
6 => 0,
];
\Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]);
......
......@@ -166,7 +166,8 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
// Get comment.
if ($contact !== TRUE) {// If true then attempting to find error message.
if ($contact !== TRUE) {
// If true then attempting to find error message.
if ($subject) {
$this->assertText($subject, 'Comment subject posted.');
}
......
......@@ -32,7 +32,8 @@ public function testApprovalAdminInterface() {
'skip comment approval' => FALSE,
]);
$this->drupalLogin($this->adminUser);
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
// Ensure that doesn't require contact info.
$this->setCommentAnonymous('0');
// Test that the comments page loads correctly when there are no comments
$this->drupalGet('admin/content/comment');
......@@ -43,7 +44,8 @@ public function testApprovalAdminInterface() {
// Post anonymous comment without contact info.
$subject = $this->randomMachineName();
$body = $this->randomMachineName();
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
// Set $contact to true so that it won't check for id and message.
$this->postComment($this->node, $body, $subject, TRUE);
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.');
// Get unapproved comment id.
......@@ -123,13 +125,15 @@ public function testApprovalNodeInterface() {
'skip comment approval' => FALSE,
]);
$this->drupalLogin($this->adminUser);
$this->setCommentAnonymous('0'); // Ensure that doesn't require contact info.
// Ensure that doesn't require contact info.
$this->setCommentAnonymous('0');
$this->drupalLogout();
// Post anonymous comment without contact info.
$subject = $this->randomMachineName();
$body = $this->randomMachineName();
$this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
// Set $contact to true so that it won't check for id and message.
$this->postComment($this->node, $body, $subject, TRUE);
$this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), 'Comment requires approval.');
// Get unapproved comment id.
......@@ -205,7 +209,8 @@ public function testEditComment() {
// Post anonymous comment.
$this->drupalLogin($this->adminUser);
$this->setCommentAnonymous('2'); // Ensure that we need email id before posting comment.
// Ensure that we need email id before posting comment.
$this->setCommentAnonymous('2');
$this->drupalLogout();
// Post comment with contact info (required).
......
......@@ -157,7 +157,8 @@ public function postComment(EntityInterface $entity, $comment, $subject = '', $c
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
// Get comment.
if ($contact !== TRUE) {// If true then attempting to find error message.
if ($contact !== TRUE) {
// If true then attempting to find error message.
if ($subject) {
$this->assertText($subject, 'Comment subject posted.');
}
......
......@@ -160,7 +160,8 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
// Get comment.
if ($contact !== TRUE) {// If true then attempting to find error message.
if ($contact !== TRUE) {
// If true then attempting to find error message.
if ($subject) {
$this->assertText($subject, 'Comment subject posted.');
}
......
......@@ -306,7 +306,8 @@ public function testSwitchingSecurity() {
$expected = [
[
'node_id' => 1,
'value' => self::$sampleContent, // No text editor => no XSS filtering.
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
'format' => 'restricted_without_editor',
'switch_to' => [
'restricted_with_editor' => self::$sampleContentSecured,
......@@ -319,7 +320,8 @@ public function testSwitchingSecurity() {
],
[
'node_id' => 2,
'value' => self::$sampleContentSecured, // Text editor => XSS filtering.
// Text editor => XSS filtering.
'value' => self::$sampleContentSecured,
'format' => 'restricted_with_editor',
'switch_to' => [
// No text editor => no XSS filtering.
......@@ -333,7 +335,8 @@ public function testSwitchingSecurity() {
],
[
'node_id' => 3,
'value' => self::$sampleContentSecuredEmbedAllowed, // Text editor => XSS filtering.
// Text editor => XSS filtering.
'value' => self::$sampleContentSecuredEmbedAllowed,
'format' => 'restricted_plus_dangerous_tag_with_editor',
'switch_to' => [
// No text editor => no XSS filtering.
......@@ -348,7 +351,8 @@ public function testSwitchingSecurity() {
],
[
'node_id' => 4,
'value' => self::$sampleContent, // No text editor => no XSS filtering.
// No text editor => no XSS filtering.
'value' => self::$sampleContent,
'format' => 'unrestricted_without_editor',
'switch_to' => [
// No text editor => no XSS filtering.
......@@ -364,7 +368,8 @@ public function testSwitchingSecurity() {
],
[
'node_id' => 5,
'value' => self::$sampleContentSecured, // Text editor => XSS filtering.
// Text editor => XSS filtering.
'value' => self::$sampleContentSecured,
'format' => 'unrestricted_with_editor',
'switch_to' => [
// From editor, no security filters to security filters, no editor: no
......
......@@ -91,9 +91,12 @@ public function testFileCreateUrl() {
// Tilde (~) is excluded from this test because it is encoded by
// rawurlencode() in PHP 5.2 but not in PHP 5.3, as per RFC 3986.
// @see http://php.net/manual/function.rawurlencode.php#86506
$basename = " -._!$'\"()*@[]?&+%#,;=:\n\x00" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
// "Special" ASCII characters.
$basename = " -._!$'\"()*@[]?&+%#,;=:\n\x00" .
// Characters that look like a percent-escaped string.
"%23%25%26%2B%2F%3F" .
// Characters from various non-ASCII alphabets.
"éøïвβ中國書۞";
$basename_encoded = '%20-._%21%24%27%22%28%29%2A%40%5B%5D%3F%26%2B%25%23%2C%3B%3D%3A__' .
'%2523%2525%2526%252B%252F%253F' .
'%C3%A9%C3%B8%C3%AF%D0%B2%CE%B2%E4%B8%AD%E5%9C%8B%E6%9B%B8%DB%9E';
......
......@@ -71,8 +71,10 @@ public function testFileMaxSize() {
$field_name = strtolower($this->randomMachineName());
$this->createFileField($field_name, 'node', $type_name, [], ['required' => '1']);
$small_file = $this->getTestFile('text', 131072); // 128KB.
$large_file = $this->getTestFile('text', 1310720); // 1.2MB
// 128KB.
$small_file = $this->getTestFile('text', 131072);
// 1.2MB
$large_file = $this->getTestFile('text', 1310720);
// Test uploading both a large and small file with different increments.
$sizes = [
......
......@@ -729,20 +729,28 @@ function _filter_autop($text) {
}
}
elseif (!$ignore) {
$chunk = preg_replace('|\n*$|', '', $chunk) . "\n\n"; // just to make things a little easier, pad the end
// just to make things a little easier, pad the end
$chunk = preg_replace('|\n*$|', '', $chunk) . "\n\n";
$chunk = preg_replace('|<br />\s*<br />|', "\n\n", $chunk);
$chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk); // Space things out a little
$chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk); // Space things out a little
$chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates
// Space things out a little
$chunk = preg_replace('!(<' . $block . '[^>]*>)!', "\n$1", $chunk);
// Space things out a little
$chunk = preg_replace('!(</' . $block . '>)!', "$1\n\n", $chunk);
// take care of duplicates
$chunk = preg_replace("/\n\n+/", "\n\n", $chunk);
$chunk = preg_replace('/^\n|\n\s*\n$/', '', $chunk);
$chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n"; // make paragraphs, including one at the end
$chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
// make paragraphs, including one at the end
$chunk = '<p>' . preg_replace('/\n\s*\n\n?(.)/', "</p>\n<p>$1", $chunk) . "</p>\n";
// problem with nested lists
$chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk);
$chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
$chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk);
$chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
// under certain strange conditions it could create a P of entirely whitespace
$chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk);
$chunk = preg_replace('!<p>\s*(</?' . $block . '[^>]*>)!', "$1", $chunk);
$chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk);
$chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
// make line breaks
$chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk);
$chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*<br />!', "$1", $chunk);
$chunk = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $chunk);
$chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
......
......@@ -124,7 +124,8 @@ public function testFilterFormatAPI() {
$full_html_format = FilterFormat::load('full_html');
$this->assertIdentical(
$full_html_format->getHtmlRestrictions(),
FALSE, // Every tag is allowed.
// Every tag is allowed.
FALSE,
'FilterFormatInterface::getHtmlRestrictions() works as expected for the full_html format.'
);
$this->assertIdentical(
......@@ -141,7 +142,8 @@ public function testFilterFormatAPI() {
'filter_html' => [
'status' => 1,
'settings' => [
'allowed_html' => '', // Nothing is allowed.
// Nothing is allowed.
'allowed_html' => '',
],
],
],
......@@ -149,7 +151,8 @@ public function testFilterFormatAPI() {
$stupid_filtered_html_format->save();
$this->assertIdentical(
$stupid_filtered_html_format->getHtmlRestrictions(),
['allowed' => []], // No tag is allowed.
// No tag is allowed.
['allowed' => []],
'FilterFormatInterface::getHtmlRestrictions() works as expected for the stupid_filtered_html format.'
);
$this->assertIdentical(
......
......@@ -111,7 +111,8 @@ function locale_schema() {
'customized' => [
'type' => 'int',
'not null' => TRUE,
'default' => 0, // LOCALE_NOT_CUSTOMIZED
// LOCALE_NOT_CUSTOMIZED
'default' => 0,
'description' => 'Boolean indicating whether the translation is custom to this site.',
],
],
......
......@@ -117,7 +117,8 @@ protected function setUp() {
$node->save();
$node = Node::load($node->id()); // Make sure we get revision information.
// Make sure we get revision information.
$node = Node::load($node->id());
$nodes[] = clone $node;
}
......
......@@ -109,8 +109,10 @@ public function testTimestamps() {
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => $this->randomMachineName(8),
'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
'changed' => 979534800, // Drupal 1.0 release.
// Sun, 19 Nov 1978 05:00:00 GMT.
'created' => 280299600,
// Drupal 1.0 release.
'changed' => 979534800,
];
Node::create($edit)->save();
......
......@@ -170,19 +170,29 @@ public function testBulkForm() {
// operations are always applied to individual translations.
$edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
'node_bulk_form[2]' => TRUE, // Node 1, Italian.
// Node 1, English, original.
'node_bulk_form[0]' => TRUE,
// Node 1, British English.
'node_bulk_form[1]' => TRUE,
// Node 1, Italian.
'node_bulk_form[2]' => TRUE,
// Original and only one translation.
'node_bulk_form[3]' => TRUE, // Node 2, English.
'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
'node_bulk_form[5]' => FALSE, // Node 2, Italian.
// Node 2, English.
'node_bulk_form[3]' => TRUE,
// Node 2, British English, original.
'node_bulk_form[4]' => TRUE,
// Node 2, Italian.
'node_bulk_form[5]' => FALSE,
// Only a single translation.
'node_bulk_form[6]' => TRUE, // Node 3, English.
'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
// Node 3, English.
'node_bulk_form[6]' => TRUE,
// Node 3, Italian, original.
'node_bulk_form[7]' => FALSE,
// Only a single untranslated node.
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
// Node 4, English, untranslated.
'node_bulk_form[8]' => TRUE,
// Node 5, British English, untranslated.
'node_bulk_form[9]' => FALSE,
'action' => 'node_unpublish_action',
];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
......@@ -211,19 +221,29 @@ public function testBulkDeletion() {
// nodes and individual translations are properly deleted.
$edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
'node_bulk_form[2]' => TRUE, // Node 1, Italian.
// Node 1, English, original.
'node_bulk_form[0]' => TRUE,
// Node 1, British English.
'node_bulk_form[1]' => TRUE,
// Node 1, Italian.
'node_bulk_form[2]' => TRUE,
// Original and only one translation.
'node_bulk_form[3]' => TRUE, // Node 2, English.
'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
'node_bulk_form[5]' => FALSE, // Node 2, Italian.
// Node 2, English.
'node_bulk_form[3]' => TRUE,
// Node 2, British English, original.
'node_bulk_form[4]' => TRUE,
// Node 2, Italian.
'node_bulk_form[5]' => FALSE,
// Only a single translation.
'node_bulk_form[6]' => TRUE, // Node 3, English.
'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
// Node 3, English.
'node_bulk_form[6]' => TRUE,
// Node 3, Italian, original.
'node_bulk_form[7]' => FALSE,
// Only a single untranslated node.
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
// Node 4, English, untranslated.
'node_bulk_form[8]' => TRUE,
// Node 5, British English, untranslated.
'node_bulk_form[9]' => FALSE,
'action' => 'node_delete_action',
];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
......
......@@ -143,8 +143,10 @@ protected function lookup(Request $request, $type = self::MASTER_REQUEST, $catch
$if_none_match = $request->server->has('HTTP_IF_NONE_MATCH') ? stripslashes($request->server->get('HTTP_IF_NONE_MATCH')) : FALSE;
if ($if_modified_since && $if_none_match
&& $if_none_match == $response->getEtag() // etag must match
&& $if_modified_since == $last_modified->getTimestamp()) {// if-modified-since must match
// etag must match.
&& $if_none_match == $response->getEtag()
// if-modified-since must match.
&& $if_modified_since == $last_modified->getTimestamp()) {
$response->setStatusCode(304);
$response->setContent(NULL);
......
......@@ -92,7 +92,8 @@ public function testAdminAlias() {
$pid = $this->getPID($edit['alias']);
$previous = $edit['alias'];
$edit['alias'] = '/alias' . // Lower-case letters.
// Lower-case letters.
$edit['alias'] = '/alias' .
// "Special" ASCII characters.
"- ._~!$'\"()*@[]?&+%#,;=:" .
// Characters that look like a percent-escaped string.
......@@ -246,7 +247,8 @@ public function testNodeAlias() {
$previous = $edit['path[0][alias]'];
// Change alias to one containing "exotic" characters.
$edit['path[0][alias]'] = '/alias' . // Lower-case letters.
// Lower-case letters.
$edit['path[0][alias]'] = '/alias' .
// "Special" ASCII characters.
"- ._~!$'\"()*@[]?&+%#,;=:" .
// Characters that look like a percent-escaped string.
......
......@@ -446,14 +446,21 @@ function search_index($type, $sid, $langcode, $text) {
// Note: PHP ensures the array consists of alternating delimiters and literals
// and begins and ends with a literal (inserting $null as required).
$tag = FALSE; // Odd/even counter. Tag or no tag.
$score = 1; // Starting score per word
$accum = ' '; // Accumulator for cleaned up data
$tagstack = []; // Stack with open tags
$tagwords = 0; // Counter for consecutive words
$focus = 1; // Focus state
$scored_words = []; // Accumulator for words for index
// Odd/even counter. Tag or no tag.
$tag = FALSE;
// Starting score per word.
$score = 1;
// Accumulator for cleaned up data.
$accum = ' ';
// Stack with open tags.
$tagstack = [];
// Counter for consecutive words.
$tagwords = 0;
// Focus state.
$focus = 1;
// Accumulator for words for index.
$scored_words = [];
foreach ($split as $value) {
if ($tag) {
......
......@@ -303,9 +303,11 @@ public function testGetMultiple() {
$reference = [
'test3',
'test7',
'test21', // Cid does not exist.
// Cid does not exist.
'test21',
'test6',
'test19', // Cid does not exist until added before second getMultiple().
// Cid does not exist until added before second getMultiple().
'test19',
'test2',
];
......@@ -443,13 +445,16 @@ public function testDeleteMultiple() {
$backend->set('test7', 17);
$backend->delete('test1');
$backend->delete('test23'); // Nonexistent key should not cause an error.
// Nonexistent key should not cause an error.
$backend->delete('test23');
$backend->deleteMultiple([
'test3',
'test5',
'test7',
'test19', // Nonexistent key should not cause an error.
'test21', // Nonexistent key should not cause an error.
// Nonexistent key should not cause an error.
'test19',
// Nonexistent key should not cause an error.
'test21',
]);
// Test if expected keys have been deleted.
......
......@@ -15,7 +15,8 @@ public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key]['title'] = $title;
$this->derivatives[$key]['route_parameters'] = ['placeholder' => $key];
$this->derivatives[$key]['weight'] = $weight++; // ensure weights for testing.
// Ensure weights for testing.
$this->derivatives[$key]['weight'] = $weight++;
}
return $this->derivatives;
}
......
......@@ -194,9 +194,13 @@ protected function doTestMenuOnRoute() {
* Test path containing "exotic" characters.
*/
protected function doTestExoticPath() {
$path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
// "Special" ASCII characters.
$path =
"menu-test/ -._~!$'\"()*@[]?&+%#,;=:" .
// Characters that look like a percent-escaped string.
"%23%25%26%2B%2F%3F" .
// Characters from various non-ASCII alphabets.
"éøïвβ中國書۞";
$this->drupalGet($path);
$this->assertRaw('This is the menuTestCallback content.');
$this->assertNoText(t('The website encountered an unexpected error. Please try again later.'));
......
......@@ -35,10 +35,15 @@ public function testFirstSentenceQuestion() {
* Test summary with long example.
*/
public function testLongSentence() {
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' . // 125
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ' . // 108
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' . // 103
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; // 110
// 125.
$text =
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' .
// 108.
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ' .
// 103.
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' .
// 110.
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
$expected = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' .
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ' .
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.';
......
......@@ -115,7 +115,8 @@ public function adminSummary() {
$this->valueOptions[$account->id()] = $account->label();
}
else {
$this->valueOptions[$account->id()] = 'Anonymous'; // Intentionally NOT translated.
// Intentionally NOT translated.
$this->valueOptions[$account->id()] = 'Anonymous';
}
}
}
......
......@@ -328,7 +328,8 @@ public function testUserAnonymize() {
$revision = $revision_node->getRevisionId();
$settings = get_object_vars($revision_node);
$settings['revision'] = 1;
$settings['uid'] = 1; // Set new/current revision to someone else.
// Set new/current revision to someone else.