|
|
@@ -205,7 +205,7 @@ class ModelTaskTest extends CakeTestCase {
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testGetTableOddTable() {
|
|
|
+ public function testGetTableOddTableInteractive() {
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
$this->Task = $this->getMock('ModelTask',
|
|
|
@@ -234,6 +234,34 @@ class ModelTaskTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * test getTable with non-conventional tablenames
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testGetTableOddTable() {
|
|
|
+ $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
+ $in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
+ $this->Task = $this->getMock('ModelTask',
|
|
|
+ array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables'),
|
|
|
+ array($out, $out, $in)
|
|
|
+ );
|
|
|
+ $this->_setupOtherMocks();
|
|
|
+
|
|
|
+ $this->Task->connection = 'test';
|
|
|
+ $this->Task->path = '/my/path/';
|
|
|
+ $this->Task->interactive = false;
|
|
|
+ $this->Task->args = array('BakeOdd');
|
|
|
+
|
|
|
+ $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
|
|
|
+
|
|
|
+ $this->Task->listAll();
|
|
|
+
|
|
|
+ $result = $this->Task->getTable('BakeOdd');
|
|
|
+ $expected = 'bake_odd';
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* test that initializing the validations works.
|
|
|
*
|
|
|
* @return void
|
|
|
@@ -971,6 +999,61 @@ STRINGEND;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * test that odd tablenames arent inflected back from modelname
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testExecuteIntoBakeOddTables() {
|
|
|
+ $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
+ $in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
+ $this->Task = $this->getMock('ModelTask',
|
|
|
+ array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'),
|
|
|
+ array($out, $out, $in)
|
|
|
+ );
|
|
|
+ $this->_setupOtherMocks();
|
|
|
+
|
|
|
+ $this->Task->connection = 'test';
|
|
|
+ $this->Task->path = '/my/path/';
|
|
|
+ $this->Task->args = array('BakeOdd');
|
|
|
+ $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
|
|
+ $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
|
|
|
+ $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
|
|
|
+ $this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object));
|
|
|
+ $this->Task->expects($this->once())->method('bake')->with($object, false)->will($this->returnValue(true));
|
|
|
+ $this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd');
|
|
|
+
|
|
|
+ $this->Task->execute();
|
|
|
+
|
|
|
+ $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
+ $in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
+ $this->Task = $this->getMock('ModelTask',
|
|
|
+ array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'createFile'),
|
|
|
+ array($out, $out, $in)
|
|
|
+ );
|
|
|
+ $this->_setupOtherMocks();
|
|
|
+
|
|
|
+ $this->Task->connection = 'test';
|
|
|
+ $this->Task->path = '/my/path/';
|
|
|
+ $this->Task->args = array('BakeOdd');
|
|
|
+ $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
|
|
+ $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
|
|
|
+ $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
|
|
|
+ $this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object));
|
|
|
+ $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array()));
|
|
|
+ $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array()));
|
|
|
+
|
|
|
+ $filename = '/my/path/BakeOdd.php';
|
|
|
+ $this->Task->expects($this->once())->method('createFile')
|
|
|
+ ->with($filename, $this->stringContains('class BakeOdd'));
|
|
|
+
|
|
|
+ $filename = '/my/path/BakeOdd.php';
|
|
|
+ $this->Task->expects($this->once())->method('createFile')
|
|
|
+ ->with($filename, $this->stringContains('public $useTable = \'bake_odd\''));
|
|
|
+
|
|
|
+ $this->Task->execute();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* test that skipTables changes how all() works.
|
|
|
*
|
|
|
* @return void
|