ModelTaskTest.php 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  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\ORM\TableRegistry;
  21. use Cake\TestSuite\TestCase;
  22. use Cake\Utility\ClassRegistry;
  23. use Cake\Utility\Inflector;
  24. /**
  25. * ModelTaskTest class
  26. *
  27. */
  28. class ModelTaskTest extends TestCase {
  29. /**
  30. * fixtures
  31. *
  32. * @var array
  33. */
  34. public $fixtures = array(
  35. 'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag',
  36. 'core.bake_tag', 'core.category_thread', 'core.number_tree'
  37. );
  38. /**
  39. * setUp method
  40. *
  41. * @return void
  42. */
  43. public function setUp() {
  44. parent::setUp();
  45. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  46. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  47. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  48. array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
  49. array($out, $out, $in)
  50. );
  51. $this->Task->connection = 'test';
  52. $this->_setupOtherMocks();
  53. }
  54. /**
  55. * Setup a mock that has out mocked. Normally this is not used as it makes $this->at() really tricky.
  56. *
  57. * @return void
  58. */
  59. protected function _useMockedOut() {
  60. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  61. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  62. $this->Task = $this->getMock('Cake\Console\Command\Task\ModelTask',
  63. array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
  64. array($out, $out, $in)
  65. );
  66. $this->_setupOtherMocks();
  67. }
  68. /**
  69. * sets up the rest of the dependencies for Model Task
  70. *
  71. * @return void
  72. */
  73. protected function _setupOtherMocks() {
  74. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  75. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  76. $this->Task->Fixture = $this->getMock('Cake\Console\Command\Task\FixtureTask', [], [$out, $out, $in]);
  77. $this->Task->Test = $this->getMock('Cake\Console\Command\Task\FixtureTask', [], [$out, $out, $in]);
  78. $this->Task->Template = new TemplateTask($out, $out, $in);
  79. $this->Task->name = 'Model';
  80. }
  81. /**
  82. * tearDown method
  83. *
  84. * @return void
  85. */
  86. public function tearDown() {
  87. parent::tearDown();
  88. unset($this->Task);
  89. }
  90. /**
  91. * Test that listAll uses the connection property
  92. *
  93. * @return void
  94. */
  95. public function testListAllConnection() {
  96. $this->_useMockedOut();
  97. $this->Task->connection = 'test';
  98. $result = $this->Task->listAll();
  99. $this->assertContains('bake_articles', $result);
  100. $this->assertContains('bake_articles_bake_tags', $result);
  101. $this->assertContains('bake_tags', $result);
  102. $this->assertContains('bake_comments', $result);
  103. $this->assertContains('category_threads', $result);
  104. }
  105. /**
  106. * Test getName() method.
  107. *
  108. * @return void
  109. */
  110. public function testGetTable() {
  111. $this->Task->args[0] = 'BakeArticle';
  112. $result = $this->Task->getTable();
  113. $this->assertEquals('bake_articles', $result);
  114. $this->Task->args[0] = 'BakeArticles';
  115. $result = $this->Task->getTable();
  116. $this->assertEquals('bake_articles', $result);
  117. $this->Task->args[0] = 'Article';
  118. $this->Task->params['table'] = 'bake_articles';
  119. $result = $this->Task->getTable();
  120. $this->assertEquals('bake_articles', $result);
  121. }
  122. /**
  123. * Test getting the a table class.
  124. *
  125. * @return void
  126. */
  127. public function testGetTableObject() {
  128. $result = $this->Task->getTableObject('Article', 'bake_articles');
  129. $this->assertInstanceOf('Cake\ORM\Table', $result);
  130. $this->assertEquals('bake_articles', $result->table());
  131. $this->assertEquals('Article', $result->alias());
  132. }
  133. /**
  134. * Test getAssociations with off flag.
  135. *
  136. * @return void
  137. */
  138. public function testGetAssociationsNoFlag() {
  139. $this->Task->params['no-associations'] = true;
  140. $articles = TableRegistry::get('BakeArticle');
  141. $this->assertEquals([], $this->Task->getAssociations($articles));
  142. }
  143. /**
  144. * Test getAssociations
  145. *
  146. * @return void
  147. */
  148. public function testGetAssociations() {
  149. $articles = TableRegistry::get('BakeArticles');
  150. $result = $this->Task->getAssociations($articles);
  151. $expected = [
  152. 'belongsTo' => [
  153. [
  154. 'alias' => 'BakeUsers',
  155. 'className' => 'BakeUsers',
  156. 'foreignKey' => 'bake_user_id',
  157. ],
  158. ],
  159. 'hasMany' => [
  160. [
  161. 'alias' => 'BakeComments',
  162. 'className' => 'BakeComments',
  163. 'foreignKey' => 'bake_article_id',
  164. ],
  165. ],
  166. 'belongsToMany' => [
  167. [
  168. 'alias' => 'BakeTags',
  169. 'className' => 'BakeTags',
  170. 'foreignKey' => 'bake_article_id',
  171. 'joinTable' => 'bake_articles_bake_tags',
  172. 'targetForeignKey' => 'bake_tag_id',
  173. ],
  174. ],
  175. ];
  176. $this->assertEquals($expected, $result);
  177. }
  178. /**
  179. * test that belongsTo generation works.
  180. *
  181. * @return void
  182. */
  183. public function testBelongsToGeneration() {
  184. $model = TableRegistry::get('BakeComments');
  185. $result = $this->Task->findBelongsTo($model, []);
  186. $expected = [
  187. 'belongsTo' => [
  188. [
  189. 'alias' => 'BakeArticles',
  190. 'className' => 'BakeArticles',
  191. 'foreignKey' => 'bake_article_id',
  192. ],
  193. [
  194. 'alias' => 'BakeUsers',
  195. 'className' => 'BakeUsers',
  196. 'foreignKey' => 'bake_user_id',
  197. ],
  198. ]
  199. ];
  200. $this->assertEquals($expected, $result);
  201. $model = TableRegistry::get('CategoryThreads');
  202. $result = $this->Task->findBelongsTo($model, array());
  203. $expected = [
  204. 'belongsTo' => [
  205. [
  206. 'alias' => 'ParentCategoryThreads',
  207. 'className' => 'CategoryThreads',
  208. 'foreignKey' => 'parent_id',
  209. ],
  210. ]
  211. ];
  212. $this->assertEquals($expected, $result);
  213. }
  214. /**
  215. * test that hasOne and/or hasMany relations are generated properly.
  216. *
  217. * @return void
  218. */
  219. public function testHasManyGeneration() {
  220. $this->Task->connection = 'test';
  221. $model = TableRegistry::get('BakeArticles');
  222. $result = $this->Task->findHasMany($model, []);
  223. $expected = [
  224. 'hasMany' => [
  225. [
  226. 'alias' => 'BakeComments',
  227. 'className' => 'BakeComments',
  228. 'foreignKey' => 'bake_article_id',
  229. ],
  230. ],
  231. ];
  232. $this->assertEquals($expected, $result);
  233. $model = TableRegistry::get('CategoryThreads');
  234. $result = $this->Task->findHasMany($model, []);
  235. $expected = [
  236. 'hasMany' => [
  237. [
  238. 'alias' => 'ChildCategoryThreads',
  239. 'className' => 'CategoryThreads',
  240. 'foreignKey' => 'parent_id',
  241. ],
  242. ]
  243. ];
  244. $this->assertEquals($expected, $result);
  245. }
  246. /**
  247. * Test that HABTM generation works
  248. *
  249. * @return void
  250. */
  251. public function testHasAndBelongsToManyGeneration() {
  252. $this->Task->connection = 'test';
  253. $model = TableRegistry::get('BakeArticles');
  254. $result = $this->Task->findBelongsToMany($model, []);
  255. $expected = [
  256. 'belongsToMany' => [
  257. [
  258. 'alias' => 'BakeTags',
  259. 'className' => 'BakeTags',
  260. 'foreignKey' => 'bake_article_id',
  261. 'joinTable' => 'bake_articles_bake_tags',
  262. 'targetForeignKey' => 'bake_tag_id',
  263. ],
  264. ],
  265. ];
  266. $this->assertEquals($expected, $result);
  267. }
  268. /**
  269. * test that initializing the validations works.
  270. *
  271. * @return void
  272. */
  273. public function testInitValidations() {
  274. $this->markTestIncomplete('Not done here yet');
  275. $result = $this->Task->initValidations();
  276. $this->assertTrue(in_array('notEmpty', $result));
  277. }
  278. /**
  279. * test that individual field validation works, with interactive = false
  280. * tests the guessing features of validation
  281. *
  282. * @return void
  283. */
  284. public function testFieldValidationGuessing() {
  285. $this->markTestIncomplete('Not done here yet');
  286. $this->Task->interactive = false;
  287. $this->Task->initValidations();
  288. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  289. $expected = array('notEmpty' => 'notEmpty');
  290. $this->assertEquals($expected, $result);
  291. $result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
  292. $expected = array('date' => 'date');
  293. $this->assertEquals($expected, $result);
  294. $result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false));
  295. $expected = array('time' => 'time');
  296. $this->assertEquals($expected, $result);
  297. $result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false));
  298. $expected = array('email' => 'email');
  299. $this->assertEquals($expected, $result);
  300. $result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false));
  301. $expected = array('numeric' => 'numeric');
  302. $this->assertEquals($expected, $result);
  303. $result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false));
  304. $expected = array('boolean' => 'boolean');
  305. $this->assertEquals($expected, $result);
  306. }
  307. /**
  308. * test that interactive field validation works and returns multiple validators.
  309. *
  310. * @return void
  311. */
  312. public function testInteractiveFieldValidation() {
  313. $this->markTestIncomplete('Not done here yet');
  314. $this->Task->initValidations();
  315. $this->Task->interactive = true;
  316. $this->Task->expects($this->any())->method('in')
  317. ->will($this->onConsecutiveCalls('24', 'y', '18', 'n'));
  318. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  319. $expected = array('notEmpty' => 'notEmpty', 'maxLength' => 'maxLength');
  320. $this->assertEquals($expected, $result);
  321. }
  322. /**
  323. * test that a bogus response doesn't cause errors to bubble up.
  324. *
  325. * @return void
  326. */
  327. public function testInteractiveFieldValidationWithBogusResponse() {
  328. $this->markTestIncomplete('Not done here yet');
  329. $this->_useMockedOut();
  330. $this->Task->initValidations();
  331. $this->Task->interactive = true;
  332. $this->Task->expects($this->any())->method('in')
  333. ->will($this->onConsecutiveCalls('999999', '24', 'n'));
  334. $this->Task->expects($this->at(10))->method('out')
  335. ->with($this->stringContains('make a valid'));
  336. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  337. $expected = array('notEmpty' => 'notEmpty');
  338. $this->assertEquals($expected, $result);
  339. }
  340. /**
  341. * test that a regular expression can be used for validation.
  342. *
  343. * @return void
  344. */
  345. public function testInteractiveFieldValidationWithRegexp() {
  346. $this->markTestIncomplete('Not done here yet');
  347. $this->Task->initValidations();
  348. $this->Task->interactive = true;
  349. $this->Task->expects($this->any())->method('in')
  350. ->will($this->onConsecutiveCalls('/^[a-z]{0,9}$/', 'n'));
  351. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  352. $expected = array('a_z_0_9' => '/^[a-z]{0,9}$/');
  353. $this->assertEquals($expected, $result);
  354. }
  355. /**
  356. * Test that skipping fields during rule choice works when doing interactive field validation.
  357. *
  358. * @return void
  359. */
  360. public function testSkippingChoiceInteractiveFieldValidation() {
  361. $this->markTestIncomplete('Not done here yet');
  362. $this->Task->initValidations();
  363. $this->Task->interactive = true;
  364. $this->Task->expects($this->any())->method('in')
  365. ->will($this->onConsecutiveCalls('24', 'y', 's'));
  366. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  367. $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
  368. $this->assertEquals($expected, $result);
  369. }
  370. /**
  371. * Test that skipping fields after rule choice works when doing interactive field validation.
  372. *
  373. * @return void
  374. */
  375. public function testSkippingAnotherInteractiveFieldValidation() {
  376. $this->markTestIncomplete('Not done here yet');
  377. $this->Task->initValidations();
  378. $this->Task->interactive = true;
  379. $this->Task->expects($this->any())->method('in')
  380. ->will($this->onConsecutiveCalls('24', 's'));
  381. $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
  382. $expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
  383. $this->assertEquals($expected, $result);
  384. }
  385. /**
  386. * Test the validation generation routine with skipping the rest of the fields
  387. * when doing interactive field validation.
  388. *
  389. * @return void
  390. */
  391. public function testInteractiveDoValidationWithSkipping() {
  392. $this->markTestIncomplete('Not done here yet');
  393. $this->Task->expects($this->any())
  394. ->method('in')
  395. ->will($this->onConsecutiveCalls('35', '24', 'n', '11', 's'));
  396. $this->Task->interactive = true;
  397. $Model = $this->getMock('Model');
  398. $Model->primaryKey = 'id';
  399. $Model->expects($this->any())
  400. ->method('schema')
  401. ->will($this->returnValue(array(
  402. 'id' => array(
  403. 'type' => 'integer',
  404. 'length' => 11,
  405. 'null' => false,
  406. 'key' => 'primary',
  407. ),
  408. 'name' => array(
  409. 'type' => 'string',
  410. 'length' => 20,
  411. 'null' => false,
  412. ),
  413. 'email' => array(
  414. 'type' => 'string',
  415. 'length' => 255,
  416. 'null' => false,
  417. ),
  418. 'some_date' => array(
  419. 'type' => 'date',
  420. 'length' => '',
  421. 'null' => false,
  422. ),
  423. 'some_time' => array(
  424. 'type' => 'time',
  425. 'length' => '',
  426. 'null' => false,
  427. ),
  428. 'created' => array(
  429. 'type' => 'datetime',
  430. 'length' => '',
  431. 'null' => false,
  432. )
  433. )
  434. ));
  435. $result = $this->Task->doValidation($Model);
  436. $expected = array(
  437. 'name' => array(
  438. 'notEmpty' => 'notEmpty'
  439. ),
  440. 'email' => array(
  441. 'email' => 'email',
  442. ),
  443. );
  444. $this->assertEquals($expected, $result);
  445. }
  446. /**
  447. * test the validation Generation routine
  448. *
  449. * @return void
  450. */
  451. public function testNonInteractiveDoValidation() {
  452. $this->markTestIncomplete('Not done here yet');
  453. $Model = $this->getMock('Model');
  454. $Model->primaryKey = 'id';
  455. $Model->expects($this->any())
  456. ->method('schema')
  457. ->will($this->returnValue(array(
  458. 'id' => array(
  459. 'type' => 'integer',
  460. 'length' => 11,
  461. 'null' => false,
  462. 'key' => 'primary',
  463. ),
  464. 'name' => array(
  465. 'type' => 'string',
  466. 'length' => 20,
  467. 'null' => false,
  468. ),
  469. 'email' => array(
  470. 'type' => 'string',
  471. 'length' => 255,
  472. 'null' => false,
  473. ),
  474. 'some_date' => array(
  475. 'type' => 'date',
  476. 'length' => '',
  477. 'null' => false,
  478. ),
  479. 'some_time' => array(
  480. 'type' => 'time',
  481. 'length' => '',
  482. 'null' => false,
  483. ),
  484. 'created' => array(
  485. 'type' => 'datetime',
  486. 'length' => '',
  487. 'null' => false,
  488. )
  489. )
  490. ));
  491. $this->Task->interactive = false;
  492. $result = $this->Task->doValidation($Model);
  493. $expected = array(
  494. 'name' => array(
  495. 'notEmpty' => 'notEmpty'
  496. ),
  497. 'email' => array(
  498. 'email' => 'email',
  499. ),
  500. 'some_date' => array(
  501. 'date' => 'date'
  502. ),
  503. 'some_time' => array(
  504. 'time' => 'time'
  505. ),
  506. );
  507. $this->assertEquals($expected, $result);
  508. }
  509. /**
  510. * test non interactive doAssociations
  511. *
  512. * @return void
  513. */
  514. public function testDoAssociationsNonInteractive() {
  515. $this->markTestIncomplete('Not done here yet');
  516. $this->Task->connection = 'test';
  517. $this->Task->interactive = false;
  518. $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
  519. $result = $this->Task->doAssociations($model);
  520. $expected = array(
  521. 'belongsTo' => array(
  522. array(
  523. 'alias' => 'BakeUser',
  524. 'className' => 'BakeUser',
  525. 'foreignKey' => 'bake_user_id',
  526. ),
  527. ),
  528. 'hasMany' => array(
  529. array(
  530. 'alias' => 'BakeComment',
  531. 'className' => 'BakeComment',
  532. 'foreignKey' => 'bake_article_id',
  533. ),
  534. ),
  535. 'hasAndBelongsToMany' => array(
  536. array(
  537. 'alias' => 'BakeTag',
  538. 'className' => 'BakeTag',
  539. 'foreignKey' => 'bake_article_id',
  540. 'joinTable' => 'bake_articles_bake_tags',
  541. 'associationForeignKey' => 'bake_tag_id',
  542. ),
  543. ),
  544. );
  545. $this->assertEquals($expected, $result);
  546. }
  547. /**
  548. * test non interactive doActsAs
  549. *
  550. * @return void
  551. */
  552. public function testDoActsAs() {
  553. $this->markTestIncomplete('Not done here yet');
  554. $this->Task->connection = 'test';
  555. $this->Task->interactive = false;
  556. $model = new Model(array('ds' => 'test', 'name' => 'NumberTree'));
  557. $result = $this->Task->doActsAs($model);
  558. $this->assertEquals(array('Tree'), $result);
  559. }
  560. /**
  561. * Ensure that the fixture object is correctly called.
  562. *
  563. * @return void
  564. */
  565. public function testBakeFixture() {
  566. $this->Task->plugin = 'TestPlugin';
  567. $this->Task->Fixture->expects($this->at(0))
  568. ->method('bake')
  569. ->with('BakeArticle', 'bake_articles');
  570. $this->Task->bakeFixture('BakeArticle', 'bake_articles');
  571. $this->assertEquals($this->Task->plugin, $this->Task->Fixture->plugin);
  572. $this->assertEquals($this->Task->connection, $this->Task->Fixture->connection);
  573. $this->assertEquals($this->Task->interactive, $this->Task->Fixture->interactive);
  574. }
  575. /**
  576. * Ensure that the fixture baking can be disabled
  577. *
  578. * @return void
  579. */
  580. public function testBakeFixtureDisabled() {
  581. $this->Task->params['no-fixture'] = true;
  582. $this->Task->plugin = 'TestPlugin';
  583. $this->Task->Fixture->expects($this->never())
  584. ->method('bake');
  585. $this->Task->bakeFixture('BakeArticle', 'bake_articles');
  586. }
  587. /**
  588. * Ensure that the test object is correctly called.
  589. *
  590. * @return void
  591. */
  592. public function testBakeTest() {
  593. $this->Task->plugin = 'TestPlugin';
  594. $this->Task->Test->expects($this->at(0))
  595. ->method('bake')
  596. ->with('Model', 'BakeArticle');
  597. $this->Task->bakeTest('BakeArticle');
  598. $this->assertEquals($this->Task->plugin, $this->Task->Test->plugin);
  599. $this->assertEquals($this->Task->connection, $this->Task->Test->connection);
  600. $this->assertEquals($this->Task->interactive, $this->Task->Test->interactive);
  601. }
  602. /**
  603. * Ensure that test baking can be disabled.
  604. *
  605. * @return void
  606. */
  607. public function testBakeTestDisabled() {
  608. $this->Task->params['no-test'] = true;
  609. $this->Task->plugin = 'TestPlugin';
  610. $this->Task->Test->expects($this->never())
  611. ->method('bake');
  612. $this->Task->bakeTest('BakeArticle');
  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. }