PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/misdghealth/cakephp-training
PHP | 104 lines | 49 code | 17 blank | 38 comment | 0 complexity | 7bdeab81f0d38b3623b08006e385fedd MD5 | raw file
  1. <?php
  2. /**
  3. * CakePHP : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2012, Cake Software Foundation, Inc.
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
  10. * @link http://cakephp.org CakePHP Project
  11. * @package Cake.Test.Case.TestSuite
  12. * @since CakePHP v 1.2.0.4487
  13. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  14. */
  15. /**
  16. * CakeTestSuiteTest
  17. *
  18. * @package Cake.Test.Case.TestSuite
  19. */
  20. class CakeTestSuiteTest extends CakeTestCase {
  21. /**
  22. * testAddTestDirectory
  23. *
  24. * @return void
  25. */
  26. public function testAddTestDirectory() {
  27. $testFolder = CORE_TEST_CASES . DS . 'TestSuite';
  28. $count = count(glob($testFolder . DS . '*Test.php'));
  29. $suite = $this->getMock('CakeTestSuite', array('addTestFile'));
  30. $suite
  31. ->expects($this->exactly($count))
  32. ->method('addTestFile');
  33. $suite->addTestDirectory($testFolder);
  34. }
  35. /**
  36. * testAddTestDirectoryRecursive
  37. *
  38. * @return void
  39. */
  40. public function testAddTestDirectoryRecursive() {
  41. $testFolder = CORE_TEST_CASES . DS . 'Cache';
  42. $count = count(glob($testFolder . DS . '*Test.php'));
  43. $count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php'));
  44. $suite = $this->getMock('CakeTestSuite', array('addTestFile'));
  45. $suite
  46. ->expects($this->exactly($count))
  47. ->method('addTestFile');
  48. $suite->addTestDirectoryRecursive($testFolder);
  49. }
  50. /**
  51. * testAddTestDirectoryRecursiveWithHidden
  52. *
  53. * @return void
  54. */
  55. public function testAddTestDirectoryRecursiveWithHidden() {
  56. $this->skipIf(!is_writeable(TMP), 'Cant addTestDirectoryRecursiveWithHidden unless the tmp folder is writable.');
  57. $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
  58. mkdir($Folder->path . DS . '.svn', 0777, true);
  59. touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolderTest.php');
  60. touch($Folder->path . DS . 'NotHiddenTest.php');
  61. touch($Folder->path . DS . '.HiddenTest.php');
  62. $suite = $this->getMock('CakeTestSuite', array('addTestFile'));
  63. $suite
  64. ->expects($this->exactly(1))
  65. ->method('addTestFile');
  66. $suite->addTestDirectoryRecursive($Folder->pwd());
  67. $Folder->delete();
  68. }
  69. /**
  70. * testAddTestDirectoryRecursiveWithNonPhp
  71. *
  72. * @return void
  73. */
  74. public function testAddTestDirectoryRecursiveWithNonPhp() {
  75. $this->skipIf(!is_writeable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
  76. $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
  77. touch($Folder->path . DS . 'BackupTest.php~');
  78. touch($Folder->path . DS . 'SomeNotesTest.txt');
  79. touch($Folder->path . DS . 'NotHiddenTest.php');
  80. $suite = $this->getMock('CakeTestSuite', array('addTestFile'));
  81. $suite
  82. ->expects($this->exactly(1))
  83. ->method('addTestFile');
  84. $suite->addTestDirectoryRecursive($Folder->pwd());
  85. $Folder->delete();
  86. }
  87. }