TestSuiteTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * @since 1.2.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\TestSuite;
  16. use Cake\TestSuite\TestCase;
  17. use Cake\Utility\Folder;
  18. /**
  19. * TestSuiteTest
  20. *
  21. */
  22. class TestSuiteTest extends TestCase {
  23. /**
  24. * testAddTestDirectory
  25. *
  26. * @return void
  27. */
  28. public function testAddTestDirectory() {
  29. $testFolder = CORE_TEST_CASES . DS . 'TestSuite';
  30. $count = count(glob($testFolder . DS . '*Test.php'));
  31. $suite = $this->getMock('Cake\TestSuite\TestSuite', array('addTestFile'));
  32. $suite
  33. ->expects($this->exactly($count))
  34. ->method('addTestFile');
  35. $suite->addTestDirectory($testFolder);
  36. }
  37. /**
  38. * testAddTestDirectoryRecursive
  39. *
  40. * @return void
  41. */
  42. public function testAddTestDirectoryRecursive() {
  43. $testFolder = CORE_TEST_CASES . DS . 'Cache';
  44. $count = count(glob($testFolder . DS . '*Test.php'));
  45. $count += count(glob($testFolder . DS . 'Engine/*Test.php'));
  46. $suite = $this->getMock('Cake\TestSuite\TestSuite', array('addTestFile'));
  47. $suite
  48. ->expects($this->exactly($count))
  49. ->method('addTestFile');
  50. $suite->addTestDirectoryRecursive($testFolder);
  51. }
  52. /**
  53. * testAddTestDirectoryRecursiveWithHidden
  54. *
  55. * @return void
  56. */
  57. public function testAddTestDirectoryRecursiveWithHidden() {
  58. $this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithHidden unless the tmp folder is writable.');
  59. $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
  60. mkdir($Folder->path . DS . '.svn', 0777, true);
  61. touch($Folder->path . DS . '.svn/InHiddenFolderTest.php');
  62. touch($Folder->path . DS . 'NotHiddenTest.php');
  63. touch($Folder->path . DS . '.HiddenTest.php');
  64. $suite = $this->getMock('Cake\TestSuite\TestSuite', array('addTestFile'));
  65. $suite
  66. ->expects($this->exactly(1))
  67. ->method('addTestFile');
  68. $suite->addTestDirectoryRecursive($Folder->pwd());
  69. $Folder->delete();
  70. }
  71. /**
  72. * testAddTestDirectoryRecursiveWithNonPhp
  73. *
  74. * @return void
  75. */
  76. public function testAddTestDirectoryRecursiveWithNonPhp() {
  77. $this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
  78. $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
  79. touch($Folder->path . DS . 'BackupTest.php~');
  80. touch($Folder->path . DS . 'SomeNotesTest.txt');
  81. touch($Folder->path . DS . 'NotHiddenTest.php');
  82. $suite = $this->getMock('Cake\TestSuite\TestSuite', array('addTestFile'));
  83. $suite
  84. ->expects($this->exactly(1))
  85. ->method('addTestFile');
  86. $suite->addTestDirectoryRecursive($Folder->pwd());
  87. $Folder->delete();
  88. }
  89. }