PageRenderTime 62ms CodeModel.GetById 35ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php

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