2014-04-23 10:51:50 +08:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A class to contain test cases and run them with shared fixtures
|
|
|
|
*
|
2018-03-18 09:24:15 +08:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2014-04-23 10:51:50 +08:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2018-03-18 09:24:15 +08:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
|
|
|
* @link https://cakephp.org CakePHP(tm) Project
|
2014-04-23 10:51:50 +08:00
|
|
|
* @package Cake.TestSuite
|
|
|
|
* @since CakePHP(tm) v 2.0
|
2018-03-18 09:24:15 +08:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2014-04-23 10:51:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
App::uses('Folder', 'Utility');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class to contain test cases and run them with shared fixtures
|
|
|
|
*
|
|
|
|
* @package Cake.TestSuite
|
|
|
|
*/
|
|
|
|
class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all the files in a directory to the test suite. Does not recurse through directories.
|
|
|
|
*
|
|
|
|
* @param string $directory The directory to add tests from.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function addTestDirectory($directory = '.') {
|
|
|
|
$Folder = new Folder($directory);
|
|
|
|
list(, $files) = $Folder->read(true, true, true);
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if (substr($file, -4) === '.php') {
|
|
|
|
$this->addTestFile($file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Recursively adds all the files in a directory to the test suite.
|
|
|
|
*
|
|
|
|
* @param string $directory The directory subtree to add tests from.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function addTestDirectoryRecursive($directory = '.') {
|
|
|
|
$Folder = new Folder($directory);
|
|
|
|
$files = $Folder->tree(null, true, 'files');
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
if (substr($file, -4) === '.php') {
|
|
|
|
$this->addTestFile($file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|