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