2011-12-10 07:12:56 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2011-12-10 07:12:56 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2011-12-10 07:12:56 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP Project
|
2011-12-10 07:12:56 +00:00
|
|
|
* @package Cake.Test.Case.TestSuite
|
|
|
|
* @since CakePHP v 1.2.0.4487
|
2013-05-30 22:11:14 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2011-12-10 07:12:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CakeTestSuiteTest
|
|
|
|
*
|
|
|
|
* @package Cake.Test.Case.TestSuite
|
|
|
|
*/
|
|
|
|
class CakeTestSuiteTest extends CakeTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testAddTestDirectory
|
2012-07-18 01:55:29 +00:00
|
|
|
*
|
2011-12-10 07:12:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAddTestDirectory() {
|
|
|
|
$testFolder = CORE_TEST_CASES . DS . 'TestSuite';
|
|
|
|
$count = count(glob($testFolder . DS . '*Test.php'));
|
|
|
|
|
|
|
|
$suite = $this->getMock('CakeTestSuite', array('addTestFile'));
|
|
|
|
$suite
|
|
|
|
->expects($this->exactly($count))
|
|
|
|
->method('addTestFile');
|
|
|
|
|
|
|
|
$suite->addTestDirectory($testFolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testAddTestDirectoryRecursive
|
2012-07-18 01:55:29 +00:00
|
|
|
*
|
2011-12-10 07:12:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2012-02-16 18:28:21 +00:00
|
|
|
public function testAddTestDirectoryRecursive() {
|
2011-12-10 07:12:56 +00:00
|
|
|
$testFolder = CORE_TEST_CASES . DS . 'Cache';
|
|
|
|
$count = count(glob($testFolder . DS . '*Test.php'));
|
|
|
|
$count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php'));
|
|
|
|
|
|
|
|
$suite = $this->getMock('CakeTestSuite', array('addTestFile'));
|
|
|
|
$suite
|
|
|
|
->expects($this->exactly($count))
|
|
|
|
->method('addTestFile');
|
|
|
|
|
|
|
|
$suite->addTestDirectoryRecursive($testFolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testAddTestDirectoryRecursiveWithHidden
|
2012-07-18 01:55:29 +00:00
|
|
|
*
|
2011-12-10 07:12:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAddTestDirectoryRecursiveWithHidden() {
|
2012-09-15 10:17:35 +00:00
|
|
|
$this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithHidden unless the tmp folder is writable.');
|
2011-12-10 07:12:56 +00:00
|
|
|
|
|
|
|
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
|
|
|
|
mkdir($Folder->path . DS . '.svn', 0777, true);
|
|
|
|
touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolderTest.php');
|
|
|
|
touch($Folder->path . DS . 'NotHiddenTest.php');
|
|
|
|
touch($Folder->path . DS . '.HiddenTest.php');
|
|
|
|
|
|
|
|
$suite = $this->getMock('CakeTestSuite', array('addTestFile'));
|
|
|
|
$suite
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
->method('addTestFile');
|
|
|
|
|
|
|
|
$suite->addTestDirectoryRecursive($Folder->pwd());
|
|
|
|
|
2012-04-23 10:49:28 +00:00
|
|
|
$Folder->delete();
|
|
|
|
}
|
2012-04-25 00:09:39 +00:00
|
|
|
|
2012-04-23 10:49:28 +00:00
|
|
|
/**
|
|
|
|
* testAddTestDirectoryRecursiveWithNonPhp
|
2012-07-18 01:55:29 +00:00
|
|
|
*
|
2012-04-23 10:49:28 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAddTestDirectoryRecursiveWithNonPhp() {
|
2012-09-15 10:17:35 +00:00
|
|
|
$this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
|
2012-04-23 10:49:28 +00:00
|
|
|
|
|
|
|
$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());
|
|
|
|
|
2011-12-10 07:12:56 +00:00
|
|
|
$Folder->delete();
|
|
|
|
}
|
|
|
|
}
|