123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785 |
- <?php
- /**
- * TestTaskTest file
- *
- * Test Case for test generation shell task
- *
- * PHP 5
- *
- * CakePHP : Rapid Development Framework (http://cakephp.org)
- * Copyright 2005-2012, Cake Software Foundation, Inc.
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
- * @link http://cakephp.org CakePHP Project
- * @package Cake.Test.Case.Console.Command.Task
- * @since CakePHP v 1.2.0.7726
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- App::uses('ShellDispatcher', 'Console');
- App::uses('ConsoleOutput', 'Console');
- App::uses('ConsoleInput', 'Console');
- App::uses('Shell', 'Console');
- App::uses('TestTask', 'Console/Command/Task');
- App::uses('TemplateTask', 'Console/Command/Task');
- App::uses('Controller', 'Controller');
- App::uses('Model', 'Model');
- /**
- * Test Article model
- *
- * @package Cake.Test.Case.Console.Command.Task
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskArticle extends Model {
- /**
- * Model name
- *
- * @var string
- */
- public $name = 'TestTaskArticle';
- /**
- * Table name to use
- *
- * @var string
- */
- public $useTable = 'articles';
- /**
- * HasMany Associations
- *
- * @var array
- */
- public $hasMany = array(
- 'Comment' => array(
- 'className' => 'TestTask.TestTaskComment',
- 'foreignKey' => 'article_id',
- )
- );
- /**
- * Has and Belongs To Many Associations
- *
- * @var array
- */
- public $hasAndBelongsToMany = array(
- 'Tag' => array(
- 'className' => 'TestTaskTag',
- 'joinTable' => 'articles_tags',
- 'foreignKey' => 'article_id',
- 'associationForeignKey' => 'tag_id'
- )
- );
- /**
- * Example public method
- *
- * @return void
- */
- public function doSomething() {
- }
- /**
- * Example Secondary public method
- *
- * @return void
- */
- public function doSomethingElse() {
- }
- /**
- * Example protected method
- *
- * @return void
- */
- protected function _innerMethod() {
- }
- }
- /**
- * Tag Testing Model
- *
- * @package Cake.Test.Case.Console.Command.Task
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskTag extends Model {
- /**
- * Model name
- *
- * @var string
- */
- public $name = 'TestTaskTag';
- /**
- * Table name
- *
- * @var string
- */
- public $useTable = 'tags';
- /**
- * Has and Belongs To Many Associations
- *
- * @var array
- */
- public $hasAndBelongsToMany = array(
- 'Article' => array(
- 'className' => 'TestTaskArticle',
- 'joinTable' => 'articles_tags',
- 'foreignKey' => 'tag_id',
- 'associationForeignKey' => 'article_id'
- )
- );
- }
- /**
- * Simulated plugin
- *
- * @package Cake.Test.Case.Console.Command.Task
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskAppModel extends Model {
- }
- /**
- * Testing AppMode (TaskComment)
- *
- * @package Cake.Test.Case.Console.Command.Task
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskComment extends TestTaskAppModel {
- /**
- * Model name
- *
- * @var string
- */
- public $name = 'TestTaskComment';
- /**
- * Table name
- *
- * @var string
- */
- public $useTable = 'comments';
- /**
- * Belongs To Associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'Article' => array(
- 'className' => 'TestTaskArticle',
- 'foreignKey' => 'article_id',
- )
- );
- }
- /**
- * Test Task Comments Controller
- *
- * @package Cake.Test.Case.Console.Command.Task
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskCommentsController extends Controller {
- /**
- * Controller Name
- *
- * @var string
- */
- public $name = 'TestTaskComments';
- /**
- * Models to use
- *
- * @var array
- */
- public $uses = array('TestTaskComment', 'TestTaskTag');
- }
- /**
- * TestTaskTest class
- *
- * @package Cake.Test.Case.Console.Command.Task
- */
- class TestTaskTest extends CakeTestCase {
- /**
- * Fixtures
- *
- * @var string
- */
- public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
- /**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
- $in = $this->getMock('ConsoleInput', array(), array(), '', false);
- $this->Task = $this->getMock('TestTask',
- array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
- array($out, $out, $in)
- );
- $this->Task->name = 'Test';
- $this->Task->Template = new TemplateTask($out, $out, $in);
- }
- /**
- * tearDown method
- *
- * @return void
- */
- public function tearDown() {
- parent::tearDown();
- unset($this->Task);
- CakePlugin::unload();
- }
- /**
- * Test that file path generation doesn't continuously append paths.
- *
- * @return void
- */
- public function testFilePathGenerationModelRepeated() {
- $this->Task->expects($this->never())->method('err');
- $this->Task->expects($this->never())->method('_stop');
- $file = TESTS . 'Case' . DS . 'Model' . DS . 'MyClassTest.php';
- $this->Task->expects($this->at(1))->method('createFile')
- ->with($file, $this->anything());
- $this->Task->expects($this->at(3))->method('createFile')
- ->with($file, $this->anything());
- $file = TESTS . 'Case' . DS . 'Controller' . DS . 'CommentsControllerTest.php';
- $this->Task->expects($this->at(5))->method('createFile')
- ->with($file, $this->anything());
- $this->Task->bake('Model', 'MyClass');
- $this->Task->bake('Model', 'MyClass');
- $this->Task->bake('Controller', 'Comments');
- }
- /**
- * Test that method introspection pulls all relevant non parent class
- * methods into the test case.
- *
- * @return void
- */
- public function testMethodIntrospection() {
- $result = $this->Task->getTestableMethods('TestTaskArticle');
- $expected = array('dosomething', 'dosomethingelse');
- $this->assertEquals($expected, array_map('strtolower', $result));
- }
- /**
- * test that the generation of fixtures works correctly.
- *
- * @return void
- */
- public function testFixtureArrayGenerationFromModel() {
- $subject = ClassRegistry::init('TestTaskArticle');
- $result = $this->Task->generateFixtureList($subject);
- $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
- 'app.test_task_article', 'app.test_task_tag');
- $this->assertEquals(sort($expected), sort($result));
- }
- /**
- * test that the generation of fixtures works correctly.
- *
- * @return void
- */
- public function testFixtureArrayGenerationFromController() {
- $subject = new TestTaskCommentsController();
- $result = $this->Task->generateFixtureList($subject);
- $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags',
- 'app.test_task_article', 'app.test_task_tag');
- $this->assertEquals(sort($expected), sort($result));
- }
- /**
- * test user interaction to get object type
- *
- * @return void
- */
- public function testGetObjectType() {
- $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));
- $this->Task->getObjectType();
- $result = $this->Task->getObjectType();
- $this->assertEquals($this->Task->classTypes['Controller'], $result);
- }
- /**
- * creating test subjects should clear the registry so the registry is always fresh
- *
- * @return void
- */
- public function testRegistryClearWhenBuildingTestObjects() {
- ClassRegistry::flush();
- $model = ClassRegistry::init('TestTaskComment');
- $model->bindModel(array(
- 'belongsTo' => array(
- 'Random' => array(
- 'className' => 'TestTaskArticle',
- 'foreignKey' => 'article_id',
- )
- )
- ));
- $keys = ClassRegistry::keys();
- $this->assertTrue(in_array('test_task_comment', $keys));
- $this->Task->buildTestSubject('Model', 'TestTaskComment');
- $keys = ClassRegistry::keys();
- $this->assertFalse(in_array('random', $keys));
- }
- /**
- * test that getClassName returns the user choice as a classname.
- *
- * @return void
- */
- public function testGetClassName() {
- $objects = App::objects('model');
- $this->skipIf(empty($objects), 'No models in app.');
- $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('MyCustomClass'));
- $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(1));
- $result = $this->Task->getClassName('Model');
- $this->assertEquals('MyCustomClass', $result);
- $result = $this->Task->getClassName('Model');
- $options = App::objects('model');
- $this->assertEquals($options[0], $result);
- }
- /**
- * Test the user interaction for defining additional fixtures.
- *
- * @return void
- */
- public function testGetUserFixtures() {
- $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'));
- $result = $this->Task->getUserFixtures();
- $expected = array('app.pizza', 'app.topping', 'app.side_dish');
- $this->assertEquals($expected, $result);
- }
- /**
- * test that resolving classnames works
- *
- * @return void
- */
- public function testGetRealClassname() {
- $result = $this->Task->getRealClassname('Model', 'Post');
- $this->assertEquals('Post', $result);
- $result = $this->Task->getRealClassname('Controller', 'Posts');
- $this->assertEquals('PostsController', $result);
- $result = $this->Task->getRealClassname('Controller', 'PostsController');
- $this->assertEquals('PostsController', $result);
- $result = $this->Task->getRealClassname('Controller', 'AlertTypes');
- $this->assertEquals('AlertTypesController', $result);
- $result = $this->Task->getRealClassname('Helper', 'Form');
- $this->assertEquals('FormHelper', $result);
- $result = $this->Task->getRealClassname('Helper', 'FormHelper');
- $this->assertEquals('FormHelper', $result);
- $result = $this->Task->getRealClassname('Behavior', 'Containable');
- $this->assertEquals('ContainableBehavior', $result);
- $result = $this->Task->getRealClassname('Behavior', 'ContainableBehavior');
- $this->assertEquals('ContainableBehavior', $result);
- $result = $this->Task->getRealClassname('Component', 'Auth');
- $this->assertEquals('AuthComponent', $result);
- }
- /**
- * 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.
- *
- * @return void
- */
- public function testBakeModelTest() {
- $this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
- $this->Task->expects($this->once())->method('isLoadableClass')->will($this->returnValue(true));
- $result = $this->Task->bake('Model', 'TestTaskArticle');
- $this->assertContains("App::uses('TestTaskArticle', 'Model')", $result);
- $this->assertContains('class TestTaskArticleTest extends CakeTestCase', $result);
- $this->assertContains('function setUp()', $result);
- $this->assertContains("\$this->TestTaskArticle = ClassRegistry::init('TestTaskArticle')", $result);
- $this->assertContains('function tearDown()', $result);
- $this->assertContains('unset($this->TestTaskArticle)', $result);
- $this->assertContains('function testDoSomething()', $result);
- $this->assertContains('function testDoSomethingElse()', $result);
- $this->assertContains("'app.test_task_article'", $result);
- $this->assertContains("'app.test_task_comment'", $result);
- $this->assertContains("'app.test_task_tag'", $result);
- $this->assertContains("'app.articles_tag'", $result);
- }
- /**
- * test baking controller test files
- *
- * @return void
- */
- public function testBakeControllerTest() {
- $this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
- $this->Task->expects($this->once())->method('isLoadableClass')->will($this->returnValue(true));
- $result = $this->Task->bake('Controller', 'TestTaskComments');
- $this->assertContains("App::uses('TestTaskCommentsController', 'Controller')", $result);
- $this->assertContains('class TestTaskCommentsControllerTest extends ControllerTestCase', $result);
- $this->assertNotContains('function setUp()', $result);
- $this->assertNotContains("\$this->TestTaskComments = new TestTaskCommentsController()", $result);
- $this->assertNotContains("\$this->TestTaskComments->constructClasses()", $result);
- $this->assertNotContains('function tearDown()', $result);
- $this->assertNotContains('unset($this->TestTaskComments)', $result);
- $this->assertContains("'app.test_task_article'", $result);
- $this->assertContains("'app.test_task_comment'", $result);
- $this->assertContains("'app.test_task_tag'", $result);
- $this->assertContains("'app.articles_tag'", $result);
- }
- /**
- * 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');
- $this->assertContains("App::uses('Component', 'Controller')", $result);
- $this->assertContains("App::uses('ComponentCollection', 'Controller')", $result);
- $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);
- }
- /**
- * test Constructor generation ensure that constructClasses is called for controllers
- *
- * @return void
- */
- public function testGenerateConstructor() {
- $result = $this->Task->generateConstructor('controller', 'PostsController', null);
- $expected = array('', '', '');
- $this->assertEquals($expected, $result);
- $result = $this->Task->generateConstructor('model', 'Post', null);
- $expected = array('', "ClassRegistry::init('Post');\n", '');
- $this->assertEquals($expected, $result);
- $result = $this->Task->generateConstructor('helper', 'FormHelper', null);
- $expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", '');
- $this->assertEquals($expected, $result);
- }
- /**
- * 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);
- }
- /**
- * Test that mock class generation works for the appropriate classes
- *
- * @return void
- */
- public function testMockClassGeneration() {
- $result = $this->Task->hasMockClass('controller');
- $this->assertTrue($result);
- }
- /**
- * test bake() with a -plugin param
- *
- * @return void
- */
- public function testBakeWithPlugin() {
- $this->Task->plugin = 'TestTest';
- //fake plugin path
- 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';
- $this->Task->expects($this->once())->method('createFile')
- ->with($path, $this->anything());
- $this->Task->bake('Helper', 'Form');
- CakePlugin::unload();
- }
- /**
- * test interactive with plugins lists from the plugin
- *
- * @return void
- */
- public function testInteractiveWithPlugin() {
- $testApp = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS;
- App::build(array(
- 'Plugin' => array($testApp)
- ), App::RESET);
- CakePlugin::load('TestPlugin');
- $this->Task->plugin = 'TestPlugin';
- $path = $testApp . 'TestPlugin' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'OtherHelperTest.php';
- $this->Task->expects($this->any())
- ->method('in')
- ->will($this->onConsecutiveCalls(
- 5, //helper
- 1 //OtherHelper
- ));
- $this->Task->expects($this->once())
- ->method('createFile')
- ->with($path, $this->anything());
- $this->Task->stdout->expects($this->at(21))
- ->method('write')
- ->with('1. OtherHelperHelper');
- $this->Task->execute();
- }
- 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'),
- );
- }
- /**
- * Test filename generation for each type + plugins
- *
- * @dataProvider caseFileNameProvider
- * @return void
- */
- public function testTestCaseFileName($type, $class, $expected) {
- $this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS;
- $result = $this->Task->testCaseFileName($type, $class);
- $expected = $this->Task->path . $expected;
- $this->assertEquals($expected, $result);
- }
- /**
- * Test filename generation for plugins.
- *
- * @return void
- */
- public function testTestCaseFileNamePlugin() {
- $this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS;
- CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS));
- $this->Task->plugin = 'TestTest';
- $result = $this->Task->testCaseFileName('Model', 'Post');
- $expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php';
- $this->assertEquals($expected, $result);
- }
- /**
- * test execute with a type defined
- *
- * @return void
- */
- public function testExecuteWithOneArg() {
- $this->Task->args[0] = 'Model';
- $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(
- $this->anything(),
- $this->stringContains('class TestTaskTagTest extends CakeTestCase')
- );
- $this->Task->execute();
- }
- /**
- * test execute with type and class name defined
- *
- * @return void
- */
- public function testExecuteWithTwoArgs() {
- $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(),
- $this->stringContains('class TestTaskTagTest extends CakeTestCase')
- );
- $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(),
- $this->stringContains('class TestTaskTagTest extends CakeTestCase')
- );
- $this->Task->expects($this->any())->method('isLoadableClass')->will($this->returnValue(true));
- $this->Task->execute();
- }
- /**
- * 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));
- }
- }
|