0

I am working on a multi site where there is no database defined in the default directory, so whenever I run a Functional test extending BrowserTestBase I get the following error:

copy(/var/www/drupal-int/docroot/sites/default/default.settings.php): failed to open stream: No such file or directory

I'm not really sure why the files were removed in the first place and I don't want to add them back in there in case there was a good reason for removing them. Is there a way to define the site to use for the test?

My simple test:

<?php

namespace Drupal\Tests\my_module\Functional;

use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;

/**
 * Simple test to ensure that main page loads with module enabled.
 *
 * @group dnsw_scheduler_workbench_integration
 */
class LoadTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = ['my_module'];

  /**
   * A user with permission to administer site configuration.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $user;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->user = $this->drupalCreateUser(['administer site configuration']);
    $this->drupalLogin($this->user);
  }

  /**
   * Tests that the home page loads with a 200 response.
   */
  public function testLoad() {
    $this->drupalGet(Url::fromRoute('<front>'));
    $this->assertResponse(200);
  }

}

1 Answer 1

1

None of your existing sites are used during a fonctionnal test, drupal creates a fresh install defined by your static attribute $modules and the setUp() method.

So, you should get the default.settings.php file back (and create a /sites/simpletest folder)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.