Beispiel #1
0
 /**
  * Test main within a plugin.
  *
  * @return void
  */
 public function testMainPlugin()
 {
     $this->_loadTestPlugin('TestBake');
     $path = Plugin::path('TestBake');
     $this->Task->expects($this->at(0))->method('createFile')->with($this->_normalizePath($path . 'src/Shell/Task/ExampleTask.php'), $this->logicalAnd($this->stringContains('namespace TestBake\\Shell\\Task;'), $this->stringContains('class ExampleTask extends Shell')));
     $this->Task->main('TestBake.Example');
 }
Beispiel #2
0
 /**
  * Test the main with plugin.name method.
  *
  * @return void
  */
 public function testMainWithPlugin()
 {
     Plugin::load('SimpleBakeTest', ['path' => APP . 'Plugin' . DS . 'SimpleBakeTest' . DS]);
     $filename = $this->_normalizePath(APP . 'Plugin/SimpleBakeTest/src/Model/Behavior/ExampleBehavior.php');
     $this->Task->expects($this->once())->method('createFile')->with($filename, $this->stringContains('class ExampleBehavior extends Behavior'));
     $this->Task->Test->expects($this->once())->method('bake')->with('behavior', 'Example');
     $this->Task->main('SimpleBakeTest.Example');
 }
Beispiel #3
0
 /**
  * Test main within a plugin.
  *
  * @return void
  */
 public function testMainPlugin()
 {
     $this->_loadTestPlugin('TestBake');
     $path = Plugin::path('TestBake');
     $this->Task->expects($this->at(0))->method('createFile')->with($this->_normalizePath($path . 'src/Template/Cell/Example/display.ctp'), '');
     $this->Task->expects($this->at(1))->method('createFile')->with($this->_normalizePath($path . 'src/View/Cell/ExampleCell.php'), $this->stringContains('class ExampleCell extends Cell'));
     $this->Task->main('TestBake.Example');
 }
Beispiel #4
0
 /**
  * Test main within a plugin.
  *
  * @return void
  */
 public function testMainPlugin()
 {
     $this->_loadTestPlugin('TestBake');
     $path = Plugin::path('TestBake');
     $this->Task->expects($this->at(0))->method('createFile')->with($this->_normalizePath($path . 'src/Template/Layout/Email/html/example.ctp'), '');
     $this->Task->expects($this->at(1))->method('createFile')->with($this->_normalizePath($path . 'src/Template/Layout/Email/text/example.ctp'), '');
     $this->Task->expects($this->at(2))->method('createFile')->with($this->_normalizePath($path . 'src/Mailer/ExampleMailer.php'), $this->stringContains('class ExampleMailer extends Mailer'));
     $this->Task->main('TestBake.Example');
 }
Beispiel #5
0
 /**
  * test that execute passes with different inflections of the same name.
  *
  * @dataProvider nameVariations
  * @return void
  */
 public function testMainWithNamedModelVariations($name)
 {
     $this->Task->connection = 'test';
     $filename = $this->_normalizePath(APP . 'Model/Table/BakeArticlesTable.php');
     $this->Task->expects($this->at(0))->method('createFile')->with($filename, $this->stringContains('class BakeArticlesTable extends Table'));
     $this->Task->main($name);
 }
Beispiel #6
0
 /**
  * Test the main function.
  *
  * @return void
  */
 public function testMain()
 {
     $this->Shell->loadTasks();
     $this->Shell->main();
     $output = $this->out->messages();
     $expected = ['The following commands can be used to generate skeleton code for your application.', '', '<info>Available bake commands:</info>', '', '- all', '- behavior', '- cell', '- component', '- controller', '- fixture', '- form', '- helper', '- mailer', '- model', '- plugin', '- shell', '- shell_helper', '- task', '- template', '- test', '', 'By using <info>`cake bake [name]`</info> you can invoke a specific bake task.'];
     $this->assertSame($expected, $output);
 }
Beispiel #7
0
 /**
  * test main with plugin.name
  *
  * @return void
  */
 public function testMainWithPluginDot()
 {
     $this->Task->connection = 'test';
     Plugin::load('ControllerTest', ['path' => APP . 'Plugin/ControllerTest/']);
     $path = APP . 'Plugin/ControllerTest/src/Controller/BakeArticlesController.php';
     $this->Task->expects($this->at(1))->method('createFile')->with($this->_normalizePath($path), $this->stringContains('BakeArticlesController extends AppController'))->will($this->returnValue(true));
     $this->Task->main('ControllerTest.BakeArticles');
 }
Beispiel #8
0
 /**
  * Test that baking a plugin for a project that contains a composer.json, the later
  * will be updated
  *
  * @return void
  */
 public function testMainUpdateComposer()
 {
     $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
     $this->io->expects($this->any())->method('askChoice')->will($this->returnValue('y'));
     $this->Task->expects($this->any())->method('findComposer')->will($this->returnValue('composer.phar'));
     $file = TMP . 'tests' . DS . 'main-composer.json';
     file_put_contents($file, '{}');
     $savePath = $this->Task->path;
     $this->Task->path = ROOT . DS . 'tests' . DS . 'BakedPlugins/';
     $this->Task->expects($this->any())->method('_rootComposerFilePath')->will($this->returnValue($file));
     $this->Task->expects($this->once())->method('callProcess')->with('php ' . escapeshellarg('composer.phar') . ' dump-autoload');
     $this->Task->main('ComposerExample');
     $result = file_get_contents($file);
     $this->assertSameAsFile(__FUNCTION__ . '.json', $result);
     $folder = new Folder($this->Task->path);
     $folder->delete();
     $this->Task->path = $savePath;
 }
Beispiel #9
0
 /**
  * Test that bake works
  *
  * @return void
  */
 public function testBake()
 {
     $this->Task->connection = 'test';
     $this->Task->expects($this->at(0))->method('createFile')->with($this->anything(), $this->logicalAnd($this->stringContains('class ArticlesFixture extends TestFixture'), $this->stringContains('public $fields'), $this->stringContains('public $records'), $this->logicalNot($this->stringContains('public $import'))));
     $result = $this->Task->main('Articles');
 }
Beispiel #10
0
 /**
  * test execute with type and class name defined
  *
  * @return void
  */
 public function testExecuteWithAll()
 {
     $this->Task->expects($this->exactly(2))->method('createFile')->withConsecutive([$this->stringContains('TestCase' . DS . 'Model' . DS . 'Table' . DS . 'ArticlesTableTest.php'), $this->stringContains('class ArticlesTableTest extends TestCase')], [$this->stringContains('TestCase' . DS . 'Model' . DS . 'Table' . DS . 'CategoryThreadsTableTest.php'), $this->stringContains('class CategoryThreadsTableTest extends TestCase')]);
     $this->Task->params['all'] = true;
     $this->Task->main('Table');
 }