diff --git a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
index 21334c3..605bdbb 100644
--- a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
+++ b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php
@@ -13,6 +13,11 @@
* @group search
*/
class SearchAdvancedSearchFormTest extends SearchTestBase {
+ /**
+ * A node to use for testing.
+ *
+ * @var \Drupal\ndoe\NodeInterface
+ */
protected $node;
protected function setUp() {
diff --git a/core/modules/search/src/Tests/SearchCommentCountToggleTest.php b/core/modules/search/src/Tests/SearchCommentCountToggleTest.php
index 10d7cf1..5f2fd43 100644
--- a/core/modules/search/src/Tests/SearchCommentCountToggleTest.php
+++ b/core/modules/search/src/Tests/SearchCommentCountToggleTest.php
@@ -30,25 +30,36 @@ class SearchCommentCountToggleTest extends SearchTestBase {
*/
public static $modules = array('node', 'comment');
- protected $searching_user;
- protected $searchable_nodes;
+ /**
+ * A user with permission to search and post comments.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $searchingUser;
+
+ /**
+ * Array of nodes available to search.
+ *
+ * @var \Drupal\node\NodeInterface[]
+ */
+ protected $searchableNodes;
protected function setUp() {
parent::setUp();
// Create searching user.
- $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'post comments', 'skip comment approval'));
+ $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'post comments', 'skip comment approval'));
// Login with sufficient privileges.
- $this->drupalLogin($this->searching_user);
+ $this->drupalLogin($this->searchingUser);
// Add a comment field.
$this->container->get('comment.manager')->addDefaultField('node', 'article');
// Create initial nodes.
$node_params = array('type' => 'article', 'body' => array(array('value' => 'SearchCommentToggleTestCase')));
- $this->searchable_nodes['1 comment'] = $this->drupalCreateNode($node_params);
- $this->searchable_nodes['0 comments'] = $this->drupalCreateNode($node_params);
+ $this->searchableNodes['1 comment'] = $this->drupalCreateNode($node_params);
+ $this->searchableNodes['0 comments'] = $this->drupalCreateNode($node_params);
// Create a comment array
$edit_comment = array();
@@ -56,7 +67,7 @@ protected function setUp() {
$edit_comment['comment_body[0][value]'] = $this->randomMachineName();
// Post comment to the test node with comment
- $this->drupalPostForm('comment/reply/node/' . $this->searchable_nodes['1 comment']->id() . '/comment', $edit_comment, t('Save'));
+ $this->drupalPostForm('comment/reply/node/' . $this->searchableNodes['1 comment']->id() . '/comment', $edit_comment, t('Save'));
// First update the index. This does the initial processing.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
@@ -83,20 +94,20 @@ function testSearchCommentCountToggle() {
$this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Open');
// Test comment count display for nodes with comment status set to Closed
- $this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::CLOSED);
- $this->searchable_nodes['0 comments']->save();
- $this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::CLOSED);
- $this->searchable_nodes['1 comment']->save();
+ $this->searchableNodes['0 comments']->set('comment', CommentItemInterface::CLOSED);
+ $this->searchableNodes['0 comments']->save();
+ $this->searchableNodes['1 comment']->set('comment', CommentItemInterface::CLOSED);
+ $this->searchableNodes['1 comment']->save();
$this->drupalPostForm(NULL, $edit, t('Search'));
$this->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Closed');
$this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Closed');
// Test comment count display for nodes with comment status set to Hidden
- $this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::HIDDEN);
- $this->searchable_nodes['0 comments']->save();
- $this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::HIDDEN);
- $this->searchable_nodes['1 comment']->save();
+ $this->searchableNodes['0 comments']->set('comment', CommentItemInterface::HIDDEN);
+ $this->searchableNodes['0 comments']->save();
+ $this->searchableNodes['1 comment']->set('comment', CommentItemInterface::HIDDEN);
+ $this->searchableNodes['1 comment']->save();
$this->drupalPostForm(NULL, $edit, t('Search'));
$this->assertNoText(t('0 comments'), 'Empty comment count does not display for nodes with comment status set to Hidden');
diff --git a/core/modules/search/src/Tests/SearchCommentTest.php b/core/modules/search/src/Tests/SearchCommentTest.php
index ad377da..1818350 100644
--- a/core/modules/search/src/Tests/SearchCommentTest.php
+++ b/core/modules/search/src/Tests/SearchCommentTest.php
@@ -25,7 +25,33 @@ class SearchCommentTest extends SearchTestBase {
*/
public static $modules = array('filter', 'node', 'comment');
- protected $admin_user;
+ /**
+ * Test subject for comments.
+ *
+ * @var string
+ */
+ protected $commentSubject;
+
+ /**
+ * ID for the administrator role.
+ *
+ * @var string
+ */
+ protected $adminRole;
+
+ /**
+ * A user with various administrative permissions.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
+ /**
+ * Test node for searching.
+ *
+ * @var \Drupal\node\NodeInterface
+ */
+ protected $node;
protected function setUp() {
parent::setUp();
@@ -49,8 +75,8 @@ protected function setUp() {
'skip comment approval',
'access comments',
);
- $this->admin_user = $this->drupalCreateUser($permissions);
- $this->drupalLogin($this->admin_user);
+ $this->adminUser = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($this->adminUser);
// Add a comment field.
$this->container->get('comment.manager')->addDefaultField('node', 'article');
}
@@ -124,7 +150,7 @@ function testSearchResultsComment() {
$this->assertNoEscaped($edit_comment['comment_body[0][value]'], 'HTML in comment body is not escaped.');
// Hide comments.
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$node->set('comment', CommentItemInterface::HIDDEN);
$node->save();
@@ -142,9 +168,9 @@ function testSearchResultsComment() {
*/
function testSearchResultsCommentAccess() {
$comment_body = 'Test comment body';
- $this->comment_subject = 'Test comment subject';
- $roles = $this->admin_user->getRoles(TRUE);
- $this->admin_role = $roles[0];
+ $this->commentSubject = 'Test comment subject';
+ $roles = $this->adminUser->getRoles(TRUE);
+ $this->adminRole = $roles[0];
// Create a node.
// Make preview optional.
@@ -155,7 +181,7 @@ function testSearchResultsCommentAccess() {
// Post a comment using 'Full HTML' text format.
$edit_comment = array();
- $edit_comment['subject[0][value]'] = $this->comment_subject;
+ $edit_comment['subject[0][value]'] = $this->commentSubject;
$edit_comment['comment_body[0][value]'] = '
' . $comment_body . '
';
$this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit_comment, t('Save'));
@@ -166,17 +192,17 @@ function testSearchResultsCommentAccess() {
$this->setRolePermissions(DRUPAL_ANONYMOUS_RID, TRUE);
$this->assertCommentAccess(TRUE, 'Anon user has search permission and access comments permission, comments should be indexed');
- $this->drupalLogin($this->admin_user);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/people/permissions');
// Disable search access for authenticated user to test admin user.
$this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, FALSE, FALSE);
- $this->setRolePermissions($this->admin_role);
+ $this->setRolePermissions($this->adminRole);
$this->assertCommentAccess(FALSE, 'Admin user has search permission but no access comments permission, comments should not be indexed');
$this->drupalGet('node/' . $this->node->id());
- $this->setRolePermissions($this->admin_role, TRUE);
+ $this->setRolePermissions($this->adminRole, TRUE);
$this->assertCommentAccess(TRUE, 'Admin user has search permission and access comments permission, comments should be indexed');
$this->setRolePermissions(DRUPAL_AUTHENTICATED_RID);
@@ -188,13 +214,13 @@ function testSearchResultsCommentAccess() {
// Verify that access comments permission is inherited from the
// authenticated role.
$this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, FALSE);
- $this->setRolePermissions($this->admin_role);
+ $this->setRolePermissions($this->adminRole);
$this->assertCommentAccess(TRUE, 'Admin user has search permission and no access comments permission, but comments should be indexed because admin user inherits authenticated user\'s permission to access comments');
// Verify that search content permission is inherited from the authenticated
// role.
$this->setRolePermissions(DRUPAL_AUTHENTICATED_RID, TRUE, TRUE);
- $this->setRolePermissions($this->admin_role, TRUE, FALSE);
+ $this->setRolePermissions($this->adminRole, TRUE, FALSE);
$this->assertCommentAccess(TRUE, 'Admin user has access comments permission and no search permission, but comments should be indexed because admin user inherits authenticated user\'s permission to search');
}
@@ -219,13 +245,13 @@ function assertCommentAccess($assume_access, $message) {
// Search for the comment subject.
$edit = array(
- 'keys' => "'" . $this->comment_subject . "'",
+ 'keys' => "'" . $this->commentSubject . "'",
);
$this->drupalPostForm('search/node', $edit, t('Search'));
if ($assume_access) {
$expected_node_result = $this->assertText($this->node->label());
- $expected_comment_result = $this->assertText($this->comment_subject);
+ $expected_comment_result = $this->assertText($this->commentSubject);
}
else {
$expected_node_result = $this->assertText(t('Your search yielded no results.'));
diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
index 749628f..7d99214 100644
--- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
@@ -26,25 +26,25 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
*
* @var \Drupal\user\UserInterface
*/
- public $search_user;
+ protected $searchUser;
/**
* Node indexed for searching.
*
* @var \Drupal\node\NodeInterface
*/
- public $search_node;
+ protected $searchNode;
protected function setUp() {
parent::setUp();
// Login as a user that can create and search content.
- $this->search_user = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports'));
- $this->drupalLogin($this->search_user);
+ $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search', 'administer nodes', 'bypass node access', 'access user profiles', 'administer users', 'administer blocks', 'access site reports'));
+ $this->drupalLogin($this->searchUser);
// Add a single piece of content and index it.
$node = $this->drupalCreateNode();
- $this->search_node = $node;
+ $this->searchNode = $node;
// Link the node to itself to test that it's only indexed once. The content
// also needs the word "pizza" so we can use it as the search keyword.
$body_key = 'body[0][value]';
@@ -133,11 +133,11 @@ function testSearchModuleDisabling() {
$plugin_info = array(
'node_search' => array(
'keys' => 'pizza',
- 'text' => $this->search_node->label(),
+ 'text' => $this->searchNode->label(),
),
'user_search' => array(
- 'keys' => $this->search_user->getUsername(),
- 'text' => $this->search_user->getEmail(),
+ 'keys' => $this->searchUser->getUsername(),
+ 'text' => $this->searchUser->getEmail(),
),
'dummy_search_type' => array(
'keys' => 'foo',
diff --git a/core/modules/search/src/Tests/SearchEmbedFormTest.php b/core/modules/search/src/Tests/SearchEmbedFormTest.php
index 2635dbe..edfe220 100644
--- a/core/modules/search/src/Tests/SearchEmbedFormTest.php
+++ b/core/modules/search/src/Tests/SearchEmbedFormTest.php
@@ -23,13 +23,17 @@ class SearchEmbedFormTest extends SearchTestBase {
/**
* Node used for testing.
+ *
+ * @var \Drupal\node\NodeInterface
*/
- public $node;
+ protected $node;
/**
* Count of how many times the form has been submitted.
+ *
+ * @var int
*/
- public $submit_count = 0;
+ protected $submitCount = 0;
protected function setUp() {
parent::setUp();
@@ -44,7 +48,7 @@ protected function setUp() {
search_update_totals();
// Set up a dummy initial count of times the form has been submitted.
- $this->submit_count = \Drupal::state()->get('search_embedded_form.submit_count');
+ $this->submitCount = \Drupal::state()->get('search_embedded_form.submit_count');
$this->refreshVariables();
}
@@ -58,8 +62,8 @@ function testEmbeddedForm() {
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
- $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
- $this->submit_count = $count;
+ $this->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
+ $this->submitCount = $count;
// Now verify that we can see and submit the form from the search results.
$this->drupalGet('search/node', array('query' => array('keys' => $this->node->label())));
@@ -69,8 +73,8 @@ function testEmbeddedForm() {
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
- $this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
- $this->submit_count = $count;
+ $this->assertEqual($this->submitCount + 1, $count, 'Form submission count is correct');
+ $this->submitCount = $count;
// Now verify that if we submit the search form, it doesn't count as
// our form being submitted.
@@ -79,7 +83,7 @@ function testEmbeddedForm() {
t('Search'));
$this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
- $this->assertEqual($this->submit_count, $count, 'Form submission count is correct');
- $this->submit_count = $count;
+ $this->assertEqual($this->submitCount, $count, 'Form submission count is correct');
+ $this->submitCount = $count;
}
}
diff --git a/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php b/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
index 789687f..c5e42f1 100644
--- a/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/src/Tests/SearchKeywordsConditionsTest.php
@@ -25,13 +25,20 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
*/
public static $modules = array('comment', 'search_extra_type');
+ /**
+ * A user with permission to search and post comments.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $searchingUser;
+
protected function setUp() {
parent::setUp();
// Create searching user.
- $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval'));
+ $this->searchingUser = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval'));
// Login with sufficient privileges.
- $this->drupalLogin($this->searching_user);
+ $this->drupalLogin($this->searchingUser);
}
/**
diff --git a/core/modules/search/src/Tests/SearchLanguageTest.php b/core/modules/search/src/Tests/SearchLanguageTest.php
index d576983..6376dd0 100644
--- a/core/modules/search/src/Tests/SearchLanguageTest.php
+++ b/core/modules/search/src/Tests/SearchLanguageTest.php
@@ -24,6 +24,13 @@ class SearchLanguageTest extends SearchTestBase {
*/
public static $modules = array('language');
+ /**
+ * Array of nodes available to search.
+ *
+ * @var \Drupal\node\NodeInterface[]
+ */
+ protected $searchableNodes;
+
protected function setUp() {
parent::setUp();
@@ -63,20 +70,20 @@ protected function setUp() {
'langcode' => 'en',
),
);
- $this->searchable_nodes = array();
+ $this->searchableNodes = [];
foreach ($nodes as $setting) {
- $this->searchable_nodes[] = $this->drupalCreateNode($setting);
+ $this->searchableNodes[] = $this->drupalCreateNode($setting);
}
// Add English translation to the second node.
- $translation = $this->searchable_nodes[1]->addTranslation('en', array('title' => 'Second node en'));
+ $translation = $this->searchableNodes[1]->addTranslation('en', array('title' => 'Second node en'));
$translation->body->value = $this->randomMachineName(32);
- $this->searchable_nodes[1]->save();
+ $this->searchableNodes[1]->save();
// Add Spanish translation to the third node.
- $translation = $this->searchable_nodes[2]->addTranslation('es', array('title' => 'Third node es'));
+ $translation = $this->searchableNodes[2]->addTranslation('es', array('title' => 'Third node es'));
$translation->body->value = $this->randomMachineName(32);
- $this->searchable_nodes[2]->save();
+ $this->searchableNodes[2]->save();
// Update the index and then run the shutdown method.
$plugin = $this->container->get('plugin.manager.search')->createInstance('node_search');
diff --git a/core/modules/search/src/Tests/SearchMultilingualEntityTest.php b/core/modules/search/src/Tests/SearchMultilingualEntityTest.php
index f08e50e..5c4e209 100644
--- a/core/modules/search/src/Tests/SearchMultilingualEntityTest.php
+++ b/core/modules/search/src/Tests/SearchMultilingualEntityTest.php
@@ -20,9 +20,9 @@ class SearchMultilingualEntityTest extends SearchTestBase {
/**
* List of searchable nodes.
*
- * @var array
+ * @var \Drupal\node\NodeInterface[]
*/
- protected $searchable_nodes = array();
+ protected $searchableNodes = array();
/**
* Node search plugin.
@@ -97,22 +97,22 @@ protected function setUp() {
array(
),
);
- $this->searchable_nodes = array();
+ $this->searchableNodes = array();
foreach ($nodes as $setting) {
- $this->searchable_nodes[] = $this->drupalCreateNode($setting);
+ $this->searchableNodes[] = $this->drupalCreateNode($setting);
}
// Add a single translation to the second node.
- $translation = $this->searchable_nodes[1]->addTranslation('hu', array('title' => 'Second node hu'));
+ $translation = $this->searchableNodes[1]->addTranslation('hu', array('title' => 'Second node hu'));
$translation->body->value = $this->randomMachineName(32);
- $this->searchable_nodes[1]->save();
+ $this->searchableNodes[1]->save();
// Add two translations to the third node.
- $translation = $this->searchable_nodes[2]->addTranslation('hu', array('title' => 'Third node this is the Hungarian title'));
+ $translation = $this->searchableNodes[2]->addTranslation('hu', array('title' => 'Third node this is the Hungarian title'));
$translation->body->value = $this->randomMachineName(32);
- $translation = $this->searchable_nodes[2]->addTranslation('sv', array('title' => 'Third node sv'));
+ $translation = $this->searchableNodes[2]->addTranslation('sv', array('title' => 'Third node sv'));
$translation->body->value = $this->randomMachineName(32);
- $this->searchable_nodes[2]->save();
+ $this->searchableNodes[2]->save();
// Verify that we have 8 nodes left to do.
$this->assertIndexCounts(8, 8, 'before updating the search index');
@@ -196,7 +196,7 @@ function testMultilingualSearch() {
// Mark one of the nodes for reindexing, using the API function, and
// verify indexing status.
- search_mark_for_reindex('node_search', $this->searchable_nodes[0]->id());
+ search_mark_for_reindex('node_search', $this->searchableNodes[0]->id());
$this->assertIndexCounts(1, 8, 'after marking one node to reindex via API function');
// Update the index and verify the totals again.
@@ -206,7 +206,7 @@ function testMultilingualSearch() {
$this->assertIndexCounts(0, 8, 'after indexing again');
// Mark one node for reindexing by saving it, and verify indexing status.
- $this->searchable_nodes[1]->save();
+ $this->searchableNodes[1]->save();
$this->assertIndexCounts(1, 8, 'after marking one node to reindex via save');
// The request time is always the same throughout test runs. Update the
@@ -220,11 +220,11 @@ function testMultilingualSearch() {
->execute();
// Save the node again. Verify that the request time on it is not updated.
- $this->searchable_nodes[1]->save();
+ $this->searchableNodes[1]->save();
$result = db_select('search_dataset', 'd')
->fields('d', array('reindex'))
->condition('type', 'node_search')
- ->condition('sid', $this->searchable_nodes[1]->id())
+ ->condition('sid', $this->searchableNodes[1]->id())
->execute()
->fetchField();
$this->assertEqual($result, $old, 'Reindex time was not updated if node was already marked');
@@ -232,7 +232,7 @@ function testMultilingualSearch() {
// Add a bogus entry to the search index table using a different search
// type. This will not appear in the index status, because it is not
// managed by a plugin.
- search_index('foo', $this->searchable_nodes[0]->id(), 'en', 'some text');
+ search_index('foo', $this->searchableNodes[0]->id(), 'en', 'some text');
$this->assertIndexCounts(1, 8, 'after adding a different index item');
// Mark just this "foo" index for reindexing.
@@ -245,13 +245,13 @@ function testMultilingualSearch() {
// Clear one item from the index, but with wrong language.
$this->assertDatabaseCounts(8, 1, 'before clear');
- search_index_clear('node_search', $this->searchable_nodes[0]->id(), 'hu');
+ search_index_clear('node_search', $this->searchableNodes[0]->id(), 'hu');
$this->assertDatabaseCounts(8, 1, 'after clear with wrong language');
// Clear using correct language.
- search_index_clear('node_search', $this->searchable_nodes[0]->id(), 'en');
+ search_index_clear('node_search', $this->searchableNodes[0]->id(), 'en');
$this->assertDatabaseCounts(7, 1, 'after clear with right language');
// Don't specify language.
- search_index_clear('node_search', $this->searchable_nodes[1]->id());
+ search_index_clear('node_search', $this->searchableNodes[1]->id());
$this->assertDatabaseCounts(6, 1, 'unspecified language clear');
// Clear everything in 'foo'.
search_index_clear('foo');
diff --git a/core/modules/search/src/Tests/SearchNodePunctuationTest.php b/core/modules/search/src/Tests/SearchNodePunctuationTest.php
index c9405cb..6f1c91a 100644
--- a/core/modules/search/src/Tests/SearchNodePunctuationTest.php
+++ b/core/modules/search/src/Tests/SearchNodePunctuationTest.php
@@ -14,15 +14,20 @@
*/
class SearchNodePunctuationTest extends SearchTestBase {
- public $test_user;
+ /**
+ * A user with permission to use advanced search.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ public $testUser;
protected function setUp() {
parent::setUp();
node_access_rebuild();
// Create a test user and log in.
- $this->test_user = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search'));
- $this->drupalLogin($this->test_user);
+ $this->testUser = $this->drupalCreateUser(array('access content', 'search content', 'use advanced search'));
+ $this->drupalLogin($this->testUser);
}
/**
diff --git a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php b/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
index 6287da2..7a4befb 100644
--- a/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
+++ b/core/modules/search/src/Tests/SearchNodeUpdateAndDeletionTest.php
@@ -20,14 +20,19 @@ class SearchNodeUpdateAndDeletionTest extends SearchTestBase {
*/
public static $modules = array();
- public $test_user;
+ /**
+ * A user with permission to access and search content.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ public $testUser;
protected function setUp() {
parent::setUp();
// Create a test user and log in.
- $this->test_user = $this->drupalCreateUser(array('access content', 'search content'));
- $this->drupalLogin($this->test_user);
+ $this->testUser = $this->drupalCreateUser(array('access content', 'search content'));
+ $this->drupalLogin($this->testUser);
}
/**
diff --git a/core/modules/search/src/Tests/SearchNumberMatchingTest.php b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
index 330d8a7..748596d 100644
--- a/core/modules/search/src/Tests/SearchNumberMatchingTest.php
+++ b/core/modules/search/src/Tests/SearchNumberMatchingTest.php
@@ -15,29 +15,45 @@
* @group search
*/
class SearchNumberMatchingTest extends SearchTestBase {
- protected $test_user;
- protected $numbers;
+ /**
+ * A user with permission to administer nodes.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $testUser;
+
+ /**
+ * An array of strings containing numbers to use for testing.
+ *
+ * Define a group of numbers that should all match each other --
+ * numbers with internal punctuation should match each other, as well
+ * as numbers with and without leading zeros and leading/trailing
+ * . and -.
+ *
+ * @var string[]
+ */
+ protected $numbers = array(
+ '123456789',
+ '12/34/56789',
+ '12.3456789',
+ '12-34-56789',
+ '123,456,789',
+ '-123456789',
+ '0123456789',
+ );
+
+ /**
+ * An array of nodes created for testing purposes.
+ *
+ * @var \Drupal\node\NodeInterface[]
+ */
protected $nodes;
protected function setUp() {
parent::setUp();
- $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
- $this->drupalLogin($this->test_user);
-
- // Define a group of numbers that should all match each other --
- // numbers with internal punctuation should match each other, as well
- // as numbers with and without leading zeros and leading/trailing
- // . and -.
- $this->numbers = array(
- '123456789',
- '12/34/56789',
- '12.3456789',
- '12-34-56789',
- '123,456,789',
- '-123456789',
- '0123456789',
- );
+ $this->testUser = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
+ $this->drupalLogin($this->testUser);
foreach ($this->numbers as $num) {
$info = array(
diff --git a/core/modules/search/src/Tests/SearchNumbersTest.php b/core/modules/search/src/Tests/SearchNumbersTest.php
index 3747db7..18e76ba 100644
--- a/core/modules/search/src/Tests/SearchNumbersTest.php
+++ b/core/modules/search/src/Tests/SearchNumbersTest.php
@@ -15,35 +15,51 @@
* @group search
*/
class SearchNumbersTest extends SearchTestBase {
- protected $test_user;
- protected $numbers;
+ /**
+ * A user with permission to administer nodes.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $testUser;
+
+ /**
+ * An array containing a series of "numbers" for testing purposes.
+ *
+ * Create content with various numbers in it.
+ * Note: 50 characters is the current limit of the search index's word
+ * field.
+ *
+ * @var string[]
+ */
+ protected $numbers = array(
+ 'ISBN' => '978-0446365383',
+ 'UPC' => '036000 291452',
+ 'EAN bar code' => '5901234123457',
+ 'negative' => '-123456.7890',
+ 'quoted negative' => '"-123456.7890"',
+ 'leading zero' => '0777777777',
+ 'tiny' => '111',
+ 'small' => '22222222222222',
+ 'medium' => '333333333333333333333333333',
+ 'large' => '444444444444444444444444444444444444444',
+ 'gigantic' => '5555555555555555555555555555555555555555555555555',
+ 'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666',
+ 'date' => '01/02/2009',
+ 'commas' => '987,654,321',
+ );
+
+ /**
+ * An array of nodes created for testing purposes.
+ *
+ * @var \Drupal\node\NodeInterface[]
+ */
protected $nodes;
protected function setUp() {
parent::setUp();
- $this->test_user = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
- $this->drupalLogin($this->test_user);
-
- // Create content with various numbers in it.
- // Note: 50 characters is the current limit of the search index's word
- // field.
- $this->numbers = array(
- 'ISBN' => '978-0446365383',
- 'UPC' => '036000 291452',
- 'EAN bar code' => '5901234123457',
- 'negative' => '-123456.7890',
- 'quoted negative' => '"-123456.7890"',
- 'leading zero' => '0777777777',
- 'tiny' => '111',
- 'small' => '22222222222222',
- 'medium' => '333333333333333333333333333',
- 'large' => '444444444444444444444444444444444444444',
- 'gigantic' => '5555555555555555555555555555555555555555555555555',
- 'over fifty characters' => '666666666666666666666666666666666666666666666666666666666666',
- 'date' => '01/02/2009',
- 'commas' => '987,654,321',
- );
+ $this->testUser = $this->drupalCreateUser(array('search content', 'access content', 'administer nodes', 'access site reports'));
+ $this->drupalLogin($this->testUser);
foreach ($this->numbers as $doc => $num) {
$info = array(
diff --git a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
index d5aa9ec..da975f6 100644
--- a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
+++ b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
@@ -13,23 +13,30 @@
* @group search
*/
class SearchPageCacheTagsTest extends SearchTestBase {
-
+ /**
+ * {@inheritdoc}
+ */
protected $dumpHeaders = TRUE;
- protected $searching_user;
+ /**
+ * A user with permission to search content.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $searchingUser;
protected function setUp() {
parent::setUp();
// Create user.
- $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles'));
+ $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles'));
}
/**
* Tests the presence of the expected cache tag in various situations.
*/
function testSearchText() {
- $this->drupalLogin($this->searching_user);
+ $this->drupalLogin($this->searchingUser);
// Initial page for searching nodes.
$this->drupalGet('search/node');
@@ -49,7 +56,7 @@ function testSearchText() {
$this->assertTrue(in_array('search_page:user_search', $cache_tags));
// User search results.
- $edit['keys'] = $this->searching_user->getUsername();
+ $edit['keys'] = $this->searchingUser->getUsername();
$this->drupalPostForm('search/user', $edit, t('Search'));
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('search_page:user_search', $cache_tags));
diff --git a/core/modules/search/src/Tests/SearchPageOverrideTest.php b/core/modules/search/src/Tests/SearchPageOverrideTest.php
index ed6a75f..6817773 100644
--- a/core/modules/search/src/Tests/SearchPageOverrideTest.php
+++ b/core/modules/search/src/Tests/SearchPageOverrideTest.php
@@ -24,14 +24,19 @@ class SearchPageOverrideTest extends SearchTestBase {
*/
public static $modules = array('search_extra_type');
- public $search_user;
+ /**
+ * A user with permission to administer search.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ public $searchUser;
protected function setUp() {
parent::setUp();
// Login as a user that can create and search content.
- $this->search_user = $this->drupalCreateUser(array('search content', 'administer search'));
- $this->drupalLogin($this->search_user);
+ $this->searchUser = $this->drupalCreateUser(array('search content', 'administer search'));
+ $this->drupalLogin($this->searchUser);
}
function testSearchPageHook() {
diff --git a/core/modules/search/src/Tests/SearchPageTextTest.php b/core/modules/search/src/Tests/SearchPageTextTest.php
index 5cb4865..328b685 100644
--- a/core/modules/search/src/Tests/SearchPageTextTest.php
+++ b/core/modules/search/src/Tests/SearchPageTextTest.php
@@ -16,20 +16,25 @@
* @group search
*/
class SearchPageTextTest extends SearchTestBase {
- protected $searching_user;
+ /**
+ * A user with permission to use advanced search.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $searchingUser;
protected function setUp() {
parent::setUp();
// Create user.
- $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search'));
+ $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles', 'use advanced search'));
}
/**
* Tests the failed search text, and various other text on the search page.
*/
function testSearchText() {
- $this->drupalLogin($this->searching_user);
+ $this->drupalLogin($this->searchingUser);
$this->drupalGet('search/node');
$this->assertText(t('Enter your keywords'));
$this->assertText(t('Search'));
@@ -61,10 +66,10 @@ function testSearchText() {
$actual_title = (string) current($this->xpath('//title'));
$this->assertEqual($actual_title, String::decodeEntities(t($title_source, array('@keywords' => Unicode::truncate($search_terms, 60, TRUE, TRUE)))), 'Search page title is correct');
- $edit['keys'] = $this->searching_user->getUsername();
+ $edit['keys'] = $this->searchingUser->getUsername();
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->assertText(t('Search'));
- $this->assertTitle(t($title_source, array('@keywords' => Unicode::truncate($this->searching_user->getUsername(), 60, TRUE, TRUE))));
+ $this->assertTitle(t($title_source, array('@keywords' => Unicode::truncate($this->searchingUser->getUsername(), 60, TRUE, TRUE))));
// Test that search keywords containing slashes are correctly loaded
// from the GET params and displayed in the search form.
diff --git a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
index 0093e6a..fbac74d 100644
--- a/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
+++ b/core/modules/search/src/Tests/SearchPreprocessLangcodeTest.php
@@ -20,6 +20,13 @@ class SearchPreprocessLangcodeTest extends SearchTestBase {
*/
public static $modules = array('search_langcode_test');
+ /**
+ * Test node for searching.
+ *
+ * @var \Drupal\node\NodeInterface
+ */
+ protected $node;
+
protected function setUp() {
parent::setUp();