ProjectTaskTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.3.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Console\Command\Task;
  16. use Cake\Console\Command\Task\ProjectTask;
  17. use Cake\Core\Configure;
  18. use Cake\TestSuite\TestCase;
  19. use Cake\Utility\File;
  20. use Cake\Utility\Folder;
  21. /**
  22. * ProjectTask Test class
  23. *
  24. */
  25. class ProjectTaskTest extends TestCase {
  26. /**
  27. * setUp method
  28. *
  29. * @return void
  30. */
  31. public function setUp() {
  32. parent::setUp();
  33. $io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
  34. $this->Task = $this->getMock('Cake\Console\Command\Task\ProjectTask',
  35. array('in', 'err', 'createFile', '_stop'),
  36. array($io)
  37. );
  38. $this->Task->path = TMP;
  39. }
  40. /**
  41. * tearDown method
  42. *
  43. * @return void
  44. */
  45. public function tearDown() {
  46. parent::tearDown();
  47. $Folder = new Folder($this->Task->path . 'BakeTestApp');
  48. $Folder->delete();
  49. unset($this->Task);
  50. }
  51. /**
  52. * creates a test project that is used for testing project task.
  53. *
  54. * @return void
  55. */
  56. protected function _setupTestProject() {
  57. $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
  58. $this->Task->bake($this->Task->path . 'BakeTestApp');
  59. }
  60. /**
  61. * test bake with an absolute path.
  62. *
  63. * @return void
  64. */
  65. public function testExecuteWithAbsolutePath() {
  66. $this->markTestIncomplete('Need to figure this out');
  67. $this->Task->params['skel'] = CAKE . 'Console/Templates/skel';
  68. $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
  69. $this->Task->main(TMP . 'BakeTestApp');
  70. $this->assertTrue(is_dir(TMP . 'BakeTestApp'), 'No project dir');
  71. $File = new File($path . DS . 'Config/paths.php');
  72. $contents = $File->read();
  73. $this->assertRegExp('/define\(\'CAKE_CORE_INCLUDE_PATH\', .*?DS/', $contents);
  74. }
  75. /**
  76. * Copy the TestApp route file so it can be modified.
  77. *
  78. * @return void
  79. */
  80. protected function _cloneRoutes() {
  81. $File = new File(TEST_APP . 'TestApp/Config/routes.php');
  82. $contents = $File->read();
  83. mkdir(TMP . 'BakeTestApp/Config/', 0777, true);
  84. $File = new File(TMP . 'BakeTestApp/Config/routes.php');
  85. $File->write($contents);
  86. }
  87. }