BakeShellTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /**
  3. * BakeShell Test Case
  4. *
  5. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @since CakePHP(tm) v 1.3
  15. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  16. */
  17. namespace Cake\Test\TestCase\Console\Command;
  18. use Cake\Console\Command\BakeShellShell;
  19. use Cake\Controller\Controller;
  20. use Cake\Core\App;
  21. use Cake\Core\Configure;
  22. use Cake\TestSuite\TestCase;
  23. class BakeShellTest extends TestCase {
  24. /**
  25. * fixtures
  26. *
  27. * @var array
  28. */
  29. public $fixtures = array('core.comment');
  30. /**
  31. * setup test
  32. *
  33. * @return void
  34. */
  35. public function setUp() {
  36. parent::setUp();
  37. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  38. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  39. $this->Shell = $this->getMock(
  40. 'Cake\Console\Command\BakeShell',
  41. ['in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest'],
  42. [$out, $out, $in]
  43. );
  44. Configure::write('App.namespace', 'TestApp');
  45. }
  46. /**
  47. * tearDown method
  48. *
  49. * @return void
  50. */
  51. public function tearDown() {
  52. parent::tearDown();
  53. unset($this->Dispatch, $this->Shell);
  54. }
  55. /**
  56. * test bake all
  57. *
  58. * @return void
  59. */
  60. public function testAllWithModelName() {
  61. $this->markTestIncomplete('Baking with models is not working right now.');
  62. $dispatcher =& $this->Dispatcher;
  63. $this->Shell->Model = $this->getMock(
  64. 'Cake\Console\Command\Task\ModelTask',
  65. [],
  66. [$dispatcher]
  67. );
  68. $this->Shell->Controller = $this->getMock(
  69. 'Cake\Console\Command\Task\ControllerTask',
  70. [],
  71. [$dispatcher]
  72. );
  73. $this->Shell->View = $this->getMock(
  74. 'Cake\Console\Command\Task\ModelTask',
  75. [],
  76. [$dispatcher]
  77. );
  78. $this->Shell->DbConfig = $this->getMock(
  79. 'Cake\Console\Command\Task\DbConfigTask',
  80. [],
  81. [$dispatcher]
  82. );
  83. $this->Shell->DbConfig->expects($this->once())
  84. ->method('getConfig')
  85. ->will($this->returnValue('test'));
  86. $this->Shell->Model->expects($this->never())
  87. ->method('getName');
  88. $this->Shell->Model->expects($this->once())
  89. ->method('bake')
  90. ->will($this->returnValue(true));
  91. $this->Shell->Controller->expects($this->once())
  92. ->method('bake')
  93. ->will($this->returnValue(true));
  94. $this->Shell->View->expects($this->once())
  95. ->method('execute');
  96. $this->Shell->expects($this->once())
  97. ->method('_stop');
  98. $this->Shell->expects($this->at(0))
  99. ->method('out')
  100. ->with('Bake All');
  101. $this->Shell->expects($this->at(4))
  102. ->method('out')
  103. ->with('<success>Bake All complete</success>');
  104. $this->Shell->connection = '';
  105. $this->Shell->params = array();
  106. $this->Shell->args = array('Comment');
  107. $this->Shell->all();
  108. $this->assertEquals('Comment', $this->Shell->View->args[0]);
  109. }
  110. }