Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drupal\Tests\module_name\TestSite namespace not found #124

Closed
2 tasks done
mradcliffe opened this issue Jan 20, 2020 · 5 comments
Closed
2 tasks done

Drupal\Tests\module_name\TestSite namespace not found #124

mradcliffe opened this issue Jan 20, 2020 · 5 comments

Comments

@mradcliffe
Copy link

How is drupal-check installed?

  • drupal-check is installed globally via Composer
  • drupal-check is installed however it is run via dev.acquia.com

Environment:

  • OS: Linux
  • PHP Version: 7.2
  • Drupal core: 8.9.x

Describe the bug

Class not found underneath tests/src/TestSite directory as namespace Drupal\Tests\cck_select_other\TestSite. Namespace resolution suggests that this should resolve.

Drupalci runs and passes the Nightwatch test that uses this class.

Console output

Note I couldn't run with -vvv because I have a bunch of modules in various states sitting in /modules directory as part of my preferred work flow for hacking on contrib. modules.

~/.composer/vendor/bin/drupal-check --drupal-root ../../ -d ./
PHPStan crashed in the previous run probably because of excessive memory consumption.
It consumed around 39 MB of memory.


To avoid this issue, allow to use more memory with the --memory-limit option.
 19/19 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------------------------------------------------- 
  Line   tests/src/TestSite/SelectOtherInstallTestScript.php                                                                                  
 ------ ------------------------------------------------------------------------------------------------------------------------------------- 
         Class Drupal\Tests\cck_select_other\TestSite\SelectOtherInstallTestScript was not found while trying to analyse it - autoloading is  
         probably not configured properly.                                                                                                    
 ------ ------------------------------------------------------------------------------------------------------------------------------------- 
@mradcliffe
Copy link
Author

This seems like a duplicate of #121 if \Drupal\Tests\MODULE\Functional isn't being found either.

@mradcliffe
Copy link
Author

Maybe not a duplicate. #121 should already be working in phpstan-drupal's autoloader... But TestSite wouldn't work at all according to https://github.com/mglaman/phpstan-drupal/blob/master/src/Drupal/DrupalAutoloader.php#L245.

I'm not sure if the logic around manually specifying the directories is necessary at all. Shouldn't specifying the following be enough to support all directories underneath tests/src for modules?

$module_test_dir = $module_dir . '/tests/src';
$this->namespaces["Drupal\\Tests\\$module_name"] = $module_test_dir;

I think that this probably should be moved to phpstan-drupal project.

@mradcliffe
Copy link
Author

The @see drupal_phpunit_get_extension_namespaces comment also shows that it should behave like above and not like the logic in phpstan-drupal is doing.

I think I have enough direction to create a PR for this.

@mradcliffe
Copy link
Author

Fixed. Thank you, @mglaman . I'm going to test #121 as well manually.

I needed to fork phpstan-junit because that still depends on phpstan/phpstan 0.11 while phpstan-drupal master is now on 0.12.

@mglaman
Copy link
Owner

mglaman commented Jan 22, 2020

@mradcliffe ah I'll roll a release for that. FYI PHPStan now has a built in junit formatter, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants