/** * Test baking within a plugin. * * @return void */ public function testBakePlugin() { $this->_loadTestPlugin('TestBake'); $path = Plugin::path('TestBake'); $this->Task->plugin = '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')); $result = $this->Task->bake('Example'); $this->assertSameAsFile(__FUNCTION__ . '.php', $result); }
/** * Test baking within a plugin. * * @return void */ public function testBakePlugin() { $this->_loadTestPlugin('TestBake'); $path = Plugin::path('TestBake'); $this->Task->plugin = 'TestBake'; $this->Task->expects($this->once())->method('createFile')->with($this->_normalizePath($path . 'src/Model/Behavior/ExampleBehavior.php'), $this->stringContains('class ExampleBehavior extends Behavior')); $result = $this->Task->bake('Example'); $this->assertSameAsFile(__FUNCTION__ . '.php', $result); }
/** * test bake() with a -plugin param * * @return void */ public function testBakeWithPlugin() { $this->Task->plugin = 'TestTest'; Plugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]); $path = APP . 'Plugin/TestTest/tests/TestCase/View/Helper/FormHelperTest.php'; $path = str_replace('/', DS, $path); $this->Task->expects($this->once())->method('createFile')->with($path, $this->anything()); $this->Task->bake('Helper', 'Form'); }
/** * Test baking within a plugin. * * @return void */ public function testBakePlugin() { $this->_loadTestPlugin('TestBake'); $path = Plugin::path('TestBake'); $this->Task->plugin = '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'))); $result = $this->Task->bake('Example'); $this->assertSameAsFile(__FUNCTION__ . '.php', $result); }
/** * Test baking within a plugin. * * @return void */ public function testBakePlugin() { $this->_loadTestPlugin('TestBake'); $path = Plugin::path('TestBake'); $this->Task->plugin = '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')); $result = $this->Task->bake('Example'); $this->assertSameAsFile(__FUNCTION__ . '.php', $result); }
/** * test record generation with float and binary types * * @return void */ public function testRecordGenerationForBinaryAndFloat() { $this->Task->connection = 'test'; $result = $this->Task->bake('Article', 'datatypes'); $this->assertContains("'float_field' => 1", $result); $this->assertContains("'decimal_field' => 1.5", $result); $this->assertContains("'huge_int' => 1", $result); $this->assertContains("'bool' => 1", $result); $this->assertContains("_constraints", $result); $this->assertContains("'primary' => ['type' => 'primary'", $result); $this->assertContains("'columns' => ['id']", $result); $this->assertContains("'uuid' => ['type' => 'uuid'", $result); $this->assertRegExp("/(\\s+)('uuid' => ')([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12})(')/", $result); $result = $this->Task->bake('Article', 'binary_tests'); $this->assertContains("'data' => 'Lorem ipsum dolor sit amet'", $result); }
/** * test bake with vendor plugin * * @return void */ public function testBakeVendorName() { $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); $this->Task->bake('Company/Example'); $this->assertPluginContents('Company/Example'); }
/** * * test that bakeActions is creating the correct controller Code. (Using sessions) * * @return void */ public function testBakeActionsContent() { $result = $this->Task->bake('BakeArticles'); $this->assertSameAsFile(__FUNCTION__ . '.php', $result); }