Beispiel #1
0
  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->state = $this->container->get('state');

    $this->installEntitySchema('user');
    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));

    // Create a test server.
    $this->server = Server::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'backend' => 'search_api_test_backend',
    ));
    $this->server->save();

    // Create a test index.
    $this->index = Index::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'datasources' => array('entity:user'),
      'tracker' => 'default',
      'server' => $this->server->id(),
      'options' => array('index_directly' => FALSE),
    ));
    $this->index->save();

    $this->serverTaskManager = $this->container->get('search_api.server_task_manager');
  }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     // Enable translation for the entity_test module.
     \Drupal::state()->set('entity_test.translation', TRUE);
     $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
     $this->installEntitySchema('entity_test_mul');
     // Create the default languages.
     $this->installConfig(array('language'));
     $this->langcodes = array();
     for ($i = 0; $i < 3; ++$i) {
         /** @var \Drupal\language\Entity\ConfigurableLanguage $language */
         $language = ConfigurableLanguage::create(array('id' => 'l' . $i, 'label' => 'language - ' . $i, 'weight' => $i));
         $this->langcodes[$i] = $language->getId();
         $language->save();
     }
     // Do not use a batch for tracking the initial items after creating an
     // index when running the tests via the GUI. Otherwise, it seems Drupal's
     // Batch API gets confused and the test fails.
     \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
     // Create a test server.
     $this->server = Server::create(array('name' => 'Test Server', 'id' => 'test_server', 'status' => 1, 'backend' => 'search_api_test_backend'));
     $this->server->save();
     // Create a test index.
     $this->index = Index::create(array('name' => 'Test Index', 'id' => 'test_index', 'status' => 1, 'datasource_settings' => array('entity:' . $this->testEntityTypeId => array('plugin_id' => 'entity:' . $this->testEntityTypeId, 'settings' => array())), 'tracker_settings' => array('default' => array('plugin_id' => 'default', 'settings' => array())), 'server' => $this->server->id(), 'options' => array('index_directly' => FALSE)));
     $this->index->save();
 }
  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
    $this->installSchema('system', array('router'));
    $this->installSchema('user', array('users_data'));

    $this->setUpExampleStructure();

    $this->installConfig(array('search_api_test_db'));

    $this->insertExampleContent();

    // Create a test server.
    $this->server = Server::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'backend' => 'search_api_test_backend',
    ));
    $this->server->save();

    $this->index = Index::load('database_search_index');
    $this->index->setServer($this->server);
  }
  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));

    // Create a test server.
    $this->server = Server::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'backend' => 'search_api_test_backend',
    ));
    $this->server->save();

    // Create a test index.
    $this->index = Index::create(array(
      'name' => $this->randomString(),
      'id' => $this->randomMachineName(),
      'status' => 1,
      'datasources' => array('entity:' . $this->testEntityTypeId),
      'tracker' => 'default',
      'server' => $this->server->id(),
      'options' => array('index_directly' => FALSE),
    ));
    $this->index->save();

    Utility::getIndexTaskManager()->addItemsAll($this->index);
  }
Beispiel #5
0
  /**
   * Performs setup tasks before each individual test method is run.
   *
   * Installs commonly used schemas and sets up a search server and an index,
   * with the specified processor enabled.
   *
   * @param string|null $processor
   *   (optional) The plugin ID of the processor that should be set up for
   *   testing.
   */
  public function setUp($processor = NULL) {
    parent::setUp();

    $this->installSchema('node', array('node_access'));
    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));

    $server_name = $this->randomMachineName();
    $this->server = Server::create(array(
      'id' => strtolower($server_name),
      'name' => $server_name,
      'status' => TRUE,
      'backend' => 'search_api_db',
      'backend_config' => array(
        'min_chars' => 3,
        'database' => 'default:default',
      ),
    ));
    $this->server->save();

    $index_name = $this->randomMachineName();
    $this->index = Index::create(array(
      'id' => strtolower($index_name),
      'name' => $index_name,
      'status' => TRUE,
      'datasources' => array('entity:comment', 'entity:node'),
      'server' => $server_name,
      'tracker' => 'default',
    ));
    $this->index->setServer($this->server);
    $this->index->setOption('fields', array(
      'entity:comment/subject' => array(
        'type' => 'text',
      ),
      'entity:node/title' => array(
        'type' => 'text',
      ),
    ));
    if ($processor) {
      $this->index->setOption('processors', array(
        $processor => array(
          'processor_id' => $processor,
          'weights' => array(),
          'settings' => array(),
        ),
      ));

      /** @var \Drupal\search_api\Processor\ProcessorPluginManager $plugin_manager */
      $plugin_manager = \Drupal::service('plugin.manager.search_api.processor');
      $this->processor = $plugin_manager->createInstance($processor, array('index' => $this->index));
    }
    $this->index->save();
    \Drupal::configFactory()
      ->getEditable('search_api.settings')
      ->set('tracking_page_size', 100)
      ->save();
    Utility::getIndexTaskManager()->addItemsAll($this->index);
  }
 /**
  * Tests a backend with a dependency that gets removed.
  *
  * If the dependency does not get removed, proper cascading to the index is
  * also verified.
  *
  * @param bool $remove_dependency
  *   Whether to remove the dependency from the backend when the object
  *   depended on is deleted.
  *
  * @dataProvider dependencyTestDataProvider
  */
 public function testBackendDependency($remove_dependency)
 {
     $dependency_key = $this->dependency->getConfigDependencyKey();
     $dependency_name = $this->dependency->getConfigDependencyName();
     // Create a server using the test backend, and set the dependency in the
     // configuration.
     /** @var \Drupal\search_api\ServerInterface $server */
     $server = Server::create(array('id' => 'test_server', 'name' => 'Test server', 'backend' => 'search_api_test_backend', 'backend_config' => array('dependencies' => array($dependency_key => array($dependency_name)))));
     $server->save();
     $server_dependency_key = $server->getConfigDependencyKey();
     $server_dependency_name = $server->getConfigDependencyName();
     // Set the server on the index and save that, too. However, we don't want
     // the index enabled, since that would lead to all kinds of overhead which
     // is completely irrelevant for this test.
     $this->index->setServer($server);
     $this->index->disable();
     $this->index->save();
     // Check that the dependencies were calculated correctly.
     $server_dependencies = $server->getDependencies();
     $this->assertContains($dependency_name, $server_dependencies[$dependency_key], 'Backend dependency correctly inserted');
     $index_dependencies = $this->index->getDependencies();
     $this->assertContains($server_dependency_name, $index_dependencies[$server_dependency_key], 'Server dependency correctly inserted');
     // Set our magic state key to let the test plugin know whether the
     // dependency should be removed or not. See
     // \Drupal\search_api_test_backend\Plugin\search_api\backend\TestBackend::onDependencyRemoval().
     $key = 'search_api_test_backend.dependencies.remove';
     \Drupal::state()->set($key, $remove_dependency);
     // Delete the backend's dependency.
     $this->dependency->delete();
     // Reload the index and check it's still there.
     $this->reloadIndex();
     $this->assertInstanceOf('Drupal\\search_api\\IndexInterface', $this->index, 'Index not removed');
     // Reload the server.
     $storage = \Drupal::entityTypeManager()->getStorage('search_api_server');
     $storage->resetCache();
     $server = $storage->load($server->id());
     if ($remove_dependency) {
         $this->assertInstanceOf('Drupal\\search_api\\ServerInterface', $server, 'Server was not removed');
         $this->assertArrayNotHasKey('dependencies', $server->get('backend_config'), 'Backend config was adapted');
         // @todo Logically, this should not be changed: if the server does not get
         //   removed, there is no need to adapt the index's configuration.
         //   However, the way this config dependency cascading is actually
         //   implemented in
         //   \Drupal\Core\Config\ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval()
         //   does not seem to follow that logic, but just computes the complete
         //   tree of dependencies once and operates generally on the assumption
         //   that all of them will be deleted. See #2642374.
         //      $this->assertEquals($server->id(), $this->index->getServerId(), "Index's server was not changed");
     } else {
         $this->assertNull($server, 'Server was removed');
         $this->assertEquals(NULL, $this->index->getServerId(), 'Index server was changed');
     }
 }
Beispiel #7
0
 /**
  * Creates or deletes a server.
  *
  * @param string $name
  *   (optional) The name of the server.
  * @param string $id
  *   (optional) The ID of the server.
  * @param string $backend_id
  *   (optional) The ID of the backend to set for the server.
  * @param array $backend_config
  *   (optional) The backend configuration to set for the server.
  * @param bool $reset
  *   (optional) If TRUE, delete the server instead of creating it. (Only the
  *   server's ID is required in that case).
  *
  * @return \Drupal\search_api\ServerInterface
  *   A search server.
  */
 public function getTestServer($name = 'WebTest server', $id = 'webtest_server', $backend_id = 'search_api_test_backend', $backend_config = array(), $reset = FALSE)
 {
     if ($reset) {
         $server = Server::load($id);
         if ($server) {
             $server->delete();
         }
     } else {
         $server = Server::create(array('id' => $id, 'name' => $name, 'description' => $name, 'backend' => $backend_id, 'backend_config' => $backend_config));
         $server->save();
     }
     return $server;
 }
Beispiel #8
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
     $this->installEntitySchema('entity_test');
     // Create a test server.
     $this->server = Server::create(array('name' => 'Test server', 'id' => 'test', 'status' => 1, 'backend' => 'search_api_test_backend'));
     $this->server->save();
     // Manually set the tracking page size since the module's default
     // configuration is not installed automatically in kernel tests.
     \Drupal::configFactory()->getEditable('search_api.settings')->set('tracking_page_size', 100)->save();
     // Disable the use of batches for item tracking to simulate a CLI
     // environment.
     \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
 }
 /**
  * Performs setup tasks before each individual test method is run.
  *
  * Installs commonly used schemas and sets up a search server and an index,
  * with the specified processor enabled.
  *
  * @param string|null $processor
  *   (optional) The plugin ID of the processor that should be set up for
  *   testing.
  */
 public function setUp($processor = NULL)
 {
     parent::setUp();
     $this->installSchema('node', array('node_access'));
     $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
     $this->installEntitySchema('user');
     $this->installEntitySchema('node');
     $this->installEntitySchema('comment');
     $this->installConfig(array('field'));
     Action::create(['id' => 'foo', 'label' => 'Foobaz', 'plugin' => 'comment_publish_action'])->save();
     \Drupal::configFactory()->getEditable('search_api.settings')->set('tracking_page_size', 100)->save();
     // Do not use a batch for tracking the initial items after creating an
     // index when running the tests via the GUI. Otherwise, it seems Drupal's
     // Batch API gets confused and the test fails.
     \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
     $this->server = Server::create(array('id' => 'server', 'name' => 'Server & Name', 'status' => TRUE, 'backend' => 'search_api_db', 'backend_config' => array('min_chars' => 3, 'database' => 'default:default')));
     $this->server->save();
     $this->index = Index::create(array('id' => 'index', 'name' => 'Index name', 'status' => TRUE, 'datasource_settings' => array('entity:comment' => array('plugin_id' => 'entity:comment', 'settings' => array()), 'entity:node' => array('plugin_id' => 'entity:node', 'settings' => array())), 'server' => 'server', 'tracker_settings' => array('default' => array('plugin_id' => 'default', 'settings' => array()))));
     $this->index->setServer($this->server);
     $field_subject = new Field($this->index, 'subject');
     $field_subject->setType('text');
     $field_subject->setPropertyPath('subject');
     $field_subject->setDatasourceId('entity:comment');
     $field_subject->setLabel('Subject');
     $field_title = new Field($this->index, 'title');
     $field_title->setType('text');
     $field_title->setPropertyPath('title');
     $field_title->setDatasourceId('entity:node');
     $field_title->setLabel('Title');
     $this->index->addField($field_subject);
     $this->index->addField($field_title);
     if ($processor) {
         /** @var \Drupal\search_api\Processor\ProcessorPluginManager $plugin_manager */
         $plugin_manager = \Drupal::service('plugin.manager.search_api.processor');
         $this->processor = $plugin_manager->createInstance($processor, array('index' => $this->index));
         $this->index->addProcessor($this->processor);
     }
     $this->index->save();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
     $this->installSchema('system', array('router'));
     $this->installSchema('user', array('users_data'));
     $this->installEntitySchema('entity_test');
     // Do not use a batch for tracking the initial items after creating an
     // index when running the tests via the GUI. Otherwise, it seems Drupal's
     // Batch API gets confused and the test fails.
     \Drupal::state()->set('search_api_use_tracking_batch', FALSE);
     $this->installConfig(array('search_api_test_db'));
     // Create test entities.
     $this->entities[1] = EntityTest::create(array('name' => 'foo bar baz föö smile' . json_decode('"\\u1F601"'), 'body' => 'test test case Case casE', 'type' => 'item', 'keywords' => array('Orange', 'orange', 'örange', 'Orange'), 'category' => 'item_category'));
     $this->entities[2] = EntityTest::create(array('name' => 'foo bar baz föö smile', 'body' => 'test test case Case casE', 'type' => 'item', 'keywords' => array('strawberry', 'llama'), 'category' => 'item_category'));
     $this->entities[1]->save();
     $this->entities[2]->save();
     // Create a test server.
     $this->server = Server::create(array('name' => 'Server test ~', 'id' => 'test', 'status' => 1, 'backend' => 'search_api_test_backend'));
     $this->server->save();
     $this->index = Index::load('database_search_index');
     $this->index->setServer($this->server);
 }
Beispiel #11
0
 /**
  * Retrieves the search server used by this test.
  *
  * @return \Drupal\search_api\ServerInterface
  *   The search server.
  */
 protected function getServer()
 {
     return Server::load($this->serverId);
 }
 /**
  * Implements the magic __wakeup() method.
  *
  * Reloads the server entity.
  */
 public function __wakeup()
 {
     parent::__wakeup();
     if ($this->serverId) {
         $this->server = Server::load($this->serverId);
         $this->serverId = NULL;
     }
 }
 /**
  * Test that the "Alter processors test backend" actually alters processors.
  *
  * @see https://www.drupal.org/node/2228739
  */
 public function testLimitProcessors()
 {
     $this->loadProcessorsTab();
     $this->assertResponse(200);
     $this->assertText($this->t('Highlight'));
     $this->assertText($this->t('Ignore character'));
     $this->assertText($this->t('Tokenizer'));
     $this->assertText($this->t('Stopwords'));
     // Create a new server with the "search_api_test_backend" backend.
     $server = Server::create(array('id' => 'webtest_server', 'name' => 'WebTest server', 'description' => 'WebTest server', 'backend' => 'search_api_test_backend', 'backend_config' => array()));
     $server->save();
     $key = 'search_api_test_backend.discouraged_processors';
     $processors = array('highlight', 'ignore_character', 'tokenizer', 'stopwords');
     \Drupal::state()->set($key, $processors);
     // Use the newly created server.
     $settings_path = 'admin/config/search/search-api/index/' . $this->indexId . '/edit';
     $this->drupalGet($settings_path);
     $this->drupalPostForm(NULL, array('server' => 'webtest_server'), $this->t('Save'));
     // Load the processors again and check that they are not shown anymore.
     $this->loadProcessorsTab();
     $this->assertResponse(200);
     $this->assertNoText($this->t('Highlight'));
     $this->assertNoText($this->t('Ignore character'));
     $this->assertNoText($this->t('Tokenizer'));
     $this->assertNoText($this->t('Stopwords'));
 }
 /**
  * {@inheritdoc}
  */
 protected function checkModuleUninstall()
 {
     // See whether clearing the server works.
     // Regression test for #2156151.
     $server = Server::load($this->serverId);
     $index = Index::load($this->indexId);
     $server->deleteAllItems($index);
     // Deleting items take at least 1 second for Solr to parse it so that drupal
     // doesn't get timeouts while waiting for Solr. Lets give it 2 seconds to
     // make sure we are in bounds.
     sleep(2);
     $query = $this->buildSearch();
     $results = $query->execute();
     $this->assertEqual($results->getResultCount(), 0, 'Clearing the server worked correctly.');
 }
Beispiel #15
0
  /**
   * Tests whether the default search was correctly installed.
   */
  protected function testDefaultSetupWorking() {
    $server = Server::load('default_server');
    $this->assertTrue($server, 'Server can be loaded');

    $index = Index::load('default_index');
    $this->assertTrue($index, 'Index can be loaded');

    $this->drupalGet('search/content');
    $this->assertResponse(200, 'Anonymous user can access the search page.');
    $this->drupalLogin($this->authenticatedUser);
    $this->drupalGet('search/content');
    $this->assertResponse(200, 'Authenticated user can access the search page.');
  }
Beispiel #16
0
 /**
  * Tests deleting a search server via the UI.
  */
 protected function deleteServer()
 {
     $server = Server::load($this->serverId);
     // Load confirmation form.
     $this->drupalGet('admin/config/search/search-api/server/' . $this->serverId . '/delete');
     $this->assertResponse(200, 'Server delete page exists');
     $this->assertRaw(t('Are you sure you want to delete the search server %name?', array('%name' => $server->label())), 'Deleting a server sks for confirmation.');
     $this->assertText(t('Deleting a server will disable all its indexes and their searches.'), 'Correct warning is displayed when deleting a server.');
     // Confirm deletion.
     $this->drupalPostForm(NULL, NULL, t('Delete'));
     $this->assertRaw(t('The search server %name has been deleted.', array('%name' => $server->label())), 'The server was deleted.');
     $this->assertFalse(Server::load($this->serverId), 'Server could not be found anymore.');
     $this->assertUrl('admin/config/search/search-api', array(), 'Correct redirect to search api overview page.');
     // Confirm that the index hasn't been deleted.
     $this->indexStorage->resetCache(array($this->indexId));
     /** @var $index \Drupal\search_api\IndexInterface */
     $index = $this->indexStorage->load($this->indexId);
     if ($this->assertTrue($index, 'The index associated with the server was not deleted.')) {
         $this->assertFalse($index->status(), 'The index associated with the server was disabled.');
         $this->assertNull($index->getServerId(), 'The index was removed from the server.');
     }
 }
 /**
  * Tests whether the default search was correctly installed.
  */
 protected function testInstallAndDefaultSetupWorking()
 {
     $this->drupalLogin($this->adminUser);
     // Install the search_api_db_defaults module.
     $edit_enable = array('modules[Search][search_api_db_defaults][enable]' => TRUE);
     $this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
     $this->assertText(t('Some required modules must be enabled'), 'Dependencies required.');
     $this->drupalPostForm(NULL, NULL, t('Continue'));
     $args = array('@count' => 3, '%names' => 'Database Search Defaults, Database search, Search API');
     $success_text = strip_tags(t('@count modules have been enabled: %names.', $args));
     $this->assertText($success_text, 'Modules have been installed.');
     $this->rebuildContainer();
     $server = Server::load('default_server');
     $this->assertTrue($server, 'Server can be loaded');
     $index = Index::load('default_index');
     $this->assertTrue($index, 'Index can be loaded');
     $this->drupalLogin($this->authenticatedUser);
     $this->drupalGet('search/content');
     $this->assertResponse(200, 'Authenticated user can access the search view.');
     $this->drupalLogin($this->adminUser);
     // Uninstall the module.
     $edit_disable = array('uninstall[search_api_db_defaults]' => TRUE);
     $this->drupalPostForm('admin/modules/uninstall', $edit_disable, t('Uninstall'));
     $this->drupalPostForm(NULL, array(), t('Uninstall'));
     $this->rebuildContainer();
     $this->assertFalse($this->container->get('module_handler')->moduleExists('search_api_db_defaults'), 'Search API DB Defaults module uninstalled.');
     // Check if the server is found in the Search API admin UI.
     $this->drupalGet('admin/config/search/search-api/server/default_server');
     $this->assertResponse(200, 'Server was not removed.');
     // Check if the index is found in the Search API admin UI.
     $this->drupalGet('admin/config/search/search-api/index/default_index');
     $this->assertResponse(200, 'Index was not removed.');
     $this->drupalLogin($this->authenticatedUser);
     $this->drupalGet('search/content');
     $this->assertResponse(200, 'Authenticated user can access the search view.');
     $this->drupalLogin($this->adminUser);
     // Enable the module again. This should fail because the either the index
     // or the server or the view was found.
     $this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
     $this->assertText(t('It looks like the default setup provided by this module already exists on your site. Cannot re-install module.'));
     // Delete all the entities that we would fail on if they exist.
     $entities_to_remove = array('search_api_index' => 'default_index', 'search_api_server' => 'default_server', 'view' => 'search_content');
     /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
     $entity_type_manager = \Drupal::service('entity_type.manager');
     foreach ($entities_to_remove as $entity_type => $entity_id) {
         /** @var \Drupal\Core\Entity\EntityStorageInterface $entity_storage */
         $entity_storage = $entity_type_manager->getStorage($entity_type);
         $entity_storage->resetCache();
         $entities = $entity_storage->loadByProperties(array('id' => $entity_id));
         if (!empty($entities[$entity_id])) {
             $entities[$entity_id]->delete();
         }
     }
     // Delete the article content type.
     $this->drupalGet('admin/structure/types/manage/article');
     $this->clickLink(t('Delete'));
     $this->assertResponse(200);
     $this->drupalPostForm(NULL, array(), t('Delete'));
     // Try to install search_api_db_defaults module and test if it failed
     // because there was no content type "article".
     $this->drupalPostForm('admin/modules', $edit_enable, t('Install'));
     $success_text = t('Content type @content_type not found. Database Search Defaults module could not be installed.', array('@content_type' => 'article'));
     $this->assertText($success_text);
 }
Beispiel #18
0
 /**
  * {@inheritdoc}
  */
 public function getServerInstance()
 {
     if (!$this->serverInstance && $this->server) {
         $this->serverInstance = Server::load($this->server);
         if (!$this->serverInstance) {
             $args['@server'] = $this->server;
             $args['%index'] = $this->label();
             throw new SearchApiException(new FormattableMarkup('The server with ID "@server" could not be retrieved for index %index.', $args));
         }
     }
     return $this->serverInstance;
 }
 /**
  * Tests whether removing the configuration again works as it should.
  */
 protected function checkModuleUninstall()
 {
     // See whether clearing the server works.
     // Regression test for #2156151.
     $server = Server::load($this->serverId);
     $index = Index::load($this->indexId);
     $server->deleteAllIndexItems($index);
     $query = $this->buildSearch();
     $results = $query->execute();
     $this->assertEqual($results->getResultCount(), 0, 'Clearing the server worked correctly.');
     $table = 'search_api_db_' . $this->indexId;
     $this->assertTrue(db_table_exists($table), 'The index tables were left in place.');
     // Remove first the index and then the server.
     $index->setServer();
     $index->save();
     $server = Server::load($this->serverId);
     $this->assertEqual($server->getBackendConfig()['field_tables'], array(), 'The index was successfully removed from the server.');
     $this->assertFalse(db_table_exists($table), 'The index tables were deleted.');
     $server->delete();
     // Uninstall the module.
     \Drupal::service('module_installer')->uninstall(array('search_api_db'), FALSE);
     #\Drupal::moduleHandler()->uninstall(array('search_api_db'), FALSE);
     $this->assertFalse(\Drupal::moduleHandler()->moduleExists('search_api_db'), 'The Database Search module was successfully disabled.');
     $prefix = \Drupal::database()->prefixTables('{search_api_db_}') . '%';
     $this->assertEqual(\Drupal::database()->schema()->findTables($prefix), array(), 'The Database Search module was successfully uninstalled.');
 }
 /**
  * Tests Acquia Search environment creation.
  *
  * Tests executed:
  * - Acquia Search environment is saved and loaded.
  * - Acquia Search environment is set as the default environment when created.
  * - The service class is set to AcquiaSearchService.
  * - The environment's URL is built as expected.
  */
 public function testEnvironment()
 {
     // Connect site on key and id.
     $this->drupalGet('admin/config/search/search-api');
     $environment = Server::load('acquia_search_server');
     // Check if the environment is a valid variable.
     $this->assertTrue($environment, t('Acquia Search environment saved.'), 'Acquia Search');
 }