I am writing a custom plugin for the awesome framework CakePHP, called: TableTool
.
My plugin has a default folder structure, created by cake bake
:
-app (some subfolders omitted)
--plugin
---TableTool
----Config
----Console
----Controller
-----TableToolAppController.php
----Lib
----Model
-----TableToolAppModel.php
<= old location of the model
----Test
-----Case
------View
-------Helper
--------TableToolHelperTest.php
------Fixture
--------PostFixtureTest.php
-----TestApp <= manually added
------Model
-------Post.php <= new location of the model
----Vendor
----View
-----Helper
------TableToolHelper.php
The plugin is a helper-tool without a specific model. For test purposes a use a Model: Post
. It is located in app\plugin\TableTool\Model\Post.php
(old location) and works fine in my test case.
Because the model Post.php is only for test purposes I have tried to change the location to: app\plugin\TableTool\Test\TestApp\Model\Post
.
After the change my test case started with complaining: Model Post
could not be found. That wasn`t a surprise. The fixture needs a folder location for the model. I have tried the following:
class PostFixture extends CakeTestFixture {
public $import = array('model' => 'TableTool.Model/Post', 'records' => true, 'connection' => 'test_tooltable');
public function init() {
App::build(array('TableTool.Model' => array(APP . 'Plugin' . DS . 'TableTool' . DS . 'Test' . DS . 'TestApp' . DS . 'Model' . DS)));
parent::init();
}
}
In the lib\cake\Test
folder, I have seen a test_app
.... I have look around for examples in it, but I didn't found the solution....
Thanks for reading.