PageRenderTime 45ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/tests/cases/console/libs/tasks/test.test.php

https://code.google.com/
PHP | 99 lines | 44 code | 7 blank | 48 comment | 3 complexity | 8071a5eee1152881d3222397b2c13e2c MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * TestTaskTest file
  5. *
  6. * Test Case for test generation shell task
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP : Rapid Development Framework (http://cakephp.org)
  11. * Copyright 2006-2010, Cake Software Foundation, Inc.
  12. *
  13. * Licensed under The MIT License
  14. * Redistributions of files must retain the above copyright notice.
  15. *
  16. * @copyright Copyright 2006-2010, Cake Software Foundation, Inc.
  17. * @link http://cakefoundation.org/projects/info/cakephp CakePHP Project
  18. * @package cake
  19. * @subpackage cake.tests.cases.console.libs.tasks
  20. * @since CakePHP v 1.2.0.7726
  21. * @version $Revision$
  22. * @modifiedby $LastChangedBy$
  23. * @lastmodified $Date$
  24. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  25. */
  26. App::import('Core', 'Shell');
  27. if (!defined('DISABLE_AUTO_DISPATCH')) {
  28. define('DISABLE_AUTO_DISPATCH', true);
  29. }
  30. if (!class_exists('ShellDispatcher')) {
  31. ob_start();
  32. $argv = false;
  33. require CAKE . 'console' . DS . 'cake.php';
  34. ob_end_clean();
  35. }
  36. if (!class_exists('TestTask')) {
  37. require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
  38. }
  39. Mock::generatePartial(
  40. 'ShellDispatcher', 'TestTestTaskMockShellDispatcher',
  41. array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
  42. );
  43. Mock::generatePartial(
  44. 'TestTask', 'MockTestTask',
  45. array('in', 'out', 'createFile')
  46. );
  47. /**
  48. * TestTaskTest class
  49. *
  50. * @package cake
  51. * @subpackage cake.tests.cases.console.libs.tasks
  52. */
  53. class TestTaskTest extends CakeTestCase {
  54. /**
  55. * setUp method
  56. *
  57. * @return void
  58. * @access public
  59. */
  60. function setUp() {
  61. $this->Dispatcher =& new TestTestTaskMockShellDispatcher();
  62. $this->Task =& new MockTestTask($this->Dispatcher);
  63. $this->Task->Dispatch =& $this->Dispatcher;
  64. }
  65. /**
  66. * tearDown method
  67. *
  68. * @return void
  69. * @access public
  70. */
  71. function tearDown() {
  72. ClassRegistry::flush();
  73. }
  74. /**
  75. * Test that file path generation doesn't continuously append paths.
  76. *
  77. * @access public
  78. * @return void
  79. */
  80. function testFilePathGeneration () {
  81. $file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
  82. $this->Task->Dispatch->expectNever('stderr');
  83. $this->Task->Dispatch->expectNever('_stop');
  84. $this->Task->setReturnValueAt(0, 'in', 'y');
  85. $this->Task->expectAt(0, 'createFile', array($file, '*'));
  86. $this->Task->bake('Model', 'MyClass');
  87. $this->Task->setReturnValueAt(1, 'in', 'y');
  88. $this->Task->expectAt(1, 'createFile', array($file, '*'));
  89. $this->Task->bake('Model', 'MyClass');
  90. }
  91. }
  92. ?>