在cakePhp中创建多个装置

在cakePhp中创建多个装置,cakephp,Cakephp,我一直在尝试用cakePhP创建多个fixture,但没有成功。目前,我需要测试一个需要两个不同fixture数据库表的函数。如果可能的话,请有人发表一些简单的片段,并告诉我创建多个装置 熔炉 你看过蛋糕的bake实用程序了吗?你可以用它烤固定装置 cake bake fixture all 在应用程序中一次性烘焙所有固定装置。请小心使用,以免覆盖现有代码 Edit0: 使用 如果您还有其他问题。这里有一个简单的fixture:app/tests/fixtures/entity_fixture

我一直在尝试用cakePhP创建多个fixture,但没有成功。目前,我需要测试一个需要两个不同fixture数据库表的函数。如果可能的话,请有人发表一些简单的片段,并告诉我创建多个装置

熔炉

你看过蛋糕的
bake
实用程序了吗?你可以用它烤固定装置

cake bake fixture all
在应用程序中一次性烘焙所有固定装置。请小心使用,以免覆盖现有代码

Edit0: 使用


如果您还有其他问题。

这里有一个简单的fixture:app/tests/fixtures/entity_fixtures.php 在本例中,您将创建其中两个文件,每个模型一个,名称不同

<?php  
 class EntityFixture extends CakeTestFixture { 

    var $name = 'Entity'; 
    var $table = 'entities';

    // Define the fields
    var $fields = array(
        'entity_id'     => array('type' => 'integer', 'key' => 'primary'),
        'type'          => array('type' => 'string' , 'length' => 255),
        'created'       => 'datetime',
        'modified'      => 'datetime'

    );

    var $records = array( 
        array('entity_id' => 1, 'type' => 'entity', 'created'=>'2010-01-01', 'modified' => '2010-01-01')

    ); 
 } 
 ?> 
<?php  
 class EntityFixture extends CakeTestFixture { 

    var $name = 'Entity'; 
    var $table = 'entities';

    // Define the fields
    var $fields = array(
        'entity_id'     => array('type' => 'integer', 'key' => 'primary'),
        'type'          => array('type' => 'string' , 'length' => 255),
        'created'       => 'datetime',
        'modified'      => 'datetime'

    );

    var $records = array( 
        array('entity_id' => 1, 'type' => 'entity', 'created'=>'2010-01-01', 'modified' => '2010-01-01')

    ); 
 } 
 ?> 
class EntityTestCase extends CakeTestCase {

    var $fixtures = array(
        'plugin.myplugin.entity',     // Including a sample plugin fixture
        'entity',                     // The fixture above shown in code above
        'blogs'                       // Including a third fixture (should be in app/tests/fixtures/blog_fixture.php)
    );
}