0

我正在尝试使用 Phpunit 创建一个测试并使用 Prophecy 进行模拟,但我得到了 MethodNotFoundException。这是我的代码:

<?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();

    }

}

我正在从命令行执行测试,但出现此错误:

在此处输入图像描述

这是我要测试的类和方法:

<?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;

    }

}

我不知道测试有什么问题,所以,任何帮助将不胜感激。谢谢。

4

0 回答 0