类型错误运行PHPUnit的测试时,出现此错误:传递给Drupal的\意见\插件\观点参数1 \的HandlerBase :: __结构()必须是数组类型的PHPUnit我想对我的Drupal项目
我代码:
use Drupal\views_simple_math_field\Plugin\views\field\SimpleMathField;
class BasicTest extends PHPUnit_Framework_TestCase
{
public function test_proba()
{
$first = 25;
$second = 5;
$result = 13;
$test = new SimpleMathField();
$working = $test->plus($first,$second,$result);
$this->assertEquals($result,$working);
}
}
我认为错误是“$测试=新SimpleMathField()内;由于测试运行完美,当我运行它是这样的:
<?php
use Drupal\views_simple_math_field\Plugin\views\field\SimpleMathField;
class BasicTest extends PHPUnit_Framework_TestCase
{
public function test_proba()
{
$first = 25;
$second = 5;
$result = 13;
$this->assertTrue(True);
}
}
你测试一个名为Basic类? –
我测试在SimpleMathFIeld班加()函数,它位于有Drupal的\ views_simple_math_field \插件\意见\现场\命名空间中的extern PHP文件。 –
测试类应该有一个带有“Test”后缀的名称。所以它应该是SimpleMathFIeldTest而不是BasicTest。如果你不是很确定自己在做什么,我会推荐这个优秀的教程:https://jtreminio.com/2013/03/unit-testing-tutorial-introduction-to-phpunit/ –