ModelTaskTest.php 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  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 CakePHP v 1.2.6
  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\ModelTask;
  17. use Cake\Console\Command\Task\TemplateTask;
  18. use Cake\Core\Plugin;
  19. use Cake\Model\Model;
  20. use Cake\TestSuite\TestCase;
  21. use Cake\Utility\ClassRegistry;
  22. use Cake\Utility\Inflector;
  23. /**
  24. * ModelTaskTest class
  25. *
  26. */
  27. class ModelTaskTest extends TestCase {
  28. /**
  29. * fixtures
  30. *
  31. * @var array
  32. */
  33. public $fixtures = array(
  34. 'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag',
  35. 'core.bake_tag', 'core.category_thread', 'core.number_tree'
  36. );
  37. /**
  38. * setUp method
  39. *
  40. * @return void
  41. */
  42. public function setUp() {
  43. parent::setUp();
  44. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  45. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  46. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  47. array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
  48. array($out, $out, $in)
  49. );
  50. $this->Task->connection = 'test';
  51. $this->_setupOtherMocks();
  52. }
  53. /**
  54. * Setup a mock that has out mocked. Normally this is not used as it makes $this->at() really tricky.
  55. *
  56. * @return void
  57. */
  58. protected function _useMockedOut() {
  59. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  60. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  61. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  62. array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
  63. array($out, $out, $in)
  64. );
  65. $this->_setupOtherMocks();
  66. }
  67. /**
  68. * sets up the rest of the dependencies for Model Task
  69. *
  70. * @return void
  71. */
  72. protected function _setupOtherMocks() {
  73. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  74. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  75. $this->Task->Fixture = $this->getMock('Cake\Console\Command\Task\FixtureTask', [], [$out, $out, $in]);
  76. $this->Task->Test = $this->getMock('Cake\Console\Command\Task\FixtureTask', [], [$out, $out, $in]);
  77. $this->Task->Template = new TemplateTask($out, $out, $in);
  78. $this->Task->name = 'Model';
  79. }
  80. /**
  81. * tearDown method
  82. *
  83. * @return void
  84. */
  85. public function tearDown() {
  86. parent::tearDown();
  87. unset($this->Task);
  88. }
  89. /**
  90. * Test that listAll uses the connection property
  91. *
  92. * @return void
  93. */
  94. public function testListAllConnection() {
  95. $this->_useMockedOut();
  96. $this->Task->connection = 'test';
  97. $result = $this->Task->listAll();
  98. $this->assertContains('bake_articles', $result);
  99. $this->assertContains('bake_articles_bake_tags', $result);
  100. $this->assertContains('bake_tags', $result);
  101. $this->assertContains('bake_comments', $result);
  102. $this->assertContains('category_threads', $result);
  103. }
  104. /**
  105. * Test getName() method.
  106. *
  107. * @return void
  108. */
  109. public function testGetTable() {
  110. $this->Task->args[0] = 'BakeArticle';
  111. $result = $this->Task->getTable();
  112. $this->assertEquals('bake_articles', $result);
  113. $this->Task->args[0] = 'BakeArticles';
  114. $result = $this->Task->getTable();
  115. $this->assertEquals('bake_articles', $result);
  116. $this->Task->args[0] = 'Article';
  117. $this->Task->params['table'] = 'bake_articles';
  118. $result = $this->Task->getTable();
  119. $this->assertEquals('bake_articles', $result);
  120. }
  121. /**
  122. * Test getting the a table class.
  123. *
  124. * @return void
  125. */
  126. public function testGetTableObject() {
  127. $result = $this->Task->getTableObject('Article', 'bake_articles');
  128. $this->assertInstanceOf('Cake\ORM\Table', $result);
  129. $this->assertEquals('bake_articles', $result->table());
  130. $this->assertEquals('Article', $result->alias());
  131. }
  132. /**
  133. * test that initializing the validations works.
  134. *
  135. * @return void
  136. */
  137. public function testInitValidations() {
  138. $this->markTestIncomplete('Not done here yet');
  139. $result = $this->Task->initValidations();
  140. $this->assertTrue(in_array('notEmpty', $result));
  141. }
  142. /**
  143. * test that individual field validation works, with interactive = false
  144. * tests the guessing features of validation
  145. *
  146. * @return void
  147. */
  148. public function testFieldValidationGuessing() {
  149. $this->markTestIncomplete('Not done here yet');
  150. $this->Task->interactive = false;
  151. $this->Task->initValidations();
  152. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  153. $expected = array('notEmpty' => 'notEmpty');
  154. $this->assertEquals($expected, $result);
  155. $result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
  156. $expected = array('date' => 'date');
  157. $this->assertEquals($expected, $result);
  158. $result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false));
  159. $expected = array('time' => 'time');
  160. $this->assertEquals($expected, $result);
  161. $result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false));
  162. $expected = array('email' => 'email');
  163. $this->assertEquals($expected, $result);
  164. $result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false));
  165. $expected = array('numeric' => 'numeric');
  166. $this->assertEquals($expected, $result);
  167. $result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false));
  168. $expected = array('boolean' => 'boolean');
  169. $this->assertEquals($expected, $result);
  170. }
  171. /**
  172. * test that interactive field validation works and returns multiple validators.
  173. *
  174. * @return void
  175. */
  176. public function testInteractiveFieldValidation() {
  177. $this->markTestIncomplete('Not done here yet');
  178. $this->Task->initValidations();
  179. $this->Task->interactive = true;
  180. $this->Task->expects($this->any())->method('in')
  181. ->will($this->onConsecutiveCalls('24', 'y', '18', 'n'));
  182. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  183. $expected = array('notEmpty' => 'notEmpty', 'maxLength' => 'maxLength');
  184. $this->assertEquals($expected, $result);
  185. }
  186. /**
  187. * test that a bogus response doesn't cause errors to bubble up.
  188. *
  189. * @return void
  190. */
  191. public function testInteractiveFieldValidationWithBogusResponse() {
  192. $this->markTestIncomplete('Not done here yet');
  193. $this->_useMockedOut();
  194. $this->Task->initValidations();
  195. $this->Task->interactive = true;
  196. $this->Task->expects($this->any())->method('in')
  197. ->will($this->onConsecutiveCalls('999999', '24', 'n'));
  198. $this->Task->expects($this->at(10))->method('out')
  199. ->with($this->stringContains('make a valid'));
  200. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  201. $expected = array('notEmpty' => 'notEmpty');
  202. $this->assertEquals($expected, $result);
  203. }
  204. /**
  205. * test that a regular expression can be used for validation.
  206. *
  207. * @return void
  208. */
  209. public function testInteractiveFieldValidationWithRegexp() {
  210. $this->markTestIncomplete('Not done here yet');
  211. $this->Task->initValidations();
  212. $this->Task->interactive = true;
  213. $this->Task->expects($this->any())->method('in')
  214. ->will($this->onConsecutiveCalls('/^[a-z]{0,9}$/', 'n'));
  215. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  216. $expected = array('a_z_0_9' => '/^[a-z]{0,9}$/');
  217. $this->assertEquals($expected, $result);
  218. }
  219. /**
  220. * Test that skipping fields during rule choice works when doing interactive field validation.
  221. *
  222. * @return void
  223. */
  224. public function testSkippingChoiceInteractiveFieldValidation() {
  225. $this->markTestIncomplete('Not done here yet');
  226. $this->Task->initValidations();
  227. $this->Task->interactive = true;
  228. $this->Task->expects($this->any())->method('in')
  229. ->will($this->onConsecutiveCalls('24', 'y', 's'));
  230. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  231. $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
  232. $this->assertEquals($expected, $result);
  233. }
  234. /**
  235. * Test that skipping fields after rule choice works when doing interactive field validation.
  236. *
  237. * @return void
  238. */
  239. public function testSkippingAnotherInteractiveFieldValidation() {
  240. $this->markTestIncomplete('Not done here yet');
  241. $this->Task->initValidations();
  242. $this->Task->interactive = true;
  243. $this->Task->expects($this->any())->method('in')
  244. ->will($this->onConsecutiveCalls('24', 's'));
  245. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  246. $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
  247. $this->assertEquals($expected, $result);
  248. }
  249. /**
  250. * Test the validation generation routine with skipping the rest of the fields
  251. * when doing interactive field validation.
  252. *
  253. * @return void
  254. */
  255. public function testInteractiveDoValidationWithSkipping() {
  256. $this->markTestIncomplete('Not done here yet');
  257. $this->Task->expects($this->any())
  258. ->method('in')
  259. ->will($this->onConsecutiveCalls('35', '24', 'n', '11', 's'));
  260. $this->Task->interactive = true;
  261. $Model = $this->getMock('Model');
  262. $Model->primaryKey = 'id';
  263. $Model->expects($this->any())
  264. ->method('schema')
  265. ->will($this->returnValue(array(
  266. 'id' => array(
  267. 'type' => 'integer',
  268. 'length' => 11,
  269. 'null' => false,
  270. 'key' => 'primary',
  271. ),
  272. 'name' => array(
  273. 'type' => 'string',
  274. 'length' => 20,
  275. 'null' => false,
  276. ),
  277. 'email' => array(
  278. 'type' => 'string',
  279. 'length' => 255,
  280. 'null' => false,
  281. ),
  282. 'some_date' => array(
  283. 'type' => 'date',
  284. 'length' => '',
  285. 'null' => false,
  286. ),
  287. 'some_time' => array(
  288. 'type' => 'time',
  289. 'length' => '',
  290. 'null' => false,
  291. ),
  292. 'created' => array(
  293. 'type' => 'datetime',
  294. 'length' => '',
  295. 'null' => false,
  296. )
  297. )
  298. ));
  299. $result = $this->Task->doValidation($Model);
  300. $expected = array(
  301. 'name' => array(
  302. 'notEmpty' => 'notEmpty'
  303. ),
  304. 'email' => array(
  305. 'email' => 'email',
  306. ),
  307. );
  308. $this->assertEquals($expected, $result);
  309. }
  310. /**
  311. * test the validation Generation routine
  312. *
  313. * @return void
  314. */
  315. public function testNonInteractiveDoValidation() {
  316. $this->markTestIncomplete('Not done here yet');
  317. $Model = $this->getMock('Model');
  318. $Model->primaryKey = 'id';
  319. $Model->expects($this->any())
  320. ->method('schema')
  321. ->will($this->returnValue(array(
  322. 'id' => array(
  323. 'type' => 'integer',
  324. 'length' => 11,
  325. 'null' => false,
  326. 'key' => 'primary',
  327. ),
  328. 'name' => array(
  329. 'type' => 'string',
  330. 'length' => 20,
  331. 'null' => false,
  332. ),
  333. 'email' => array(
  334. 'type' => 'string',
  335. 'length' => 255,
  336. 'null' => false,
  337. ),
  338. 'some_date' => array(
  339. 'type' => 'date',
  340. 'length' => '',
  341. 'null' => false,
  342. ),
  343. 'some_time' => array(
  344. 'type' => 'time',
  345. 'length' => '',
  346. 'null' => false,
  347. ),
  348. 'created' => array(
  349. 'type' => 'datetime',
  350. 'length' => '',
  351. 'null' => false,
  352. )
  353. )
  354. ));
  355. $this->Task->interactive = false;
  356. $result = $this->Task->doValidation($Model);
  357. $expected = array(
  358. 'name' => array(
  359. 'notEmpty' => 'notEmpty'
  360. ),
  361. 'email' => array(
  362. 'email' => 'email',
  363. ),
  364. 'some_date' => array(
  365. 'date' => 'date'
  366. ),
  367. 'some_time' => array(
  368. 'time' => 'time'
  369. ),
  370. );
  371. $this->assertEquals($expected, $result);
  372. }
  373. /**
  374. * test that finding primary key works
  375. *
  376. * @return void
  377. */
  378. public function testFindPrimaryKey() {
  379. $this->markTestIncomplete('Not done here yet');
  380. $fields = array(
  381. 'one' => array(),
  382. 'two' => array(),
  383. 'key' => array('key' => 'primary')
  384. );
  385. $anything = new \PHPUnit_Framework_Constraint_IsAnything();
  386. $this->Task->expects($this->once())->method('in')
  387. ->with($anything, null, 'key')
  388. ->will($this->returnValue('my_field'));
  389. $result = $this->Task->findPrimaryKey($fields);
  390. $expected = 'my_field';
  391. $this->assertEquals($expected, $result);
  392. }
  393. /**
  394. * test finding Display field
  395. *
  396. * @return void
  397. */
  398. public function testFindDisplayFieldNone() {
  399. $this->markTestIncomplete('Not done here yet');
  400. $fields = array(
  401. 'id' => array(), 'tagname' => array(), 'body' => array(),
  402. 'created' => array(), 'modified' => array()
  403. );
  404. $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n'));
  405. $result = $this->Task->findDisplayField($fields);
  406. $this->assertFalse($result);
  407. }
  408. /**
  409. * Test finding a displayname from user input
  410. *
  411. * @return void
  412. */
  413. public function testFindDisplayName() {
  414. $this->markTestIncomplete('Not done here yet');
  415. $fields = array(
  416. 'id' => array(), 'tagname' => array(), 'body' => array(),
  417. 'created' => array(), 'modified' => array()
  418. );
  419. $this->Task->expects($this->any())->method('in')
  420. ->will($this->onConsecutiveCalls('y', 2));
  421. $result = $this->Task->findDisplayField($fields);
  422. $this->assertEquals('tagname', $result);
  423. }
  424. /**
  425. * test that belongsTo generation works.
  426. *
  427. * @return void
  428. */
  429. public function testBelongsToGeneration() {
  430. $this->markTestIncomplete('Not done here yet');
  431. $model = new Model(array('ds' => 'test', 'name' => 'BakeComment'));
  432. $result = $this->Task->findBelongsTo($model, array());
  433. $expected = array(
  434. 'belongsTo' => array(
  435. array(
  436. 'alias' => 'BakeArticle',
  437. 'className' => 'BakeArticle',
  438. 'foreignKey' => 'bake_article_id',
  439. ),
  440. array(
  441. 'alias' => 'BakeUser',
  442. 'className' => 'BakeUser',
  443. 'foreignKey' => 'bake_user_id',
  444. ),
  445. )
  446. );
  447. $this->assertEquals($expected, $result);
  448. $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
  449. $result = $this->Task->findBelongsTo($model, array());
  450. $expected = array(
  451. 'belongsTo' => array(
  452. array(
  453. 'alias' => 'ParentCategoryThread',
  454. 'className' => 'CategoryThread',
  455. 'foreignKey' => 'parent_id',
  456. ),
  457. )
  458. );
  459. $this->assertEquals($expected, $result);
  460. }
  461. /**
  462. * test that hasOne and/or hasMany relations are generated properly.
  463. *
  464. * @return void
  465. */
  466. public function testHasManyHasOneGeneration() {
  467. $this->markTestIncomplete('Not done here yet');
  468. $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
  469. $this->Task->connection = 'test';
  470. $this->Task->listAll();
  471. $result = $this->Task->findHasOneAndMany($model, array());
  472. $expected = array(
  473. 'hasMany' => array(
  474. array(
  475. 'alias' => 'BakeComment',
  476. 'className' => 'BakeComment',
  477. 'foreignKey' => 'bake_article_id',
  478. ),
  479. ),
  480. 'hasOne' => array(
  481. array(
  482. 'alias' => 'BakeComment',
  483. 'className' => 'BakeComment',
  484. 'foreignKey' => 'bake_article_id',
  485. ),
  486. ),
  487. );
  488. $this->assertEquals($expected, $result);
  489. $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
  490. $result = $this->Task->findHasOneAndMany($model, array());
  491. $expected = array(
  492. 'hasOne' => array(
  493. array(
  494. 'alias' => 'ChildCategoryThread',
  495. 'className' => 'CategoryThread',
  496. 'foreignKey' => 'parent_id',
  497. ),
  498. ),
  499. 'hasMany' => array(
  500. array(
  501. 'alias' => 'ChildCategoryThread',
  502. 'className' => 'CategoryThread',
  503. 'foreignKey' => 'parent_id',
  504. ),
  505. )
  506. );
  507. $this->assertEquals($expected, $result);
  508. }
  509. /**
  510. * Test that HABTM generation works
  511. *
  512. * @return void
  513. */
  514. public function testHasAndBelongsToManyGeneration() {
  515. $this->markTestIncomplete('Not done here yet');
  516. $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
  517. $this->Task->connection = 'test';
  518. $this->Task->listAll();
  519. $result = $this->Task->findHasAndBelongsToMany($model, array());
  520. $expected = array(
  521. 'hasAndBelongsToMany' => array(
  522. array(
  523. 'alias' => 'BakeTag',
  524. 'className' => 'BakeTag',
  525. 'foreignKey' => 'bake_article_id',
  526. 'joinTable' => 'bake_articles_bake_tags',
  527. 'associationForeignKey' => 'bake_tag_id',
  528. ),
  529. ),
  530. );
  531. $this->assertEquals($expected, $result);
  532. }
  533. /**
  534. * test non interactive doAssociations
  535. *
  536. * @return void
  537. */
  538. public function testDoAssociationsNonInteractive() {
  539. $this->markTestIncomplete('Not done here yet');
  540. $this->Task->connection = 'test';
  541. $this->Task->interactive = false;
  542. $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
  543. $result = $this->Task->doAssociations($model);
  544. $expected = array(
  545. 'belongsTo' => array(
  546. array(
  547. 'alias' => 'BakeUser',
  548. 'className' => 'BakeUser',
  549. 'foreignKey' => 'bake_user_id',
  550. ),
  551. ),
  552. 'hasMany' => array(
  553. array(
  554. 'alias' => 'BakeComment',
  555. 'className' => 'BakeComment',
  556. 'foreignKey' => 'bake_article_id',
  557. ),
  558. ),
  559. 'hasAndBelongsToMany' => array(
  560. array(
  561. 'alias' => 'BakeTag',
  562. 'className' => 'BakeTag',
  563. 'foreignKey' => 'bake_article_id',
  564. 'joinTable' => 'bake_articles_bake_tags',
  565. 'associationForeignKey' => 'bake_tag_id',
  566. ),
  567. ),
  568. );
  569. $this->assertEquals($expected, $result);
  570. }
  571. /**
  572. * test non interactive doActsAs
  573. *
  574. * @return void
  575. */
  576. public function testDoActsAs() {
  577. $this->markTestIncomplete('Not done here yet');
  578. $this->Task->connection = 'test';
  579. $this->Task->interactive = false;
  580. $model = new Model(array('ds' => 'test', 'name' => 'NumberTree'));
  581. $result = $this->Task->doActsAs($model);
  582. $this->assertEquals(array('Tree'), $result);
  583. }
  584. /**
  585. * Ensure that the fixture object is correctly called.
  586. *
  587. * @return void
  588. */
  589. public function testBakeFixture() {
  590. $this->markTestIncomplete('Not done here yet');
  591. $this->Task->plugin = 'TestPlugin';
  592. $this->Task->interactive = true;
  593. $this->Task->Fixture->expects($this->at(0))->method('bake')->with('BakeArticle', 'bake_articles');
  594. $this->Task->bakeFixture('BakeArticle', 'bake_articles');
  595. $this->assertEquals($this->Task->plugin, $this->Task->Fixture->plugin);
  596. $this->assertEquals($this->Task->connection, $this->Task->Fixture->connection);
  597. $this->assertEquals($this->Task->interactive, $this->Task->Fixture->interactive);
  598. }
  599. /**
  600. * Ensure that the test object is correctly called.
  601. *
  602. * @return void
  603. */
  604. public function testBakeTest() {
  605. $this->markTestIncomplete('Not done here yet');
  606. $this->Task->plugin = 'TestPlugin';
  607. $this->Task->interactive = true;
  608. $this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'BakeArticle');
  609. $this->Task->bakeTest('BakeArticle');
  610. $this->assertEquals($this->Task->plugin, $this->Task->Test->plugin);
  611. $this->assertEquals($this->Task->connection, $this->Task->Test->connection);
  612. $this->assertEquals($this->Task->interactive, $this->Task->Test->interactive);
  613. }
  614. /**
  615. * test confirming of associations, and that when an association is hasMany
  616. * a question for the hasOne is also not asked.
  617. *
  618. * @return void
  619. */
  620. public function testConfirmAssociations() {
  621. $this->markTestIncomplete('Not done here yet');
  622. $associations = array(
  623. 'hasOne' => array(
  624. array(
  625. 'alias' => 'ChildCategoryThread',
  626. 'className' => 'CategoryThread',
  627. 'foreignKey' => 'parent_id',
  628. ),
  629. ),
  630. 'hasMany' => array(
  631. array(
  632. 'alias' => 'ChildCategoryThread',
  633. 'className' => 'CategoryThread',
  634. 'foreignKey' => 'parent_id',
  635. ),
  636. ),
  637. 'belongsTo' => array(
  638. array(
  639. 'alias' => 'User',
  640. 'className' => 'User',
  641. 'foreignKey' => 'user_id',
  642. ),
  643. )
  644. );
  645. $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread'));
  646. $this->Task->expects($this->any())->method('in')
  647. ->will($this->onConsecutiveCalls('n', 'y', 'n', 'n', 'n'));
  648. $result = $this->Task->confirmAssociations($model, $associations);
  649. $this->assertTrue(empty($result['hasOne']));
  650. $result = $this->Task->confirmAssociations($model, $associations);
  651. $this->assertTrue(empty($result['hasMany']));
  652. $this->assertTrue(empty($result['hasOne']));
  653. }
  654. /**
  655. * test that inOptions generates questions and only accepts a valid answer
  656. *
  657. * @return void
  658. */
  659. public function testInOptions() {
  660. $this->markTestIncomplete('Not done here yet');
  661. $this->_useMockedOut();
  662. $options = array('one', 'two', 'three');
  663. $this->Task->expects($this->at(0))->method('out')->with('1. one');
  664. $this->Task->expects($this->at(1))->method('out')->with('2. two');
  665. $this->Task->expects($this->at(2))->method('out')->with('3. three');
  666. $this->Task->expects($this->at(3))->method('in')->will($this->returnValue(10));
  667. $this->Task->expects($this->at(4))->method('out')->with('1. one');
  668. $this->Task->expects($this->at(5))->method('out')->with('2. two');
  669. $this->Task->expects($this->at(6))->method('out')->with('3. three');
  670. $this->Task->expects($this->at(7))->method('in')->will($this->returnValue(2));
  671. $result = $this->Task->inOptions($options, 'Pick a number');
  672. $this->assertEquals(1, $result);
  673. }
  674. /**
  675. * test baking validation
  676. *
  677. * @return void
  678. */
  679. public function testBakeValidation() {
  680. $this->markTestIncomplete('Not done here yet');
  681. $validate = array(
  682. 'name' => array(
  683. 'notempty' => 'notEmpty'
  684. ),
  685. 'email' => array(
  686. 'email' => 'email',
  687. ),
  688. 'some_date' => array(
  689. 'date' => 'date'
  690. ),
  691. 'some_time' => array(
  692. 'time' => 'time'
  693. )
  694. );
  695. $result = $this->Task->bake('BakeArticle', compact('validate'));
  696. $this->assertRegExp('/class BakeArticle extends AppModel \{/', $result);
  697. $this->assertRegExp('/\$validate \= array\(/', $result);
  698. $expected = <<< STRINGEND
  699. array(
  700. 'notempty' => array(
  701. 'rule' => array('notEmpty'),
  702. //'message' => 'Your custom message here',
  703. //'allowEmpty' => false,
  704. //'required' => false,
  705. //'last' => false, // Stop validation after this rule
  706. //'on' => 'create', // Limit validation to 'create' or 'update' operations
  707. ),
  708. STRINGEND;
  709. $this->assertRegExp('/' . preg_quote(str_replace("\r\n", "\n", $expected), '/') . '/', $result);
  710. }
  711. /**
  712. * test baking relations
  713. *
  714. * @return void
  715. */
  716. public function testBakeRelations() {
  717. $this->markTestIncomplete('Not done here yet');
  718. $associations = array(
  719. 'belongsTo' => array(
  720. array(
  721. 'alias' => 'SomethingElse',
  722. 'className' => 'SomethingElse',
  723. 'foreignKey' => 'something_else_id',
  724. ),
  725. array(
  726. 'alias' => 'BakeUser',
  727. 'className' => 'BakeUser',
  728. 'foreignKey' => 'bake_user_id',
  729. ),
  730. ),
  731. 'hasOne' => array(
  732. array(
  733. 'alias' => 'OtherModel',
  734. 'className' => 'OtherModel',
  735. 'foreignKey' => 'other_model_id',
  736. ),
  737. ),
  738. 'hasMany' => array(
  739. array(
  740. 'alias' => 'BakeComment',
  741. 'className' => 'BakeComment',
  742. 'foreignKey' => 'parent_id',
  743. ),
  744. ),
  745. 'hasAndBelongsToMany' => array(
  746. array(
  747. 'alias' => 'BakeTag',
  748. 'className' => 'BakeTag',
  749. 'foreignKey' => 'bake_article_id',
  750. 'joinTable' => 'bake_articles_bake_tags',
  751. 'associationForeignKey' => 'bake_tag_id',
  752. ),
  753. )
  754. );
  755. $result = $this->Task->bake('BakeArticle', compact('associations'));
  756. $this->assertContains(' * @property BakeUser $BakeUser', $result);
  757. $this->assertContains(' * @property OtherModel $OtherModel', $result);
  758. $this->assertContains(' * @property BakeComment $BakeComment', $result);
  759. $this->assertContains(' * @property BakeTag $BakeTag', $result);
  760. $this->assertRegExp('/\$hasAndBelongsToMany \= array\(/', $result);
  761. $this->assertRegExp('/\$hasMany \= array\(/', $result);
  762. $this->assertRegExp('/\$belongsTo \= array\(/', $result);
  763. $this->assertRegExp('/\$hasOne \= array\(/', $result);
  764. $this->assertRegExp('/BakeTag/', $result);
  765. $this->assertRegExp('/OtherModel/', $result);
  766. $this->assertRegExp('/SomethingElse/', $result);
  767. $this->assertRegExp('/BakeComment/', $result);
  768. }
  769. /**
  770. * test bake() with a -plugin param
  771. *
  772. * @return void
  773. */
  774. public function testBakeWithPlugin() {
  775. $this->markTestIncomplete('Not done here yet');
  776. $this->Task->plugin = 'ControllerTest';
  777. //fake plugin path
  778. Plugin::load('ControllerTest', array('path' => APP . 'Plugin/ControllerTest/'));
  779. $path = APP . 'Plugin/ControllerTest/Model/BakeArticle.php';
  780. $this->Task->expects($this->once())->method('createFile')
  781. ->with($path, $this->stringContains('BakeArticle extends ControllerTestAppModel'));
  782. $result = $this->Task->bake('BakeArticle', array(), array());
  783. $this->assertContains("App::uses('ControllerTestAppModel', 'ControllerTest.Model');", $result);
  784. $this->assertEquals(count(ClassRegistry::keys()), 0);
  785. $this->assertEquals(count(ClassRegistry::mapKeys()), 0);
  786. }
  787. /**
  788. * test bake() for models with behaviors
  789. *
  790. * @return void
  791. */
  792. public function testBakeWithBehaviors() {
  793. $this->markTestIncomplete('Not done here yet');
  794. $result = $this->Task->bake('NumberTree', array('actsAs' => array('Tree', 'PluginName.Sluggable')));
  795. $expected = <<<TEXT
  796. /**
  797. * Behaviors
  798. *
  799. * @var array
  800. */
  801. public \$actsAs = array(
  802. 'Tree',
  803. 'PluginName.Sluggable',
  804. );
  805. TEXT;
  806. $this->assertTextContains($expected, $result);
  807. }
  808. /**
  809. * test that execute passes runs bake depending with named model.
  810. *
  811. * @return void
  812. */
  813. public function testExecuteWithNamedModel() {
  814. $this->markTestIncomplete('Not done here yet');
  815. $this->Task->connection = 'test';
  816. $this->Task->path = '/my/path/';
  817. $this->Task->args = array('BakeArticle');
  818. $filename = '/my/path/BakeArticle.php';
  819. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
  820. $this->Task->expects($this->once())->method('createFile')
  821. ->with($filename, $this->stringContains('class BakeArticle extends AppModel'));
  822. $this->Task->execute();
  823. $this->assertEquals(count(ClassRegistry::keys()), 0);
  824. $this->assertEquals(count(ClassRegistry::mapKeys()), 0);
  825. }
  826. /**
  827. * data provider for testExecuteWithNamedModelVariations
  828. *
  829. * @return void
  830. */
  831. public static function nameVariations() {
  832. return array(
  833. array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
  834. );
  835. }
  836. /**
  837. * test that execute passes with different inflections of the same name.
  838. *
  839. * @dataProvider nameVariations
  840. * @return void
  841. */
  842. public function testExecuteWithNamedModelVariations($name) {
  843. $this->markTestIncomplete('Not done here yet');
  844. $this->Task->connection = 'test';
  845. $this->Task->path = '/my/path/';
  846. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
  847. $this->Task->args = array($name);
  848. $filename = '/my/path/BakeArticle.php';
  849. $this->Task->expects($this->at(0))->method('createFile')
  850. ->with($filename, $this->stringContains('class BakeArticle extends AppModel'));
  851. $this->Task->execute();
  852. }
  853. /**
  854. * test that execute with a model name picks up hasMany associations.
  855. *
  856. * @return void
  857. */
  858. public function testExecuteWithNamedModelHasManyCreated() {
  859. $this->markTestIncomplete('Not done here yet');
  860. $this->Task->connection = 'test';
  861. $this->Task->path = '/my/path/';
  862. $this->Task->args = array('BakeArticle');
  863. $filename = '/my/path/BakeArticle.php';
  864. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
  865. $this->Task->expects($this->at(0))->method('createFile')
  866. ->with($filename, $this->stringContains("'BakeComment' => array("));
  867. $this->Task->execute();
  868. }
  869. /**
  870. * test that execute runs all() when args[0] = all
  871. *
  872. * @return void
  873. */
  874. public function testExecuteIntoAll() {
  875. $this->markTestIncomplete('Not done here yet');
  876. $count = count($this->Task->listAll('test'));
  877. if ($count != count($this->fixtures)) {
  878. $this->markTestSkipped('Additional tables detected.');
  879. }
  880. $this->Task->connection = 'test';
  881. $this->Task->path = '/my/path/';
  882. $this->Task->args = array('all');
  883. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  884. $this->Task->Fixture->expects($this->exactly(5))->method('bake');
  885. $this->Task->Test->expects($this->exactly(5))->method('bake');
  886. $filename = '/my/path/BakeArticle.php';
  887. $this->Task->expects($this->at(1))->method('createFile')
  888. ->with($filename, $this->stringContains('class BakeArticle'));
  889. $filename = '/my/path/BakeArticlesBakeTag.php';
  890. $this->Task->expects($this->at(2))->method('createFile')
  891. ->with($filename, $this->stringContains('class BakeArticlesBakeTag'));
  892. $filename = '/my/path/BakeComment.php';
  893. $this->Task->expects($this->at(3))->method('createFile')
  894. ->with($filename, $this->stringContains('class BakeComment'));
  895. $filename = '/my/path/BakeComment.php';
  896. $this->Task->expects($this->at(3))->method('createFile')
  897. ->with($filename, $this->stringContains('public $primaryKey = \'otherid\';'));
  898. $filename = '/my/path/BakeTag.php';
  899. $this->Task->expects($this->at(4))->method('createFile')
  900. ->with($filename, $this->stringContains('class BakeTag'));
  901. $filename = '/my/path/BakeTag.php';
  902. $this->Task->expects($this->at(4))->method('createFile')
  903. ->with($filename, $this->logicalNot($this->stringContains('public $primaryKey')));
  904. $filename = '/my/path/CategoryThread.php';
  905. $this->Task->expects($this->at(5))->method('createFile')
  906. ->with($filename, $this->stringContains('class CategoryThread'));
  907. $this->Task->execute();
  908. $this->assertEquals(count(ClassRegistry::keys()), 0);
  909. $this->assertEquals(count(ClassRegistry::mapKeys()), 0);
  910. }
  911. /**
  912. * test that odd tablenames aren't inflected back from modelname
  913. *
  914. * @return void
  915. */
  916. public function testExecuteIntoAllOddTables() {
  917. $this->markTestIncomplete('Not done here yet');
  918. $out = $this->getMock('Cake\Console\ConsoleOutput', array(), array(), '', false);
  919. $in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);
  920. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  921. array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'),
  922. array($out, $out, $in)
  923. );
  924. $this->_setupOtherMocks();
  925. $this->Task->connection = 'test';
  926. $this->Task->path = '/my/path/';
  927. $this->Task->args = array('all');
  928. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  929. $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd')));
  930. $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
  931. $this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object));
  932. $this->Task->expects($this->at(3))->method('bake')->with($object, false)->will($this->returnValue(true));
  933. $this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd');
  934. $this->Task->execute();
  935. $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
  936. $in = $this->getMock('ConsoleInput', array(), array(), '', false);
  937. $this->Task = $this->getMock('ModelTask',
  938. array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'),
  939. array($out, $out, $in)
  940. );
  941. $this->_setupOtherMocks();
  942. $this->Task->connection = 'test';
  943. $this->Task->path = '/my/path/';
  944. $this->Task->args = array('all');
  945. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  946. $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd')));
  947. $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
  948. $this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object));
  949. $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array()));
  950. $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array()));
  951. $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array()));
  952. $filename = '/my/path/BakeOdd.php';
  953. $this->Task->expects($this->once())->method('createFile')
  954. ->with($filename, $this->stringContains('class BakeOdd'));
  955. $filename = '/my/path/BakeOdd.php';
  956. $this->Task->expects($this->once())->method('createFile')
  957. ->with($filename, $this->stringContains('public $useTable = \'bake_odd\''));
  958. $this->Task->execute();
  959. }
  960. /**
  961. * test that odd tablenames aren't inflected back from modelname
  962. *
  963. * @return void
  964. */
  965. public function testExecuteIntoBakeOddTables() {
  966. $this->markTestIncomplete('Not done here yet');
  967. $out = $this->getMock('Cake\Console\ConsoleOutput', array(), array(), '', false);
  968. $in = $this->getMock('Cake\Console\ConsoleInput', array(), array(), '', false);
  969. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  970. array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'),
  971. array($out, $out, $in)
  972. );
  973. $this->_setupOtherMocks();
  974. $this->Task->connection = 'test';
  975. $this->Task->path = '/my/path/';
  976. $this->Task->args = array('BakeOdd');
  977. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  978. $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
  979. $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
  980. $this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object));
  981. $this->Task->expects($this->once())->method('bake')->with($object, false)->will($this->returnValue(true));
  982. $this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd');
  983. $this->Task->execute();
  984. $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
  985. $in = $this->getMock('ConsoleInput', array(), array(), '', false);
  986. $this->Task = $this->getMock('ModelTask',
  987. array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'),
  988. array($out, $out, $in)
  989. );
  990. $this->_setupOtherMocks();
  991. $this->Task->connection = 'test';
  992. $this->Task->path = '/my/path/';
  993. $this->Task->args = array('BakeOdd');
  994. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  995. $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
  996. $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
  997. $this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object));
  998. $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array()));
  999. $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array()));
  1000. $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array()));
  1001. $filename = '/my/path/BakeOdd.php';
  1002. $this->Task->expects($this->once())->method('createFile')
  1003. ->with($filename, $this->stringContains('class BakeOdd'));
  1004. $filename = '/my/path/BakeOdd.php';
  1005. $this->Task->expects($this->once())->method('createFile')
  1006. ->with($filename, $this->stringContains('public $useTable = \'bake_odd\''));
  1007. $this->Task->execute();
  1008. }
  1009. /**
  1010. * test that skipTables changes how all() works.
  1011. *
  1012. * @return void
  1013. */
  1014. public function testSkipTablesAndAll() {
  1015. $this->markTestIncomplete('Not done here yet');
  1016. $count = count($this->Task->listAll('test'));
  1017. if ($count != count($this->fixtures)) {
  1018. $this->markTestSkipped('Additional tables detected.');
  1019. }
  1020. $this->Task->connection = 'test';
  1021. $this->Task->path = '/my/path/';
  1022. $this->Task->args = array('all');
  1023. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  1024. $this->Task->skipTables = array('bake_tags');
  1025. $this->Task->Fixture->expects($this->exactly(4))->method('bake');
  1026. $this->Task->Test->expects($this->exactly(4))->method('bake');
  1027. $filename = '/my/path/BakeArticle.php';
  1028. $this->Task->expects($this->at(1))->method('createFile')
  1029. ->with($filename, $this->stringContains('class BakeArticle'));
  1030. $filename = '/my/path/BakeArticlesBakeTag.php';
  1031. $this->Task->expects($this->at(2))->method('createFile')
  1032. ->with($filename, $this->stringContains('class BakeArticlesBakeTag'));
  1033. $filename = '/my/path/BakeComment.php';
  1034. $this->Task->expects($this->at(3))->method('createFile')
  1035. ->with($filename, $this->stringContains('class BakeComment'));
  1036. $filename = '/my/path/CategoryThread.php';
  1037. $this->Task->expects($this->at(4))->method('createFile')
  1038. ->with($filename, $this->stringContains('class CategoryThread'));
  1039. $this->Task->execute();
  1040. }
  1041. /**
  1042. * test the interactive side of bake.
  1043. *
  1044. * @return void
  1045. */
  1046. public function testExecuteIntoInteractive() {
  1047. $this->markTestIncomplete('Not done here yet');
  1048. $tables = $this->Task->listAll('test');
  1049. $article = array_search('bake_articles', $tables) + 1;
  1050. $this->Task->connection = 'test';
  1051. $this->Task->path = '/my/path/';
  1052. $this->Task->interactive = true;
  1053. $this->Task->expects($this->any())->method('in')
  1054. ->will($this->onConsecutiveCalls(
  1055. $article, // article
  1056. 'n', // no validation
  1057. 'y', // associations
  1058. 'y', // comment relation
  1059. 'y', // user relation
  1060. 'y', // tag relation
  1061. 'n', // additional assocs
  1062. 'y' // looks good?
  1063. ));
  1064. $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
  1065. $this->Task->Test->expects($this->once())->method('bake');
  1066. $this->Task->Fixture->expects($this->once())->method('bake');
  1067. $filename = '/my/path/BakeArticle.php';
  1068. $this->Task->expects($this->once())->method('createFile')
  1069. ->with($filename, $this->stringContains('class BakeArticle'));
  1070. $this->Task->execute();
  1071. $this->assertEquals(count(ClassRegistry::keys()), 0);
  1072. $this->assertEquals(count(ClassRegistry::mapKeys()), 0);
  1073. }
  1074. /**
  1075. * test using bake interactively with a table that does not exist.
  1076. *
  1077. * @return void
  1078. */
  1079. public function testExecuteWithNonExistantTableName() {
  1080. $this->markTestIncomplete('Not done here yet');
  1081. $this->Task->connection = 'test';
  1082. $this->Task->path = '/my/path/';
  1083. $this->Task->expects($this->any())->method('in')
  1084. ->will($this->onConsecutiveCalls(
  1085. 'Foobar', // Or type in the name of the model
  1086. 'y', // Do you want to use this table
  1087. 'n' // Doesn't exist, continue anyway?
  1088. ));
  1089. $this->Task->execute();
  1090. }
  1091. /**
  1092. * test using bake interactively with a table that does not exist.
  1093. *
  1094. * @return void
  1095. */
  1096. public function testForcedExecuteWithNonExistantTableName() {
  1097. $this->markTestIncomplete('Not done here yet');
  1098. $this->Task->connection = 'test';
  1099. $this->Task->path = '/my/path/';
  1100. $this->Task->expects($this->any())->method('in')
  1101. ->will($this->onConsecutiveCalls(
  1102. 'Foobar', // Or type in the name of the model
  1103. 'y', // Do you want to use this table
  1104. 'y', // Doesn't exist, continue anyway?
  1105. 'id', // Primary key
  1106. 'y' // Looks good?
  1107. ));
  1108. $this->Task->execute();
  1109. }
  1110. }