我有一个代码点火器项目,我安装了 phpspec。我的问题是,当我对我的类运行测试时,它会抛出一个错误,即找不到该类的基类(由代码点火器框架自动加载),即“找不到类'CI_Controller'”。
我尝试手动包含基类的路径并删除namespace controllers;
似乎可以解决该问题的行。但是现在我的 phpspec 测试失败了class controllers\Calculator does not exist
。
这是我的设置方式:
我在 src > 控制器 > Calculator.php 中的类:
<?php
//I had to remove the following line for my app to work:
//namespace controllers;
class Calculator extends CI_Controller {...}
我在规范 > 控制器 > CalculatorSpec.php 中的测试:
<?php
namespace spec\controllers;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
//I had to add this line to fix my first problem
include_once '/Users/bradleytrager/Desktop/Workspace/code-ignitor-calculator/system/core/Controller.php';
class CalculatorSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('controllers\Calculator');
}
}
谁能帮我让它工作?