0 レビュー
2 回答
php-Codeigniter3.0phpunitテストが機能しない
http://blog.a-way-out.net/blog/2015/06/12/codeigniter3-phpunit/ を使用して、すでに構築されているサイトにphpunitテストコードを追加しようとしました しかし、そのスローエラー:
1) Homemodel_test::test_When_you_get_all_news_Then_you_get_one_item
LogicException: CodeIgniter instance is not instantiated yet. You can't use `$th
is->simple_cache` at the moment. Please fix your test code.
E:\xampp\htdocs\CodeIgniter\application\tests\_ci_phpunit_test\CIPHPUnitTestNull
CodeIgniter.php:18
E:\xampp\htdocs\CodeIgniter\application\helpers\language_helper.php:10
E:\xampp\htdocs\CodeIgniter\application\core\ROCKERS_Controller.php:51
E:\xampp\htdocs\CodeIgniter\application\controllers\Home.php:51
E:\xampp\htdocs\CodeIgniter\application\tests\_ci_phpunit_test\CIPHPUnitTestRequ
est.php:292
E:\xampp\htdocs\CodeIgniter\application\tests\_ci_phpunit_test\CIPHPUnitTestRequ
est.php:215
E:\xampp\htdocs\CodeIgniter\application\tests\_ci_phpunit_test\CIPHPUnitTestRequ
est.php:126
E:\xampp\htdocs\CodeIgniter\application\tests\_ci_phpunit_test\CIPHPUnitTestCase
.php:106
E:\xampp\htdocs\CodeIgniter\application\tests\models\home_model_test.php:25
FAILURES!
わからない
0
レビュー
答え :
解決策:
これは、HMVC https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvcを使用しているためです。
ci-phpunit-testは現在HMVCをサポートしていません。 最新のステータスを確認するには、https://github.com/kenjis/ci-phpunit-test/issues/34を参照してください。
わからない
0
レビュー
答え :
解決策:
この問題にも遭遇しましたが、シナリオが少し異なります。 $ this-> request()
を呼び出した後、コンテキストが「失われた」ことに気づきました $CI =& get_instance();
$CI->load->model('Random_model');
$CI->Random_model->save($data);
$output = $this->request('POST', 'https://example.com/random', $data);
// Now if I want to load model I need to call get_instance() again
$CI =& get_instance();
$CI->load->model('Other_model');
get_instance()を再度呼び出さない場合。エラーが発生します:
[phpunit] LogicException:CodeIgniterインスタンスがインスタンス化されていません まだ。現在、
$this->load
は使用できません。テストを修正してください コード。
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。