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


PHP CakeTestCase::getMockForModel方法代码示例

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


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

示例1: loadMongoFixtures

 /**
  * Loads the fixtures from the mongoFixtures array in the testCase into the mongoDataSource.
  * @param CakeTestCase $testCase
  *
  * @return bool
  * @throws Exception
  */
 public static function loadMongoFixtures(CakeTestCase $testCase)
 {
     if (!isset($testCase->mongoFixtures) || !is_array($testCase->mongoFixtures)) {
         return false;
     }
     foreach ($testCase->mongoFixtures as $fixtureName) {
         list($plugin, $fixtureName) = explode('.', $fixtureName);
         $fixture = new $fixtureName();
         $modelName = str_replace('Fixture', '', $fixtureName);
         $model = $testCase->getMockForModel($plugin . '.' . $modelName, array('test'));
         if (substr($model->useDbConfig, 0, 5) !== 'test_') {
             throw new InternalErrorException('The model for fixture ' . $fixtureName . ' does not have a test datasource.');
         }
         self::$_models[] = $model;
         foreach ($fixture->collections as $collection => $documents) {
             $model->setSource($collection);
             $model->batchInsert($documents);
         }
     }
     return true;
 }
开发者ID:ExpandOnline,项目名称:CakePHPUtil,代码行数:28,代码来源:MongoFixtureHandler.php

示例2: getMockForModel

 /**
  * {@inheritdoc}
  */
 public function getMockForModel($model, $methods = array(), $config = array(), $registry = false)
 {
     $modelOriginal = ClassRegistry::init($model);
     $modelMock = parent::getMockForModel($model, $methods, $config);
     // Fix bug when not merging behaviors and findMethods recursively for mocks.
     // @see Model::__construct() line 717-724
     if (get_parent_class($modelOriginal) !== 'AppModel') {
         $modelMock->findMethods = $modelOriginal->findMethods;
         $modelMock->Behaviors->init($modelMock->alias, $modelOriginal->actsAs);
     }
     if ($registry) {
         if (true === $registry) {
             list(, $registry) = pluginSplit($model);
         }
         if (ClassRegistry::isKeySet($registry)) {
             ClassRegistry::removeObject($registry);
         }
         ClassRegistry::addObject($registry, $modelMock);
     }
     return $modelMock;
 }
开发者ID:gourmet,项目名称:common,代码行数:24,代码来源:CommonTestCase.php


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