Fatal error: Trait "Drupal\Tests\facets\Functional\BlockTestTrait" not found in /var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 19

Created on 3 October 2023, 9 months ago
Updated 9 February 2024, 5 months ago

When running phpunit tests without the facets nodule installed, I get the following error:

../../vendor/bin/php
unit --list-groups
PHP Fatal error:  Trait "Drupal\Tests\facets\Functional\BlockTestTrait" not found in /var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 19

Looking at FacetsTest I can see that these dependencies are not available and break the running of the tests.

use Drupal\Tests\facets\Functional\BlockTestTrait;
use Drupal\Tests\facets\Functional\ExampleContentTrait;
use Drupal\Tests\facets\Functional\TestHelperTrait;

I guess I can manually download and install facets module but if this is the case why isn't facets module a dependency of search_api_solr ?

My feeling is that the tests should be self contained, unless calling a core module.

Thanks.

💬 Support request
Status

Fixed

Version

4.3

Component

Code

Created by

🇬🇧United Kingdom 2dareis2do

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @2dareis2do
  • 🇬🇧United Kingdom 2dareis2do
  • Status changed to Closed: works as designed 9 months ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    Facets is a required as a dev dependency in composer.json.
    For running tests, dev dependencies have to be installed.

  • 🇬🇧United Kingdom 2dareis2do

    How do you do that. When I run composer update or install form the project root, dev dependencies do not appear to be installed?

  • 🇬🇧United Kingdom 2dareis2do

    Ok, I am adding composer require --dev 'drupal/facets:^3.0@beta' for now to my root composer file.

    This is the only module that I have installed that has test dependencies on another contributed module that is not defined as dependency and installed.

  • Status changed to Needs work 5 months ago
  • 🇬🇧United Kingdom 2dareis2do

    After installing all dependencies with compose install, and the running the following command:

    ../vendor/bin/phpunit -c core --list-groups from web folder

    i get:

    PHP Fatal error: Trait "Drupal\Tests\facets\Functional\BlockTestTrait" not found in /var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 19
    PHP Stack trace:
    PHP 1. {main}() /var/www/html/vendor/bin/phpunit:0
    PHP 2. include() /var/www/html/vendor/bin/phpunit:122
    PHP 3. PHPUnit\TextUI\Command::main($exit = *uninitialized*) /var/www/html/vendor/phpunit/phpunit/phpunit:107
    PHP 4. PHPUnit\TextUI\Command->run($argv = [0 => '../vendor/bin/phpunit', 1 => '-c', 2 => 'core', 3 => '--list-groups'], $exit = TRUE) /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:97
    PHP 5. PHPUnit\TextUI\Command->handleArguments($argv = [0 => '../vendor/bin/phpunit', 1 => '-c', 2 => 'core', 3 => '--list-groups']) /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:112
    PHP 6. PHPUnit\TextUI\TestSuiteMapper->map($configuration = class PHPUnit\TextUI\XmlConfiguration\TestSuiteCollection { private $testSuites = [0 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 1 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 2 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 3 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 4 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }] }, $filter = '') /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:391
    PHP 7. PHPUnit\Framework\TestSuite->addTestFile($filename = '/var/www/html/web/core/./tests/TestSuites/FunctionalTestSuite.php') /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestSuiteMapper.php:84
    PHP 8. ReflectionMethod->invoke($object = NULL, ...$args = variadic()) /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:485
    PHP 9. Drupal\Tests\TestSuites\FunctionalTestSuite::suite('Drupal\\Tests\\TestSuites\\FunctionalTestSuite') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:485
    PHP 10. Drupal\Tests\TestSuites\TestSuiteBase->addTestsBySuiteNamespace($root = '/var/www/html/web', $suite_namespace = 'Functional') /var/www/html/web/core/tests/TestSuites/FunctionalTestSuite.php:22
    PHP 11. PHPUnit\Framework\TestSuite->addTestFiles($fileNames = ['Drupal\Tests\search_api_solr\Functional\FacetsTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php', 'Drupal\Tests\search_api_solr\Functional\IntegrationTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/IntegrationTest.php', 'Drupal\Tests\search_api_solr\Functional\ViewsTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/ViewsTest.php']) /var/www/html/web/core/tests/TestSuites/TestSuiteBase.php:63
    PHP 12. PHPUnit\Framework\TestSuite->addTestFile($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:536
    PHP 13. PHPUnit\Util\FileLoader::checkAndLoad($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:397
    PHP 14. PHPUnit\Util\FileLoader::load($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php:49
    PHP 15. include_once() /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php:66

    Fatal error: Trait "Drupal\Tests\facets\Functional\BlockTestTrait" not found in /var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php on line 19

    Call Stack:
    0.0769 385152 1. {main}() /var/www/html/vendor/bin/phpunit:0
    0.0772 386168 2. include('/var/www/html/vendor/phpunit/phpunit/phpunit') /var/www/html/vendor/bin/phpunit:122
    0.1025 700336 3. PHPUnit\TextUI\Command::main($exit = ???) /var/www/html/vendor/phpunit/phpunit/phpunit:107
    0.1025 700448 4. PHPUnit\TextUI\Command->run($argv = [0 => '../vendor/bin/phpunit', 1 => '-c', 2 => 'core', 3 => '--list-groups'], $exit = TRUE) /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:97
    0.1026 700448 5. PHPUnit\TextUI\Command->handleArguments($argv = [0 => '../vendor/bin/phpunit', 1 => '-c', 2 => 'core', 3 => '--list-groups']) /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:112
    0.6839 1739712 6. PHPUnit\TextUI\TestSuiteMapper->map($configuration = class PHPUnit\TextUI\XmlConfiguration\TestSuiteCollection { private $testSuites = [0 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 1 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 2 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 3 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }, 4 => class PHPUnit\TextUI\XmlConfiguration\TestSuite { ... }] }, $filter = '') /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:391
    37.1298 118354264 7. PHPUnit\Framework\TestSuite->addTestFile($filename = '/var/www/html/web/core/./tests/TestSuites/FunctionalTestSuite.php') /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestSuiteMapper.php:84
    37.1305 118355560 8. ReflectionMethod->invoke($object = NULL, $args = 'Drupal\\Tests\\TestSuites\\FunctionalTestSuite') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:485
    37.1305 118355624 9. Drupal\Tests\TestSuites\FunctionalTestSuite::suite('Drupal\\Tests\\TestSuites\\FunctionalTestSuite') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:485
    37.1307 118356008 10. Drupal\Tests\TestSuites\TestSuiteBase->addTestsBySuiteNamespace($root = '/var/www/html/web', $suite_namespace = 'Functional') /var/www/html/web/core/tests/TestSuites/FunctionalTestSuite.php:22
    47.0692 147459208 11. PHPUnit\Framework\TestSuite->addTestFiles($fileNames = ['Drupal\Tests\search_api_solr\Functional\FacetsTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php', 'Drupal\Tests\search_api_solr\Functional\IntegrationTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/IntegrationTest.php', 'Drupal\Tests\search_api_solr\Functional\ViewsTest' => '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/ViewsTest.php']) /var/www/html/web/core/tests/TestSuites/TestSuiteBase.php:63
    47.0692 147459208 12. PHPUnit\Framework\TestSuite->addTestFile($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:536
    47.0692 147459208 13. PHPUnit\Util\FileLoader::checkAndLoad($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:397
    47.0693 147459480 14. PHPUnit\Util\FileLoader::load($filename = '/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php:49
    47.0696 147460232 15. include_once('/var/www/html/web/modules/contrib/search_api_solr/tests/src/Functional/FacetsTest.php') /var/www/html/vendor/phpunit/phpunit/src/Util/FileLoader.php:66

  • Status changed to Active 5 months ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    facets 3 is required. Take a look at our github actions.

  • 🇬🇧United Kingdom 2dareis2do

    To run the tests locally I have had to add facets as a dev-dependency.

    This seems ridiculous to me as I have no requirement on facets.

    If facets is a dependency of search_api_solr, even it is just for running the tests, why not make it a full dependency?

  • Status changed to Fixed 5 months ago
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    I assume that a lot of users use Search API Solr with Facets. But it is just a "suggested dependency".
    Both modules don't require the other one. And that should not be changed.
    Somewhere we need to place the integration tests of the eco system. And that has to be the search backend module.
    And we do the same for Search API Spellcheck, Search API Autocomplete, Search API Location ...
    All of them are optional.

  • 🇬🇧United Kingdom 2dareis2do

    It is certainly not true that everyone use who uses search api solr uses facets.

    This is making running the tests locally more difficult for developers.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024