2009-02-13 14:22:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-19 21:10:13 +00:00
|
|
|
* TestTaskTest file
|
2009-02-13 14:22:11 +00:00
|
|
|
*
|
2009-03-19 21:10:13 +00:00
|
|
|
* Test Case for test generation shell task
|
2009-02-13 14:22:11 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* PHP 5
|
2009-02-13 14:22:11 +00:00
|
|
|
*
|
2010-01-26 22:15:15 +00:00
|
|
|
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
2012-03-13 02:46:07 +00:00
|
|
|
* Copyright 2005-2012, Cake Software Foundation, Inc.
|
2009-02-13 14:22:11 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2012-03-13 02:46:07 +00:00
|
|
|
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-02-13 14:22:11 +00:00
|
|
|
* @since CakePHP v 1.2.0.7726
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2009-02-13 14:22:11 +00:00
|
|
|
*/
|
2010-10-17 19:43:20 +00:00
|
|
|
|
2010-12-09 03:45:18 +00:00
|
|
|
App::uses('ShellDispatcher', 'Console');
|
2011-03-07 05:27:21 +00:00
|
|
|
App::uses('ConsoleOutput', 'Console');
|
|
|
|
App::uses('ConsoleInput', 'Console');
|
2010-12-09 03:45:18 +00:00
|
|
|
App::uses('Shell', 'Console');
|
|
|
|
App::uses('TestTask', 'Console/Command/Task');
|
|
|
|
App::uses('TemplateTask', 'Console/Command/Task');
|
|
|
|
App::uses('Controller', 'Controller');
|
|
|
|
App::uses('Model', 'Model');
|
2010-01-17 00:41:52 +00:00
|
|
|
|
2009-05-24 05:15:31 +00:00
|
|
|
/**
|
2009-11-14 12:18:31 +00:00
|
|
|
* Test Article model
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2009-05-24 05:15:31 +00:00
|
|
|
class TestTaskArticle extends Model {
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $name = 'TestTaskArticle';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table name to use
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $useTable = 'articles';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HasMany Associations
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $hasMany = array(
|
2009-05-24 05:15:31 +00:00
|
|
|
'Comment' => array(
|
|
|
|
'className' => 'TestTask.TestTaskComment',
|
|
|
|
'foreignKey' => 'article_id',
|
|
|
|
)
|
|
|
|
);
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Has and Belongs To Many Associations
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $hasAndBelongsToMany = array(
|
2009-05-24 05:15:31 +00:00
|
|
|
'Tag' => array(
|
|
|
|
'className' => 'TestTaskTag',
|
|
|
|
'joinTable' => 'articles_tags',
|
|
|
|
'foreignKey' => 'article_id',
|
|
|
|
'associationForeignKey' => 'tag_id'
|
|
|
|
)
|
|
|
|
);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
2009-11-14 12:18:31 +00:00
|
|
|
/**
|
|
|
|
* Example public method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function doSomething() {
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 12:18:31 +00:00
|
|
|
/**
|
|
|
|
* Example Secondary public method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function doSomethingElse() {
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-14 12:18:31 +00:00
|
|
|
/**
|
|
|
|
* Example protected method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-04-05 03:21:28 +00:00
|
|
|
protected function _innerMethod() {
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
2012-03-11 04:32:02 +00:00
|
|
|
|
2009-05-24 05:15:31 +00:00
|
|
|
}
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tag Testing Model
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2009-05-24 05:15:31 +00:00
|
|
|
class TestTaskTag extends Model {
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $name = 'TestTaskTag';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $useTable = 'tags';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Has and Belongs To Many Associations
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $hasAndBelongsToMany = array(
|
2009-05-24 05:15:31 +00:00
|
|
|
'Article' => array(
|
|
|
|
'className' => 'TestTaskArticle',
|
|
|
|
'joinTable' => 'articles_tags',
|
|
|
|
'foreignKey' => 'tag_id',
|
|
|
|
'associationForeignKey' => 'article_id'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-24 05:15:31 +00:00
|
|
|
/**
|
2009-11-14 12:18:31 +00:00
|
|
|
* Simulated plugin
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2009-05-24 05:15:31 +00:00
|
|
|
class TestTaskAppModel extends Model {
|
2009-05-24 03:48:25 +00:00
|
|
|
}
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Testing AppMode (TaskComment)
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2009-05-24 05:15:31 +00:00
|
|
|
class TestTaskComment extends TestTaskAppModel {
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Model name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $name = 'TestTaskComment';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Table name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $useTable = 'comments';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Belongs To Associations
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $belongsTo = array(
|
2009-05-24 05:15:31 +00:00
|
|
|
'Article' => array(
|
|
|
|
'className' => 'TestTaskArticle',
|
|
|
|
'foreignKey' => 'article_id',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-11-14 12:18:31 +00:00
|
|
|
/**
|
|
|
|
* Test Task Comments Controller
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2009-05-24 05:30:04 +00:00
|
|
|
class TestTaskCommentsController extends Controller {
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller Name
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $name = 'TestTaskComments';
|
2009-11-14 12:18:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Models to use
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $uses = array('TestTaskComment', 'TestTaskTag');
|
2009-05-24 05:30:04 +00:00
|
|
|
}
|
|
|
|
|
2009-03-13 16:06:18 +00:00
|
|
|
/**
|
|
|
|
* TestTaskTest class
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command.Task
|
2009-03-13 16:06:18 +00:00
|
|
|
*/
|
2009-02-13 14:22:11 +00:00
|
|
|
class TestTaskTest extends CakeTestCase {
|
2009-05-24 05:15:31 +00:00
|
|
|
|
2009-11-14 12:18:31 +00:00
|
|
|
/**
|
|
|
|
* Fixtures
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-03-13 16:06:18 +00:00
|
|
|
/**
|
2011-12-04 21:27:51 +00:00
|
|
|
* setUp method
|
2009-03-13 16:06:18 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-12-04 21:27:51 +00:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2010-10-07 02:52:42 +00:00
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
|
|
2011-04-17 10:35:21 +00:00
|
|
|
$this->Task = $this->getMock('TestTask',
|
2010-06-10 00:15:37 +00:00
|
|
|
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
|
2010-10-24 19:27:04 +00:00
|
|
|
array($out, $out, $in)
|
2010-06-10 00:15:37 +00:00
|
|
|
);
|
2010-10-19 03:09:23 +00:00
|
|
|
$this->Task->name = 'Test';
|
2010-10-24 19:27:04 +00:00
|
|
|
$this->Task->Template = new TemplateTask($out, $out, $in);
|
2009-03-13 16:06:18 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-03-13 16:06:18 +00:00
|
|
|
/**
|
2012-04-11 14:50:54 +00:00
|
|
|
* tearDown method
|
2009-03-13 16:06:18 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-10-07 02:52:42 +00:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2010-10-24 19:27:04 +00:00
|
|
|
unset($this->Task);
|
2011-05-12 04:22:09 +00:00
|
|
|
CakePlugin::unload();
|
2009-02-13 14:22:11 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-02-13 14:22:11 +00:00
|
|
|
/**
|
|
|
|
* Test that file path generation doesn't continuously append paths.
|
2009-03-13 16:06:18 +00:00
|
|
|
*
|
2009-02-13 14:22:11 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2010-06-10 00:15:37 +00:00
|
|
|
public function testFilePathGenerationModelRepeated() {
|
2010-10-24 19:27:04 +00:00
|
|
|
$this->Task->expects($this->never())->method('err');
|
|
|
|
$this->Task->expects($this->never())->method('_stop');
|
2009-02-13 14:22:11 +00:00
|
|
|
|
2011-04-11 01:19:16 +00:00
|
|
|
$file = TESTS . 'Case' . DS . 'Model' . DS . 'MyClassTest.php';
|
2009-03-13 16:06:18 +00:00
|
|
|
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(1))->method('createFile')
|
2011-10-03 01:46:35 +00:00
|
|
|
->with($file, $this->anything());
|
2009-03-13 16:06:18 +00:00
|
|
|
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(3))->method('createFile')
|
2011-10-03 01:46:35 +00:00
|
|
|
->with($file, $this->anything());
|
2009-05-26 03:57:15 +00:00
|
|
|
|
2011-04-11 01:19:16 +00:00
|
|
|
$file = TESTS . 'Case' . DS . 'Controller' . DS . 'CommentsControllerTest.php';
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(5))->method('createFile')
|
2011-10-03 01:46:35 +00:00
|
|
|
->with($file, $this->anything());
|
2010-06-10 00:15:37 +00:00
|
|
|
|
|
|
|
$this->Task->bake('Model', 'MyClass');
|
|
|
|
$this->Task->bake('Model', 'MyClass');
|
2009-05-26 03:57:15 +00:00
|
|
|
$this->Task->bake('Controller', 'Comments');
|
2009-02-13 14:22:11 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-24 03:48:25 +00:00
|
|
|
/**
|
2009-07-26 09:59:51 +00:00
|
|
|
* Test that method introspection pulls all relevant non parent class
|
2009-05-24 03:48:25 +00:00
|
|
|
* methods into the test case.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testMethodIntrospection() {
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getTestableMethods('TestTaskArticle');
|
2009-08-02 22:17:31 +00:00
|
|
|
$expected = array('dosomething', 'dosomethingelse');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, array_map('strtolower', $result));
|
2009-05-24 05:15:31 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-24 05:15:31 +00:00
|
|
|
/**
|
|
|
|
* test that the generation of fixtures works correctly.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testFixtureArrayGenerationFromModel() {
|
2009-05-24 05:15:31 +00:00
|
|
|
$subject = ClassRegistry::init('TestTaskArticle');
|
|
|
|
$result = $this->Task->generateFixtureList($subject);
|
2009-07-26 09:59:51 +00:00
|
|
|
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
|
2009-05-24 05:15:31 +00:00
|
|
|
'app.test_task_article', 'app.test_task_tag');
|
|
|
|
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals(sort($expected), sort($result));
|
2009-05-24 03:48:25 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-24 05:30:04 +00:00
|
|
|
/**
|
|
|
|
* test that the generation of fixtures works correctly.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testFixtureArrayGenerationFromController() {
|
2009-05-24 05:30:04 +00:00
|
|
|
$subject = new TestTaskCommentsController();
|
|
|
|
$result = $this->Task->generateFixtureList($subject);
|
2009-07-26 09:59:51 +00:00
|
|
|
$expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
|
2009-05-24 05:30:04 +00:00
|
|
|
'app.test_task_article', 'app.test_task_tag');
|
|
|
|
|
2012-03-23 06:37:12 +00:00
|
|
|
$this->assertEquals(sort($expected), sort($result));
|
2009-05-25 00:12:17 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-25 00:12:17 +00:00
|
|
|
/**
|
|
|
|
* test user interaction to get object type
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testGetObjectType() {
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->once())->method('_stop');
|
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('q'));
|
|
|
|
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue(2));
|
|
|
|
|
2009-05-25 00:12:17 +00:00
|
|
|
$this->Task->getObjectType();
|
|
|
|
|
|
|
|
$result = $this->Task->getObjectType();
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($this->Task->classTypes['Controller'], $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-26 04:36:25 +00:00
|
|
|
/**
|
|
|
|
* creating test subjects should clear the registry so the registry is always fresh
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testRegistryClearWhenBuildingTestObjects() {
|
2009-05-26 04:36:25 +00:00
|
|
|
ClassRegistry::flush();
|
|
|
|
$model = ClassRegistry::init('TestTaskComment');
|
|
|
|
$model->bindModel(array(
|
|
|
|
'belongsTo' => array(
|
|
|
|
'Random' => array(
|
|
|
|
'className' => 'TestTaskArticle',
|
|
|
|
'foreignKey' => 'article_id',
|
|
|
|
)
|
|
|
|
)
|
|
|
|
));
|
|
|
|
$keys = ClassRegistry::keys();
|
2010-09-08 03:51:39 +00:00
|
|
|
$this->assertTrue(in_array('test_task_comment', $keys));
|
2010-11-13 04:22:48 +00:00
|
|
|
$object = $this->Task->buildTestSubject('Model', 'TestTaskComment');
|
2009-05-26 04:36:25 +00:00
|
|
|
|
|
|
|
$keys = ClassRegistry::keys();
|
|
|
|
$this->assertFalse(in_array('random', $keys));
|
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
/**
|
|
|
|
* test that getClassName returns the user choice as a classname.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testGetClassName() {
|
2009-08-08 02:45:48 +00:00
|
|
|
$objects = App::objects('model');
|
2011-05-31 00:49:46 +00:00
|
|
|
$this->skipIf(empty($objects), 'No models in app.');
|
|
|
|
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('MyCustomClass'));
|
|
|
|
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(1));
|
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getClassName('Model');
|
2012-03-23 06:37:12 +00:00
|
|
|
$this->assertEquals('MyCustomClass', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
|
|
|
$result = $this->Task->getClassName('Model');
|
2009-08-08 02:45:48 +00:00
|
|
|
$options = App::objects('model');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($options[0], $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
/**
|
|
|
|
* Test the user interaction for defining additional fixtures.
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testGetUserFixtures() {
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
|
|
|
$this->Task->expects($this->at(1))->method('in')
|
|
|
|
->will($this->returnValue('app.pizza, app.topping, app.side_dish'));
|
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getUserFixtures();
|
|
|
|
$expected = array('app.pizza', 'app.topping', 'app.side_dish');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
/**
|
|
|
|
* test that resolving classnames works
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testGetRealClassname() {
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getRealClassname('Model', 'Post');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('Post', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
|
|
|
$result = $this->Task->getRealClassname('Controller', 'Posts');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('PostsController', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
2011-10-03 01:46:35 +00:00
|
|
|
$result = $this->Task->getRealClassname('Controller', 'PostsController');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('PostsController', $result);
|
2012-03-11 04:32:02 +00:00
|
|
|
|
2012-02-28 14:58:28 +00:00
|
|
|
$result = $this->Task->getRealClassname('Controller', 'AlertTypes');
|
|
|
|
$this->assertEquals('AlertTypesController', $result);
|
2011-10-03 01:46:35 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getRealClassname('Helper', 'Form');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('FormHelper', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
2011-10-03 01:46:35 +00:00
|
|
|
$result = $this->Task->getRealClassname('Helper', 'FormHelper');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('FormHelper', $result);
|
2011-10-03 01:46:35 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getRealClassname('Behavior', 'Containable');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('ContainableBehavior', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
2011-10-03 01:46:35 +00:00
|
|
|
$result = $this->Task->getRealClassname('Behavior', 'ContainableBehavior');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('ContainableBehavior', $result);
|
2011-10-03 01:46:35 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
$result = $this->Task->getRealClassname('Component', 'Auth');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals('AuthComponent', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-25 03:50:21 +00:00
|
|
|
/**
|
2009-08-02 22:17:31 +00:00
|
|
|
* test baking files. The conditionally run tests are known to fail in PHP4
|
|
|
|
* as PHP4 classnames are all lower case, breaking the plugin path inflection.
|
2009-05-25 03:50:21 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testBakeModelTest() {
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
|
|
|
|
$this->Task->expects($this->once())->method('isLoadableClass')->will($this->returnValue(true));
|
2009-05-25 03:50:21 +00:00
|
|
|
|
|
|
|
$result = $this->Task->bake('Model', 'TestTaskArticle');
|
|
|
|
|
2011-03-16 02:59:18 +00:00
|
|
|
$this->assertContains("App::uses('TestTaskArticle', 'Model')", $result);
|
2012-04-21 13:02:35 +00:00
|
|
|
$this->assertContains('class TestTaskArticleTest extends CakeTestCase', $result);
|
2009-05-25 04:54:23 +00:00
|
|
|
|
2011-02-05 06:40:14 +00:00
|
|
|
$this->assertContains('function setUp()', $result);
|
2010-11-13 04:22:48 +00:00
|
|
|
$this->assertContains("\$this->TestTaskArticle = ClassRegistry::init('TestTaskArticle')", $result);
|
2009-05-25 04:54:23 +00:00
|
|
|
|
2011-02-05 06:40:14 +00:00
|
|
|
$this->assertContains('function tearDown()', $result);
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains('unset($this->TestTaskArticle)', $result);
|
2009-05-25 04:54:23 +00:00
|
|
|
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains('function testDoSomething()', $result);
|
|
|
|
$this->assertContains('function testDoSomethingElse()', $result);
|
2009-05-25 03:50:21 +00:00
|
|
|
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains("'app.test_task_article'", $result);
|
2012-06-14 11:38:17 +00:00
|
|
|
$this->assertContains("'app.test_task_comment'", $result);
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains("'app.test_task_tag'", $result);
|
|
|
|
$this->assertContains("'app.articles_tag'", $result);
|
2009-05-24 05:30:04 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-26 03:48:41 +00:00
|
|
|
/**
|
2012-05-11 18:28:01 +00:00
|
|
|
* test baking controller test files
|
2009-05-26 03:48:41 +00:00
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testBakeControllerTest() {
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
|
|
|
|
$this->Task->expects($this->once())->method('isLoadableClass')->will($this->returnValue(true));
|
2009-05-26 03:48:41 +00:00
|
|
|
|
|
|
|
$result = $this->Task->bake('Controller', 'TestTaskComments');
|
|
|
|
|
2011-03-16 02:59:18 +00:00
|
|
|
$this->assertContains("App::uses('TestTaskCommentsController', 'Controller')", $result);
|
2012-05-11 18:28:01 +00:00
|
|
|
$this->assertContains('class TestTaskCommentsControllerTest extends ControllerTestCase', $result);
|
2009-05-26 03:48:41 +00:00
|
|
|
|
2012-06-06 21:04:18 +00:00
|
|
|
$this->assertNotContains('function setUp()', $result);
|
|
|
|
$this->assertNotContains("\$this->TestTaskComments = new TestTaskCommentsController()", $result);
|
|
|
|
$this->assertNotContains("\$this->TestTaskComments->constructClasses()", $result);
|
2009-05-26 03:48:41 +00:00
|
|
|
|
2012-06-06 21:04:18 +00:00
|
|
|
$this->assertNotContains('function tearDown()', $result);
|
|
|
|
$this->assertNotContains('unset($this->TestTaskComments)', $result);
|
2009-05-26 03:48:41 +00:00
|
|
|
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains("'app.test_task_article'", $result);
|
2012-06-14 11:38:17 +00:00
|
|
|
$this->assertContains("'app.test_task_comment'", $result);
|
2010-09-25 04:56:46 +00:00
|
|
|
$this->assertContains("'app.test_task_tag'", $result);
|
|
|
|
$this->assertContains("'app.articles_tag'", $result);
|
2009-05-26 03:48:41 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2012-04-29 14:44:58 +00:00
|
|
|
/**
|
|
|
|
* test baking component test files,
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testBakeComponentTest() {
|
|
|
|
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$result = $this->Task->bake('Component', 'Example');
|
|
|
|
|
2012-07-24 01:25:55 +00:00
|
|
|
$this->assertContains("App::uses('Component', 'Controller')", $result);
|
|
|
|
$this->assertContains("App::uses('ComponentCollection', 'Controller')", $result);
|
2012-04-29 14:44:58 +00:00
|
|
|
$this->assertContains("App::uses('ExampleComponent', 'Controller/Component')", $result);
|
|
|
|
$this->assertContains('class ExampleComponentTest extends CakeTestCase', $result);
|
|
|
|
|
|
|
|
$this->assertContains('function setUp()', $result);
|
|
|
|
$this->assertContains("\$Collection = new ComponentCollection()", $result);
|
|
|
|
$this->assertContains("\$this->Example = new ExampleComponent(\$Collection)", $result);
|
|
|
|
|
|
|
|
$this->assertContains('function tearDown()', $result);
|
|
|
|
$this->assertContains('unset($this->Example)', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test baking behavior test files,
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testBakeBehaviorTest() {
|
|
|
|
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$result = $this->Task->bake('Behavior', 'Example');
|
|
|
|
|
|
|
|
$this->assertContains("App::uses('ExampleBehavior', 'Model/Behavior')", $result);
|
|
|
|
$this->assertContains('class ExampleBehaviorTest extends CakeTestCase', $result);
|
|
|
|
|
|
|
|
$this->assertContains('function setUp()', $result);
|
|
|
|
$this->assertContains("\$this->Example = new ExampleBehavior()", $result);
|
|
|
|
|
|
|
|
$this->assertContains('function tearDown()', $result);
|
|
|
|
$this->assertContains('unset($this->Example)', $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test baking helper test files,
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testBakeHelperTest() {
|
|
|
|
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
|
|
|
|
|
|
|
|
$result = $this->Task->bake('Helper', 'Example');
|
|
|
|
|
|
|
|
$this->assertContains("App::uses('ExampleHelper', 'View/Helper')", $result);
|
|
|
|
$this->assertContains('class ExampleHelperTest extends CakeTestCase', $result);
|
|
|
|
|
|
|
|
$this->assertContains('function setUp()', $result);
|
|
|
|
$this->assertContains("\$View = new View()", $result);
|
|
|
|
$this->assertContains("\$this->Example = new ExampleHelper(\$View)", $result);
|
|
|
|
|
|
|
|
$this->assertContains('function tearDown()', $result);
|
|
|
|
$this->assertContains('unset($this->Example)', $result);
|
|
|
|
}
|
|
|
|
|
2009-05-25 04:54:23 +00:00
|
|
|
/**
|
|
|
|
* test Constructor generation ensure that constructClasses is called for controllers
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testGenerateConstructor() {
|
2012-05-10 22:33:10 +00:00
|
|
|
$result = $this->Task->generateConstructor('controller', 'PostsController', null);
|
2012-06-06 21:04:18 +00:00
|
|
|
$expected = array('', '', '');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2009-05-25 05:02:59 +00:00
|
|
|
|
2012-05-10 22:33:10 +00:00
|
|
|
$result = $this->Task->generateConstructor('model', 'Post', null);
|
2012-01-27 03:44:01 +00:00
|
|
|
$expected = array('', "ClassRegistry::init('Post');\n", '');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2009-05-25 05:02:59 +00:00
|
|
|
|
2012-05-10 22:33:10 +00:00
|
|
|
$result = $this->Task->generateConstructor('helper', 'FormHelper', null);
|
2012-01-27 03:44:01 +00:00
|
|
|
$expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", '');
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2009-05-25 04:54:23 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2012-01-27 03:50:25 +00:00
|
|
|
/**
|
|
|
|
* Test generateUses()
|
|
|
|
*/
|
|
|
|
public function testGenerateUses() {
|
|
|
|
$result = $this->Task->generateUses('model', 'Model', 'Post');
|
|
|
|
$expected = array(
|
|
|
|
array('Post', 'Model')
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
|
|
$result = $this->Task->generateUses('controller', 'Controller', 'PostsController');
|
|
|
|
$expected = array(
|
|
|
|
array('PostsController', 'Controller')
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
|
|
$result = $this->Task->generateUses('helper', 'View/Helper', 'FormHelper');
|
|
|
|
$expected = array(
|
|
|
|
array('View', 'View'),
|
|
|
|
array('Helper', 'View'),
|
|
|
|
array('FormHelper', 'View/Helper'),
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
|
|
$result = $this->Task->generateUses('component', 'Controller/Component', 'AuthComponent');
|
|
|
|
$expected = array(
|
|
|
|
array('ComponentCollection', 'Controller'),
|
|
|
|
array('Component', 'Controller'),
|
|
|
|
array('AuthComponent', 'Controller/Component')
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
|
2009-05-26 03:48:41 +00:00
|
|
|
/**
|
|
|
|
* Test that mock class generation works for the appropriate classes
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testMockClassGeneration() {
|
2009-05-26 03:48:41 +00:00
|
|
|
$result = $this->Task->hasMockClass('controller');
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-06-07 01:03:26 +00:00
|
|
|
/**
|
|
|
|
* test bake() with a -plugin param
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testBakeWithPlugin() {
|
2009-06-07 01:03:26 +00:00
|
|
|
$this->Task->plugin = 'TestTest';
|
|
|
|
|
2011-05-12 04:22:09 +00:00
|
|
|
//fake plugin path
|
2012-03-11 04:32:02 +00:00
|
|
|
CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS));
|
|
|
|
$path = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php';
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->once())->method('createFile')
|
2011-10-03 01:46:35 +00:00
|
|
|
->with($path, $this->anything());
|
2010-06-10 00:15:37 +00:00
|
|
|
|
2009-06-07 01:03:26 +00:00
|
|
|
$this->Task->bake('Helper', 'Form');
|
2011-05-12 04:22:09 +00:00
|
|
|
CakePlugin::unload();
|
2009-06-07 01:03:26 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2010-12-14 03:00:37 +00:00
|
|
|
/**
|
|
|
|
* test interactive with plugins lists from the plugin
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testInteractiveWithPlugin() {
|
2011-04-17 10:35:21 +00:00
|
|
|
$testApp = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS;
|
2010-12-14 03:00:37 +00:00
|
|
|
App::build(array(
|
2012-02-18 12:31:29 +00:00
|
|
|
'Plugin' => array($testApp)
|
2012-02-18 12:04:54 +00:00
|
|
|
), App::RESET);
|
2011-05-12 04:22:09 +00:00
|
|
|
CakePlugin::load('TestPlugin');
|
2010-12-14 03:00:37 +00:00
|
|
|
|
|
|
|
$this->Task->plugin = 'TestPlugin';
|
2011-10-03 16:24:40 +00:00
|
|
|
$path = $testApp . 'TestPlugin' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'OtherHelperTest.php';
|
2011-01-09 04:49:19 +00:00
|
|
|
$this->Task->expects($this->any())
|
|
|
|
->method('in')
|
|
|
|
->will($this->onConsecutiveCalls(
|
|
|
|
5, //helper
|
|
|
|
1 //OtherHelper
|
2011-04-17 10:35:21 +00:00
|
|
|
));
|
|
|
|
|
2011-01-09 04:49:19 +00:00
|
|
|
$this->Task->expects($this->once())
|
|
|
|
->method('createFile')
|
|
|
|
->with($path, $this->anything());
|
|
|
|
|
|
|
|
$this->Task->stdout->expects($this->at(21))
|
|
|
|
->method('write')
|
2011-03-07 05:27:21 +00:00
|
|
|
->with('1. OtherHelperHelper');
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2010-12-14 03:00:37 +00:00
|
|
|
$this->Task->execute();
|
|
|
|
}
|
|
|
|
|
2011-10-23 15:11:07 +00:00
|
|
|
public static function caseFileNameProvider() {
|
|
|
|
return array(
|
|
|
|
array('Model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'),
|
|
|
|
array('Helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'),
|
|
|
|
array('Controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'),
|
|
|
|
array('Behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'),
|
|
|
|
array('Component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'),
|
|
|
|
array('model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'),
|
|
|
|
array('helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'),
|
|
|
|
array('controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'),
|
|
|
|
array('behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'),
|
|
|
|
array('component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-06-07 01:09:56 +00:00
|
|
|
/**
|
|
|
|
* Test filename generation for each type + plugins
|
|
|
|
*
|
2011-10-23 15:11:07 +00:00
|
|
|
* @dataProvider caseFileNameProvider
|
2009-06-07 01:09:56 +00:00
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2011-10-23 15:11:07 +00:00
|
|
|
public function testTestCaseFileName($type, $class, $expected) {
|
2011-06-21 15:54:59 +00:00
|
|
|
$this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS;
|
2009-06-07 01:09:56 +00:00
|
|
|
|
2011-10-23 15:11:07 +00:00
|
|
|
$result = $this->Task->testCaseFileName($type, $class);
|
|
|
|
$expected = $this->Task->path . $expected;
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2011-10-23 15:11:07 +00:00
|
|
|
}
|
2009-06-07 01:09:56 +00:00
|
|
|
|
2011-10-23 15:11:07 +00:00
|
|
|
/**
|
|
|
|
* Test filename generation for plugins.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTestCaseFileNamePlugin() {
|
|
|
|
$this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS;
|
2009-06-07 01:09:56 +00:00
|
|
|
|
2012-09-28 11:49:51 +00:00
|
|
|
CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS));
|
2009-06-07 01:09:56 +00:00
|
|
|
$this->Task->plugin = 'TestTest';
|
|
|
|
$result = $this->Task->testCaseFileName('Model', 'Post');
|
2012-03-11 04:32:02 +00:00
|
|
|
$expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php';
|
2011-10-23 14:44:19 +00:00
|
|
|
$this->assertEquals($expected, $result);
|
2009-06-07 01:09:56 +00:00
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-30 04:14:57 +00:00
|
|
|
/**
|
|
|
|
* test execute with a type defined
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testExecuteWithOneArg() {
|
2009-05-30 04:14:57 +00:00
|
|
|
$this->Task->args[0] = 'Model';
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestTaskTag'));
|
|
|
|
$this->Task->expects($this->once())->method('isLoadableClass')->will($this->returnValue(true));
|
|
|
|
$this->Task->expects($this->once())->method('createFile')
|
|
|
|
->with(
|
2011-10-03 01:46:35 +00:00
|
|
|
$this->anything(),
|
2012-04-21 13:02:35 +00:00
|
|
|
$this->stringContains('class TestTaskTagTest extends CakeTestCase')
|
2010-06-10 00:15:37 +00:00
|
|
|
);
|
2009-05-30 04:14:57 +00:00
|
|
|
$this->Task->execute();
|
|
|
|
}
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-05-30 04:14:57 +00:00
|
|
|
/**
|
|
|
|
* test execute with type and class name defined
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:18:31 +00:00
|
|
|
*/
|
2010-09-25 04:56:46 +00:00
|
|
|
public function testExecuteWithTwoArgs() {
|
2009-05-30 04:14:57 +00:00
|
|
|
$this->Task->args = array('Model', 'TestTaskTag');
|
2010-06-10 00:15:37 +00:00
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestTaskTag'));
|
|
|
|
$this->Task->expects($this->once())->method('createFile')
|
|
|
|
->with(
|
2011-10-03 01:46:35 +00:00
|
|
|
$this->anything(),
|
2012-04-21 13:02:35 +00:00
|
|
|
$this->stringContains('class TestTaskTagTest extends CakeTestCase')
|
2011-10-23 15:11:07 +00:00
|
|
|
);
|
|
|
|
$this->Task->expects($this->any())->method('isLoadableClass')->will($this->returnValue(true));
|
|
|
|
$this->Task->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test execute with type and class name defined and lower case.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testExecuteWithTwoArgsLowerCase() {
|
|
|
|
$this->Task->args = array('model', 'TestTaskTag');
|
|
|
|
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestTaskTag'));
|
|
|
|
$this->Task->expects($this->once())->method('createFile')
|
|
|
|
->with(
|
|
|
|
$this->anything(),
|
2012-04-21 13:02:35 +00:00
|
|
|
$this->stringContains('class TestTaskTagTest extends CakeTestCase')
|
2010-06-10 00:15:37 +00:00
|
|
|
);
|
|
|
|
$this->Task->expects($this->any())->method('isLoadableClass')->will($this->returnValue(true));
|
2009-05-30 04:14:57 +00:00
|
|
|
$this->Task->execute();
|
|
|
|
}
|
2011-10-03 01:46:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Data provider for mapType() tests.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function mapTypeProvider() {
|
|
|
|
return array(
|
|
|
|
array('controller', null, 'Controller'),
|
|
|
|
array('Controller', null, 'Controller'),
|
|
|
|
array('component', null, 'Controller/Component'),
|
|
|
|
array('Component', null, 'Controller/Component'),
|
|
|
|
array('model', null, 'Model'),
|
|
|
|
array('Model', null, 'Model'),
|
|
|
|
array('behavior', null, 'Model/Behavior'),
|
|
|
|
array('Behavior', null, 'Model/Behavior'),
|
|
|
|
array('helper', null, 'View/Helper'),
|
|
|
|
array('Helper', null, 'View/Helper'),
|
|
|
|
array('Helper', 'DebugKit', 'DebugKit.View/Helper'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that mapType returns the correct package names.
|
|
|
|
*
|
|
|
|
* @dataProvider mapTypeProvider
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testMapType($original, $plugin, $expected) {
|
|
|
|
$this->assertEquals($expected, $this->Task->mapType($original, $plugin));
|
|
|
|
}
|
2009-02-13 14:22:11 +00:00
|
|
|
}
|