2011-03-04 2 views
2

나는 cakePhP에 여러 조명기를 만들려고했지만 헛되이 노력했다. 현재 두 개의 다른 조명기 데이터베이스 테이블을 필요로하는 함수를 테스트해야합니다. 가능하다면, 누군가 간단한 스 니펫을 게시하고 여러 비품을 만들어 주실 수 있습니까?cakePhp에서 여러 조명기 만들기

답변

4

로,

당신은 케이크의 bake 유틸리티를 살펴 보셨나요? 그것으로 조명기구를 구울 수 있습니다.

cake bake fixture all 

은 앱에서 동시에 모든 조명기를 굽습니다. 기존 코드를 덮어 쓰지 않도록주의해서 사용하십시오.

Edit0 : 사용

추가 문의 사항이 있으면
cake bake fixture help 

.

4

여기에 간단한기구입니다 : 응용 프로그램/시험/비품이 경우/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') 

    ); 
} 
?> 

경우는 테스트 케이스의 상단에 비품을 포함

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) 
    ); 
} 
관련 문제