diff --git a/src/Tests/OverviewPageTest.php b/src/Tests/OverviewPageTest.php index 1cbea11..97aeec3 100644 --- a/src/Tests/OverviewPageTest.php +++ b/src/Tests/OverviewPageTest.php @@ -66,8 +66,8 @@ class OverviewPageTest extends WebTestBase { // Test that an entity without bundles can be used as data source. // @todo Why is this here? This hasn't got anything to do with the overview. $edit = array( - 'name' => $this->randomMachineName(), - 'id' => Unicode::strtolower($this->randomMachineName()), + 'name' => 'test Name', + 'id' => 'test_name', 'datasources[]' => 'entity:user', ); $this->drupalPostForm('admin/config/search/search-api/add-index', $edit, $this->t('Save')); diff --git a/src/Tests/Processor/ContentAccessTest.php b/src/Tests/Processor/ContentAccessTest.php index 9221b66..b301cd4 100644 --- a/src/Tests/Processor/ContentAccessTest.php +++ b/src/Tests/Processor/ContentAccessTest.php @@ -199,7 +199,7 @@ class ContentAccessTest extends ProcessorTestBase { 'datasource' => 'entity:comment', 'item' => $comment->getTypedData(), 'item_id' => $comment->id(), - 'text' => $this->randomMachineName(), + 'text' => 'Comment: ' . $comment->id(), ); } $items = $this->generateItems($items); @@ -221,7 +221,7 @@ class ContentAccessTest extends ProcessorTestBase { 'datasource' => 'entity:comment', 'item' => $comment->getTypedData(), 'item_id' => $comment->id(), - 'field_text' => $this->randomMachineName(), + 'field_text' => 'Text: &' . $comment->id(), ); } $items = $this->generateItems($items); diff --git a/src/Tests/Processor/ProcessorTestBase.php b/src/Tests/Processor/ProcessorTestBase.php index 49ab6ac..2809c31 100644 --- a/src/Tests/Processor/ProcessorTestBase.php +++ b/src/Tests/Processor/ProcessorTestBase.php @@ -71,10 +71,9 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { // Batch API gets confused and the test fails. \Drupal::state()->set('search_api_use_tracking_batch', FALSE); - $server_name = $this->randomMachineName(); $this->server = Server::create(array( - 'id' => strtolower($server_name), - 'name' => $server_name, + 'id' => 'server', + 'name' => 'Server & Name', 'status' => TRUE, 'backend' => 'search_api_db', 'backend_config' => array( @@ -84,13 +83,12 @@ abstract class ProcessorTestBase extends EntityUnitTestBase { )); $this->server->save(); - $index_name = $this->randomMachineName(); $this->index = Index::create(array( - 'id' => strtolower($index_name), - 'name' => $index_name, + 'id' => 'index', + 'name' => 'Index name', 'status' => TRUE, 'datasources' => array('entity:comment', 'entity:node'), - 'server' => $server_name, + 'server' => 'server', 'tracker' => 'default', )); $this->index->setServer($this->server); diff --git a/src/Tests/Processor/RenderedItemTest.php b/src/Tests/Processor/RenderedItemTest.php index 7e0af2a..8a920e4 100644 --- a/src/Tests/Processor/RenderedItemTest.php +++ b/src/Tests/Processor/RenderedItemTest.php @@ -31,13 +31,6 @@ class RenderedItemTest extends ProcessorTestBase { protected $nodes; /** - * Data for all nodes which are published. - * - * @var array - */ - protected $nodeData; - - /** * Modules to enable for this test. * * @var string[] @@ -79,19 +72,25 @@ class RenderedItemTest extends ProcessorTestBase { $anonymous_user->save(); // Default node values for all nodes we create below. - $this->nodeData = array( + $node_data = array( 'status' => NODE_PUBLISHED, 'type' => 'page', - 'title' => $this->randomMachineName(8), - 'body' => array('value' => $this->randomMachineName(32), 'summary' => $this->randomMachineName(16), 'format' => 'plain_text'), + 'title' => '', + 'body' => array('value' => '', 'summary' => '', 'format' => 'plain_text'), 'uid' => $anonymous_user->id(), ); // Create some test nodes with valid user on it for rendering a picture. - $this->nodes[0] = Node::create($this->nodeData); - $this->nodes[0]->save(); - $this->nodes[1] = Node::create($this->nodeData); + $node_data['title'] = 'Title for node 1'; + $node_data['body']['value'] = 'value for node 1'; + $node_data['body']['summary'] = 'summary for node 1'; + $this->nodes[1] = Node::create($node_data); $this->nodes[1]->save(); + $node_data['title'] = 'Title for node 2'; + $node_data['body']['value'] = 'value for node 2'; + $node_data['body']['summary'] = 'summary for node 2'; + $this->nodes[2] = Node::create($node_data); + $this->nodes[2]->save(); // Set proper configuration for the tested processor. $config = $this->processor->getConfiguration(); @@ -125,7 +124,7 @@ class RenderedItemTest extends ProcessorTestBase { 'datasource' => 'entity:node', 'item' => $node->getTypedData(), 'item_id' => $node->id(), - 'text' => $this->randomMachineName(), + 'text' => 'node text' . $node->id(), ); } $items = $this->generateItems($items); @@ -146,9 +145,9 @@ class RenderedItemTest extends ProcessorTestBase { // adding it to the output. $this->assertTrue(substr_count($values[0], 'view-mode-full') > 0, 'Node item ' . $nid . ' rendered in view-mode "full".'); $this->assertTrue(substr_count($values[0], 'field--name-title') > 0, 'Node item ' . $nid . ' has a rendered title field.'); - $this->assertTrue(substr_count($values[0], '>' . $this->nodeData['title'] . '<') > 0, 'Node item ' . $nid . ' has a rendered title inside HTML-Tags.'); + $this->assertTrue(substr_count($values[0], '>' . $this->nodes[$nid]->label() . '<') > 0, 'Node item ' . $nid . ' has a rendered title inside HTML-Tags.'); $this->assertTrue(substr_count($values[0], '>Member for<') > 0, 'Node item ' . $nid . ' has rendered member information HTML-Tags.'); - $this->assertTrue(substr_count($values[0], '>' . $this->nodeData['body']['value'] . '<') > 0, 'Node item ' . $nid . ' has rendered content inside HTML-Tags.'); + $this->assertTrue(substr_count($values[0], '>' . $this->nodes[$nid]->get('body')->getValue()[0]['value'] . '<') > 0, 'Node item ' . $nid . ' has rendered content inside HTML-Tags.'); } } @@ -174,7 +173,7 @@ class RenderedItemTest extends ProcessorTestBase { 'datasource' => 'entity:node', 'item' => $node->getTypedData(), 'item_id' => $node->id(), - 'text' => $this->randomMachineName(), + 'text' => 'text for ' . $node->id(), ); } $items = $this->generateItems($items); diff --git a/tests/src/Kernel/CliTest.php b/tests/src/Kernel/CliTest.php index 1714c23..70fd5cc 100644 --- a/tests/src/Kernel/CliTest.php +++ b/tests/src/Kernel/CliTest.php @@ -51,8 +51,8 @@ class CliTest extends KernelTestBase { // Create a test server. $this->server = Server::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test server', + 'id' => 'test', 'status' => 1, 'backend' => 'search_api_test_backend', )); @@ -91,8 +91,8 @@ class CliTest extends KernelTestBase { // Create a test index. /** @var \Drupal\search_api\IndexInterface $index */ $index = Index::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test index', + 'id' => 'index', 'status' => 1, 'datasources' => array('entity:entity_test'), 'tracker' => 'default', diff --git a/tests/src/Kernel/CustomDataTypesTest.php b/tests/src/Kernel/CustomDataTypesTest.php index 6ae2d46..56b9647 100644 --- a/tests/src/Kernel/CustomDataTypesTest.php +++ b/tests/src/Kernel/CustomDataTypesTest.php @@ -96,8 +96,8 @@ class CustomDataTypesTest extends KernelTestBase { // Create a test server. $this->server = Server::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Server test ~', + 'id' => 'test', 'status' => 1, 'backend' => 'search_api_test_backend', )); diff --git a/tests/src/Kernel/IndexStorageTest.php b/tests/src/Kernel/IndexStorageTest.php index 06e5a3b..0e89a46 100644 --- a/tests/src/Kernel/IndexStorageTest.php +++ b/tests/src/Kernel/IndexStorageTest.php @@ -62,8 +62,8 @@ class IndexStorageTest extends KernelTestBase { */ public function indexCreate() { $indexData = array( - 'id' => $this->randomMachineName(), - 'name' => $this->randomString(), + 'id' => 'test', + 'name' => 'Index test name', 'tracker' => 'default', ); diff --git a/tests/src/Kernel/LanguageKernelTest.php b/tests/src/Kernel/LanguageKernelTest.php index da369db..671a957 100644 --- a/tests/src/Kernel/LanguageKernelTest.php +++ b/tests/src/Kernel/LanguageKernelTest.php @@ -96,8 +96,8 @@ class LanguageKernelTest extends KernelTestBase { // Create a test server. $this->server = Server::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test Server', + 'id' => 'test_server', 'status' => 1, 'backend' => 'search_api_test_backend', )); @@ -105,8 +105,8 @@ class LanguageKernelTest extends KernelTestBase { // Create a test index. $this->index = Index::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test Index', + 'id' => 'test_index', 'status' => 1, 'datasources' => array('entity:' . $this->testEntityTypeId), 'tracker' => 'default', diff --git a/tests/src/Kernel/ServerStorageTest.php b/tests/src/Kernel/ServerStorageTest.php index 3165b7f..f5a7fe9 100644 --- a/tests/src/Kernel/ServerStorageTest.php +++ b/tests/src/Kernel/ServerStorageTest.php @@ -63,8 +63,8 @@ class ServerStorageTest extends KernelTestBase { */ public function serverCreate() { $serverData = array( - 'id' => $this->randomMachineName(), - 'name' => $this->randomString(), + 'id' => 'test_server', + 'name' => 'Test server', 'backend' => 'search_api_test_backend', ); $server = $this->storage->create($serverData); diff --git a/tests/src/Kernel/ServerTaskTest.php b/tests/src/Kernel/ServerTaskTest.php index f621882..a31595d 100644 --- a/tests/src/Kernel/ServerTaskTest.php +++ b/tests/src/Kernel/ServerTaskTest.php @@ -79,8 +79,8 @@ class ServerTaskTest extends KernelTestBase { // Create a test server. $this->server = Server::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test Server', + 'id' => 'test_server', 'status' => 1, 'backend' => 'search_api_test_backend', )); @@ -88,8 +88,8 @@ class ServerTaskTest extends KernelTestBase { // Create a test index. $this->index = Index::create(array( - 'name' => $this->randomString(), - 'id' => $this->randomMachineName(), + 'name' => 'Test index', + 'id' => 'test_index', 'status' => 1, 'datasources' => array('entity:user'), 'tracker' => 'default', diff --git a/tests/src/Unit/Plugin/Processor/TransliterationTest.php b/tests/src/Unit/Plugin/Processor/TransliterationTest.php index 74b59aa..bcc77c4 100644 --- a/tests/src/Unit/Plugin/Processor/TransliterationTest.php +++ b/tests/src/Unit/Plugin/Processor/TransliterationTest.php @@ -33,7 +33,7 @@ class TransliterationTest extends UnitTestCase { * {@inheritdoc} */ public function setUp() { - parent::setUp('transliteration'); + parent::setUp(); $this->index = $this->getMock('Drupal\search_api\IndexInterface'); @@ -78,7 +78,7 @@ class TransliterationTest extends UnitTestCase { * Tests that strings are affected. */ public function testTransliterationWithString() { - $field_value = $this->getRandomGenerator()->string(); + $field_value = 'test_string'; /** @var \Drupal\search_api\Item\FieldInterface $field */ $items = $this->createSingleFieldItem($this->index, 'string', $field_value, $field); $this->processor->preprocessIndexItems($items);