-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testGetPostContent #2963
testGetPostContent #2963
Conversation
public function testGetPostContent() | ||
{ | ||
// 準備 | ||
$templateDir = ROOT . DS . 'plugins' . DS . 'bc-admin-third' . DS . 'templates'. DS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nghiem-mb テスト実行時、テンプレートが存在しないというエラーが出たのでしょうか?
BlogHelper::getPostContent()
を確認したところ、エレメント呼び出しでプラグイン名の指定がなかったので、エラーになった可能性が高いです。
(ブラウザで実行している場合はプラグイン名なしでも動作します)
次のように変更した上で再度テストを作ってもらえますか?
// BlogHelper 493行目、501行目
$this->BcBaser->getElement('BcBlog.blog_post_content'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryuring
変更しましたが、以下のエラー出ています。
いろいろ修正しましたが、まだ駄目です。
ご確認お願いします。
There was 1 error:
1) BcBlog\Test\TestCase\View\Helper\BlogHelperTest::testGetPostContent
Cake\View\Exception\MissingHelperException: Helper class BlogHelper could not be found.
/var/www/html/vendor/cakephp/cakephp/src/View/HelperRegistry.php:133
/var/www/html/vendor/cakephp/cakephp/src/Core/ObjectRegistry.php:103
/var/www/html/vendor/cakephp/cakephp/src/View/HelperRegistry.php:70
/var/www/html/vendor/cakephp/cakephp/src/View/View.php:1132
/var/www/html/plugins/bc-front/templates/plugin/BcBlog/element/blog_post_content_more.php:27
/var/www/html/vendor/cakephp/cakephp/src/View/View.php:1222
/var/www/html/vendor/cakephp/cakephp/src/View/View.php:1179
/var/www/html/vendor/cakephp/cakephp/src/View/View.php:1731
/var/www/html/vendor/cakephp/cakephp/src/View/View.php:701
/var/www/html/plugins/baser-core/src/View/Helper/BcBaserHelper.php:326
/var/www/html/plugins/bc-blog/src/View/Helper/BlogHelper.php:506
/var/www/html/plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php:311
/var/www/html/vendor/bin/phpunit:122
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nghiem-mb テンプレートの中で、ヘルパが読み込まれていないみたいですね。
ブラウザからアクセスする場合はViewクラスで読み込まれますが、テストの場合は明示的に読み込んであげる必要があるみたいですね。
次の行を追記してみてください。
$this->Blog->getView()->addHelper('Blog', ['className' => 'BcBlog.Blog']);
もしくは、setUp() にて、BlogHelper
を初期化する際に、BlogFrontAppView
を利用するといいかもしれません。
ブラウザからのアクセスの際はその仕様なのでそちらの方がいいかもしれません。
No description provided.