当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeTestFixture::create方法代码示例

本文整理汇总了PHP中CakeTestFixture::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeTestFixture::create方法的具体用法?PHP CakeTestFixture::create怎么用?PHP CakeTestFixture::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CakeTestFixture的用法示例。


在下文中一共展示了CakeTestFixture::create方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Initializes this fixture class
  *
  * @return boolean
  */
 public function create($db)
 {
     if (!empty($this->fields)) {
         return parent::create($db);
     }
     return (bool) $db->execute(file_get_contents($this->_getFilePath()));
 }
开发者ID:theplankmeister,项目名称:cakephp-fixturize,代码行数:12,代码来源:SQLTestFixture.php

示例2: create

 function create(&$db)
 {
     $result = parent::create($db);
     if ($result) {
         $db->execute('ALTER TABLE `items` CHANGE `provider_key` `provider_key` BIGINT( 20 ) NULL DEFAULT NULL ');
     }
     return $result;
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:8,代码来源:item_fixture.php

示例3: create

 /**
  * Maps enum fields in the database to strings with a length of 64
  */
 public function create($db)
 {
     foreach ($this->fields as $name => &$field) {
         if (strstr($field['type'], "enum") !== false) {
             $field['type'] = 'string';
             $field['length'] = 64;
         }
     }
     parent::create($db);
 }
开发者ID:inigoflores,项目名称:CakePHP-Notification-Manager,代码行数:13,代码来源:EnumFriendlyTestFixture.php

示例4: create

 public function create($db)
 {
     parent::create($db);
     return '
   CREATE TABLE `multilanguage_model` (
     `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
     `object_id` int(11) unsigned NOT NULL,
     `lang_code` varchar(5) NOT NULL,
     `name` text,
     PRIMARY KEY (`id`)
   ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8';
 }
开发者ID:pdkhuong,项目名称:BBG,代码行数:12,代码来源:TestFixture.php

示例5: create

 /**
  * Initializes this fixture class
  *
  * @param DboSource $db
  * @return boolean
  */
 public function create($db)
 {
     if (!empty($this->fields)) {
         return parent::create($db);
     }
     $source = ConnectionManager::getDataSource($this->sourceConfig);
     $sourceTable = $source->fullTableName($this->table);
     $query = sprintf('DROP TABLE IF EXISTS %s', $db->fullTableName($this->table));
     $db->execute($query, ['log' => false]);
     $query = sprintf('CREATE TABLE %s LIKE %s', $db->fullTableName($this->table), $sourceTable);
     $db->execute($query, ['log' => false]);
     $this->created[] = $db->configKeyName;
     return true;
 }
开发者ID:theplankmeister,项目名称:cakephp-fixturize,代码行数:20,代码来源:TableCopyTestFixture.php

示例6: create

 public function create($db)
 {
     $ok = parent::create($db);
     // Workaround: CakeSchema cannot create FULLTEXT fixtures, so we change the table manually after creation
     if ($ok) {
         $query = "ALTER TABLE `{$this->table}` ADD FULLTEXT INDEX `data` (`data` ASC)";
         try {
             $db->rawQuery($query);
             $this->created[] = $db->configKeyName;
         } catch (Exception $e) {
             $msg = __d('cake_dev', 'Fixture creation for "%s" failed "%s"', $this->table, $e->getMessage());
             CakeLog::error($msg);
             trigger_error($msg, E_USER_WARNING);
             return false;
         }
         return true;
     }
     return false;
 }
开发者ID:klarkc,项目名称:Searchable-Behaviour-for-CakePHP,代码行数:19,代码来源:SearchIndexFixture.php

示例7: create

 /**
  * Run before all tests execute, should return SQL statement to create table for this fixture could be executed successfully.
  *
  * @param object	$db	An instance of the database object used to create the fixture table
  * @return boolean True on success, false on failure
  * @access public
  * @ override
  */
 public function create(&$db)
 {
     if (isset($this->fields) && !empty($this->fields) && empty($this->fields['tableParameters']['engine'])) {
         $canUseMemory = true;
         foreach ($this->fields as $field => $args) {
             if (is_string($args)) {
                 $type = $args;
             } elseif (!empty($args['type'])) {
                 $type = $args['type'];
             } else {
                 continue;
             }
             if (in_array($type, array('blob', 'text', 'binary'))) {
                 $canUseMemory = false;
                 break;
             }
         }
         if ($canUseMemory) {
             $this->fields['tableParameters']['engine'] = 'MEMORY';
         }
     }
     return parent::create($db);
 }
开发者ID:hiromi2424,项目名称:ninja,代码行数:31,代码来源:ninja_test_fixture.php

示例8: _setupTable

 /**
  * Runs the drop and create commands on the fixtures if necessary.
  *
  * @param CakeTestFixture $fixture the fixture object to create
  * @param DataSource $db the datasource instance to use
  * @param boolean $drop whether drop the fixture if it is already created or not
  * @return void
  */
 protected function _setupTable($fixture, $db = null, $drop = true)
 {
     if (!$db) {
         if (!empty($fixture->useDbConfig)) {
             $db = ClassRegistry::getDataSource($fixture->useDbConfig);
         } else {
             $db = $this->_db;
         }
     }
     if (!empty($fixture->created) && in_array($db->configKeyName, $fixture->created)) {
         return;
     }
     $sources = $db->listSources();
     $table = $db->config['prefix'] . $fixture->table;
     if ($drop && in_array($table, $sources)) {
         $fixture->drop($db);
         $fixture->create($db);
     } elseif (!in_array($table, $sources)) {
         $fixture->create($db);
     }
 }
开发者ID:pkdevbox,项目名称:app.director,代码行数:29,代码来源:CakeFixtureManager.php

示例9: _setupTable

 /**
  * Runs the drop and create commands on the fixtures if necessary.
  *
  * @param CakeTestFixture $fixture the fixture object to create
  * @param DataSource $db the datasource instance to use
  * @param bool $drop whether drop the fixture if it is already created or not
  * @return void
  */
 protected function _setupTable($fixture, $db = null, $drop = true)
 {
     if (!$db) {
         if (!empty($fixture->useDbConfig)) {
             $db = ConnectionManager::getDataSource($fixture->useDbConfig);
         } else {
             $db = $this->_db;
         }
     }
     if (!empty($fixture->created) && in_array($db->configKeyName, $fixture->created)) {
         return;
     }
     $sources = (array) $db->listSources();
     $table = $db->config['prefix'] . $fixture->table;
     $exists = in_array($table, $sources);
     if ($drop && $exists) {
         $fixture->drop($db);
         $fixture->create($db);
     } elseif (!$exists) {
         $fixture->create($db);
     } else {
         $fixture->created[] = $db->configKeyName;
     }
 }
开发者ID:agashish,项目名称:test_new,代码行数:32,代码来源:CakeFixtureManager.php

示例10: startController

 /**
  * Callback issued when a controller's action is about to be invoked through testAction().
  *
  * @param Controller $controller	Controller that's about to be invoked.
  * @param array $params	Additional parameters as sent by testAction().
  * @return void
  * @access public
  */
 function startController(&$controller, $params = array())
 {
     if (isset($params['fixturize']) && (is_array($params['fixturize']) && !empty($params['fixturize']) || $params['fixturize'] === true)) {
         if (!isset($this->db)) {
             $this->_initDb();
         }
         if ($controller->uses === false) {
             $list = array($controller->modelClass);
         } else {
             $list = is_array($controller->uses) ? $controller->uses : array($controller->uses);
         }
         $models = array();
         ClassRegistry::config(array('ds' => $params['connection']));
         foreach ($list as $name) {
             if (is_array($params['fixturize']) && in_array($name, $params['fixturize']) || $params['fixturize'] === true) {
                 if (class_exists($name) || App::import('Model', $name)) {
                     $object = ClassRegistry::init($name);
                     //switch back to specified datasource.
                     $object->setDataSource($params['connection']);
                     $db = ConnectionManager::getDataSource($object->useDbConfig);
                     $db->cacheSources = false;
                     $models[$object->alias] = array('table' => $object->table, 'model' => $object->alias, 'key' => strtolower($name));
                 }
             }
         }
         ClassRegistry::config(array('ds' => 'test_suite'));
         if (!empty($models) && isset($this->db)) {
             $this->_actionFixtures = array();
             foreach ($models as $model) {
                 $fixture = new CakeTestFixture($this->db);
                 $fixture->name = $model['model'] . 'Test';
                 $fixture->table = $model['table'];
                 $fixture->import = array('model' => $model['model'], 'records' => true);
                 $fixture->init();
                 $fixture->create($this->db);
                 $fixture->insert($this->db);
                 $this->_actionFixtures[] = $fixture;
             }
             foreach ($models as $model) {
                 $object = ClassRegistry::getObject($model['key']);
                 if ($object !== false) {
                     $object->setDataSource('test_suite');
                     $object->cacheSources = false;
                 }
             }
         }
     }
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:56,代码来源:cake_test_case.php

示例11: _setupTable

 /**
  * Runs the drop and create commands on the fixtures if necessary
  *
  * @param CakeTestFixture $fixture the fixture object to create
  * @param DataSource $db the datasource instance to use
  * @param boolean $drop whether drop the fixture if it is already created or not
  * @return void
  */
 protected function _setupTable($fixture, $db = null, $drop = true)
 {
     if (!$db) {
         $db = $this->_db;
     }
     if (!empty($fixture->created) && $fixture->created == $db->configKeyName) {
         return;
     }
     $cacheSources = $db->cacheSources;
     $db->cacheSources = false;
     $sources = $db->listSources();
     $db->cacheSources = $cacheSources;
     $table = $db->config['prefix'] . $fixture->table;
     if ($drop && in_array($table, $sources)) {
         $fixture->drop($db);
         $fixture->create($db);
         $fixture->created = $db->configKeyName;
     } elseif (!in_array($table, $sources)) {
         $fixture->create($db);
         $fixture->created = $db->configKeyName;
     }
 }
开发者ID:Nervie,项目名称:Beta,代码行数:30,代码来源:CakeFixtureManager.php

示例12: create

 public function create(&$db)
 {
     $db->columns['decimal'] = array('name' => 'decimal', 'formatter' => 'floatval');
     return parent::create($db);
 }
开发者ID:styfle,项目名称:core,代码行数:5,代码来源:payment_fixture.php

示例13: creaete

 public function creaete($db)
 {
     $ret = parent::create($db);
     var_dump($ret);
     exit;
 }
开发者ID:JodiWarren,项目名称:hms,代码行数:6,代码来源:MailingListSubscriptionsFixture.php


注:本文中的CakeTestFixture::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。