Drupal 7 预言框架和Drupal7
我试图用Phpunit创建一个测试,并用预言进行模拟,但我得到了MethodNotFoundException。这是我的代码:Drupal 7 预言框架和Drupal7,drupal-7,phpunit,prophecy,Drupal 7,Phpunit,Prophecy,我试图用Phpunit创建一个测试,并用预言进行模拟,但我得到了MethodNotFoundException。这是我的代码: <?php namespace Drupal\forum_innovation\Tests; use Prophecy; /** * Test the ForumCounter Class. * @coversDefaultClass \Drupal\forum_innovation\Forum * @group utility */ class
<?php
namespace Drupal\forum_innovation\Tests;
use Prophecy;
/**
* Test the ForumCounter Class.
* @coversDefaultClass \Drupal\forum_innovation\Forum
* @group utility
*/
class ForumCounterTest extends \PHPUnit_Framework_TestCase {
/**
* @covers::setForumCounter
*/
public function testSetForumCounter() {
$prophet = new Prophecy\Prophet;
$set_counter = $prophet->prophesize('Drupal\forum_innovation\Forum\ForumCounter');
$set_counter->setForumCounter(83, 3024)->willReturn(TRUE);
$stub = $set_counter->reveal();
}
}
您的测试类中的第34行是什么样子的?谢谢您的评论Susi,但我的测试中只有29行。你能证实你的问题吗?你截图中的错误信息说明错误发生在ForumCounterTest的第34行-这就是我问的原因。
<?php
namespace Drupal\forum_innovation\Forum;
class ForumCounter implements ForumInterface {
public static function setForumCounter($forum, $uid) {
$counterState = db_update('forum_counter_states')
->fields(array(
'state' => 'read',
))
->condition('uid', $uid)
->condition('tid', $forum)
->execute();
return $counterState;
}
}