pictcode / lib / Cake / Test / Case / TestSuite / CakeTestSuiteTest.php @ 40928d1c
履歴 | 表示 | アノテート | ダウンロード (2.979 KB)
| 1 |
<?php
|
|---|---|
| 2 |
/**
|
| 3 |
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
| 4 |
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 5 |
*
|
| 6 |
* Licensed under The MIT License
|
| 7 |
* For full copyright and license information, please see the LICENSE.txt
|
| 8 |
* Redistributions of files must retain the above copyright notice.
|
| 9 |
*
|
| 10 |
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
| 11 |
* @link http://cakephp.org CakePHP Project
|
| 12 |
* @package Cake.Test.Case.TestSuite
|
| 13 |
* @since CakePHP v 1.2.0.4487
|
| 14 |
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
| 15 |
*/
|
| 16 |
|
| 17 |
/**
|
| 18 |
* CakeTestSuiteTest
|
| 19 |
*
|
| 20 |
* @package Cake.Test.Case.TestSuite
|
| 21 |
*/
|
| 22 |
class CakeTestSuiteTest extends CakeTestCase { |
| 23 |
|
| 24 |
/**
|
| 25 |
* testAddTestDirectory
|
| 26 |
*
|
| 27 |
* @return void
|
| 28 |
*/
|
| 29 |
public function testAddTestDirectory() { |
| 30 |
$testFolder = CORE_TEST_CASES . DS . 'TestSuite'; |
| 31 |
$count = count(glob($testFolder . DS . '*Test.php')); |
| 32 |
|
| 33 |
$suite = $this->getMock('CakeTestSuite', array('addTestFile')); |
| 34 |
$suite
|
| 35 |
->expects($this->exactly($count)) |
| 36 |
->method('addTestFile');
|
| 37 |
|
| 38 |
$suite->addTestDirectory($testFolder); |
| 39 |
} |
| 40 |
|
| 41 |
/**
|
| 42 |
* testAddTestDirectoryRecursive
|
| 43 |
*
|
| 44 |
* @return void
|
| 45 |
*/
|
| 46 |
public function testAddTestDirectoryRecursive() { |
| 47 |
$testFolder = CORE_TEST_CASES . DS . 'Cache'; |
| 48 |
$count = count(glob($testFolder . DS . '*Test.php')); |
| 49 |
$count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php')); |
| 50 |
|
| 51 |
$suite = $this->getMock('CakeTestSuite', array('addTestFile')); |
| 52 |
$suite
|
| 53 |
->expects($this->exactly($count)) |
| 54 |
->method('addTestFile');
|
| 55 |
|
| 56 |
$suite->addTestDirectoryRecursive($testFolder); |
| 57 |
} |
| 58 |
|
| 59 |
/**
|
| 60 |
* testAddTestDirectoryRecursiveWithHidden
|
| 61 |
*
|
| 62 |
* @return void
|
| 63 |
*/
|
| 64 |
public function testAddTestDirectoryRecursiveWithHidden() { |
| 65 |
$this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithHidden unless the tmp folder is writable.'); |
| 66 |
|
| 67 |
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777); |
| 68 |
mkdir($Folder->path . DS . '.svn', 0777, true); |
| 69 |
touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolderTest.php'); |
| 70 |
touch($Folder->path . DS . 'NotHiddenTest.php'); |
| 71 |
touch($Folder->path . DS . '.HiddenTest.php'); |
| 72 |
|
| 73 |
$suite = $this->getMock('CakeTestSuite', array('addTestFile')); |
| 74 |
$suite
|
| 75 |
->expects($this->exactly(1)) |
| 76 |
->method('addTestFile');
|
| 77 |
|
| 78 |
$suite->addTestDirectoryRecursive($Folder->pwd()); |
| 79 |
|
| 80 |
$Folder->delete(); |
| 81 |
} |
| 82 |
|
| 83 |
/**
|
| 84 |
* testAddTestDirectoryRecursiveWithNonPhp
|
| 85 |
*
|
| 86 |
* @return void
|
| 87 |
*/
|
| 88 |
public function testAddTestDirectoryRecursiveWithNonPhp() { |
| 89 |
$this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.'); |
| 90 |
|
| 91 |
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777); |
| 92 |
touch($Folder->path . DS . 'BackupTest.php~'); |
| 93 |
touch($Folder->path . DS . 'SomeNotesTest.txt'); |
| 94 |
touch($Folder->path . DS . 'NotHiddenTest.php'); |
| 95 |
|
| 96 |
$suite = $this->getMock('CakeTestSuite', array('addTestFile')); |
| 97 |
$suite
|
| 98 |
->expects($this->exactly(1)) |
| 99 |
->method('addTestFile');
|
| 100 |
|
| 101 |
$suite->addTestDirectoryRecursive($Folder->pwd()); |
| 102 |
|
| 103 |
$Folder->delete(); |
| 104 |
} |
| 105 |
} |