TestSuiteTest.php 3.3 KB

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