ComposerIntegrationTrait.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Drupal\Tests\Composer;
  3. use Symfony\Component\Finder\Finder;
  4. /**
  5. * Some utility functions for testing the Composer integration.
  6. */
  7. trait ComposerIntegrationTrait {
  8. /**
  9. * Get a Finder object to traverse all of the composer.json files in core.
  10. *
  11. * @param string $drupal_root
  12. * Absolute path to the root of the Drupal installation.
  13. *
  14. * @return \Symfony\Component\Finder\Finder
  15. * A Finder object able to iterate all the composer.json files in core.
  16. */
  17. public function getComposerJsonFinder($drupal_root) {
  18. $composer_json_finder = new Finder();
  19. $composer_json_finder->name('composer.json')
  20. ->in([
  21. // Only find composer.json files within composer/ and core/ directories
  22. // so we don't inadvertently test contrib in local dev environments.
  23. $drupal_root . '/composer',
  24. $drupal_root . '/core',
  25. ])
  26. ->ignoreUnreadableDirs()
  27. ->notPath('#^vendor#')
  28. ->notPath('#/fixture#');
  29. return $composer_json_finder;
  30. }
  31. }