I am trying to run a BrowserTestBase
based test in my own module, following the documentation on drupal.org.
No matter if I run the test from PHPStorm or command line, I get the same error:
vagrant@local:/var/www/mysite/docroot$ ../vendor/bin/phpunit -c core/phpunit.xml --group mymodule
PHP Fatal error: Trait 'Drupal\Tests\facets\Functional\BlockTestTrait' not found in /var/www/mysite/docroot/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 20
PHP Stack trace:
PHP 1. {main}() /var/www/mysite/vendor/phpunit/phpunit/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /var/www/mysite/vendor/phpunit/phpunit/phpunit:52
PHP 3. PHPUnit_TextUI_Command->run() /var/www/mysite/vendor/phpunit/phpunit/src/TextUI/Command.php:100
PHP 4. PHPUnit_TextUI_Command->handleArguments() /var/www/mysite/vendor/phpunit/phpunit/src/TextUI/Command.php:111
PHP 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /var/www/mysite/vendor/phpunit/phpunit/src/TextUI/Command.php:649
PHP 6. PHPUnit_Util_Configuration->getTestSuite() /var/www/mysite/vendor/phpunit/phpunit/src/Util/Configuration.php:878
PHP 7. PHPUnit_Framework_TestSuite->addTestFile() /var/www/mysite/vendor/phpunit/phpunit/src/Util/Configuration.php:1000
PHP 8. ReflectionMethod->invoke() /var/www/mysite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:353
PHP 9. Drupal\Tests\TestSuites\FunctionalTestSuite::suite() /var/www/mysite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:353
PHP 10. Drupal\Tests\TestSuites\TestSuiteBase->addTestsBySuiteNamespace() /var/www/mysite/docroot/core/tests/TestSuites/FunctionalTestSuite.php:22
PHP 11. PHPUnit_Framework_TestSuite->addTestFiles() /var/www/mysite/docroot/core/tests/TestSuites/TestSuiteBase.php:55
PHP 12. PHPUnit_Framework_TestSuite->addTestFile() /var/www/mysite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:384
PHP 13. PHPUnit_Util_Fileloader::checkAndLoad() /var/www/mysite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:310
PHP 14. PHPUnit_Util_Fileloader::load() /var/www/mysite/vendor/phpunit/phpunit/src/Util/Fileloader.php:38
PHP 15. include_once() /var/www/mysite/vendor/phpunit/phpunit/src/Util/Fileloader.php:56
Fatal error: Trait 'Drupal\Tests\facets\Functional\BlockTestTrait' not found in /var/www/mysite/docroot/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 20
I am not requiring Search API Solr in my test, nor do I have a clue why it is running it. Even if I specify --testsuite unit
, I get the same error.
Here is the test I am trying to run, with a basic test step:
namespace Drupal\Tests\mymodule\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Class AuthenticationTest.
*
* @group mymodule
*/
class AuthenticationTest extends BrowserTestBase {
/**
* Required modules.
*
* @var array
*/
protected static $modules = ['user', 'node'];
public function setUp() {
parent::setUp();
// set config for netforum
}
/**
* The superuser should not authenticate to Netforum.
*/
public function testAdminUserUsesDrupalAuthentication() {
$account = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($account);
}
}
I am not sure why it is even looking at the Search API Solr module, but the test in question does try to use several files that do not exist:
use Drupal\Tests\facets\Functional\BlockTestTrait;
use Drupal\Tests\facets\Functional\ExampleContentTrait;
use Drupal\Tests\facets\Functional\TestHelperTrait;
I assume these are a part of the Facets module, which I do not have.
edit: This might be my issue.