@mnapoli opened this issue on October 28th 2014

The generate:travis-yml was looking for test files in plugins, but it was looking in tests/*Test.php or tests/*/*Test.php. And of course, for plugins that had plugins in a 3 level deep subdirectory (i.e. tests/*/*/*Test.php) the command was failing because no tests were found. This is the case for example for the ActivityLog plugin.

I could have fixed it by adding another test to the list (because glob() doesn't match recursively):

$testFiles = array_merge(glob($folderPath . "/*/*Test.php"), glob($folderPath . "/*Test.php"), glob($folderPath . "/*/*/*Test.php"));
return !empty($testFiles);

But this is not really ideal, so instead of writing useless complex code I went with using Symfony's Finder component:

$finder = new Finder();
$finder->files()
    ->in($folderPath)
    ->name('*Test.php');
return count($finder) > 0;

So that's the reason I'm opening a pull request: do you think that's fine to introduce a new dependency to that component? I've been using the Finder for a while in other projects and it's really useful, I'm guessing it could be reused in many places in Piwik.

@mattab commented on October 28th 2014

because glob() doesn't match recursively

Maybe globr would help here? http://developer.piwik.org/api-reference/Piwik/Filesystem#globr

@mnapoli commented on October 28th 2014

Fixed with Piwik\Filesystem::globr()

@mattab commented on October 28th 2014

done in https://github.com/piwik/piwik/commit/b64e589d21e1b0c63e03a839b7630e4ce5a4822b

This issue was closed on October 28th 2014
Powered by GitHub Issue Mirror