mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
CakeTestSuite::addTestDirectory() ignore non-php
CakeTestSuite::addTestDirectory() and addTestDirectoryRecursive() now ignore any files that do not end in .php This avoids any stray non-php files being parsed, especially tilde-style backup files that end in .php~ Improves #2031 Signed-off-by: mark_story <mark@mark-story.com>
This commit is contained in:
parent
8a6417521f
commit
3f7e2f536f
2 changed files with 29 additions and 2 deletions
|
@ -76,6 +76,29 @@ class CakeTestSuiteTest extends CakeTestCase {
|
||||||
|
|
||||||
$suite->addTestDirectoryRecursive($Folder->pwd());
|
$suite->addTestDirectoryRecursive($Folder->pwd());
|
||||||
|
|
||||||
|
$Folder->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testAddTestDirectoryRecursiveWithNonPhp
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testAddTestDirectoryRecursiveWithNonPhp() {
|
||||||
|
$this->skipIf(!is_writeable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
|
||||||
|
|
||||||
|
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
|
||||||
|
touch($Folder->path . DS . 'BackupTest.php~');
|
||||||
|
touch($Folder->path . DS . 'SomeNotesTest.txt');
|
||||||
|
touch($Folder->path . DS . 'NotHiddenTest.php');
|
||||||
|
|
||||||
|
$suite = $this->getMock('CakeTestSuite', array('addTestFile'));
|
||||||
|
$suite
|
||||||
|
->expects($this->exactly(1))
|
||||||
|
->method('addTestFile');
|
||||||
|
|
||||||
|
$suite->addTestDirectoryRecursive($Folder->pwd());
|
||||||
|
|
||||||
$Folder->delete();
|
$Folder->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
||||||
list($dirs, $files) = $Folder->read(true, true, true);
|
list($dirs, $files) = $Folder->read(true, true, true);
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$this->addTestFile($file);
|
if (substr($file, -4) === '.php') {
|
||||||
|
$this->addTestFile($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +54,9 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
||||||
$files = $Folder->tree(null, true, 'files');
|
$files = $Folder->tree(null, true, 'files');
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$this->addTestFile($file);
|
if (substr($file, -4) === '.php') {
|
||||||
|
$this->addTestFile($file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue