我收到错误,"试图获取非对象的属性"当我只想在我的单元测试类中实例化一个控制器时。
<?php namespace Tests\Unitaires\ModuleFournisseurs;
session_start();
/**
* Test du controlleur X
*/
class XControllerTest extends \PHPUnit_Framework_TestCase
{
public function testScenario()
{
// loading my modules
\bootstrapDev::addModules(Array(
'ModuleX',
'ModuleY',
// ...
));
// runing my bootstrap
\bootstrapDev::init();
// the line of code that generates the error
$controlleur = new \Name\Space\XController;
$this->assertTrue(true);
}
}
答案 0 :(得分:0)
我找到了错误的来源。这是因为我的控制器扩展了另一个在其构造函数中有一些处理的类,它会生成错误。