在使用 Cakephp 应用程序测试所有模型之前,./cake test app AllModel
我必须进行一些操作。我使用 Cakephp 2.9.7。这个函数的声明AllModelTest.php
方式如下:
class AllModelTest extends CakeTestSuite {
public static function suite() {
$suite = new CakeTestSuite('All model tests');
$suite->addTestDirectory(TESTS . 'Case/Model');
return $suite;
}
}
如何访问我的模型并直接从此文件进行一些操作?我试过了App::uses('MyModel', 'Model');
——那是行不通的。$this
我不能使用,因为它给了我错误PHP Fatal error: Using $this when not in object context in path....
您可以使用 ClassRegistry
$yourModel = ClassRegistry::init('YourModelName');
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句