我正在使用 symfony2。我的 AppKernel 中的代码如下所示:
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle()
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new My\BookBundle\MyBookBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
现在我的 Bookbundle 下的单元测试之一的代码如下所示:
namespace My\BookBundle\Tests\Controller;
use My\BookBundle\Services\TestHelper;
use My\BookBundle\Tests\BaseTest;
class WriterControllerTest extends BaseTest
{
/**
* @var TestHelper
*/
protected $testHelper;
public function __construct()
{
parent::__construct();
$this->testHelper = $this->get('test_helper');
}
public function setUp()
{
$this->testHelper->setupTestData();
}
以前它运行应用程序和测试非常顺利。然后我添加了很多功能代码(例如控制器、存储库功能等)。现在,当我尝试通过编写测试来备份代码时,我在命令提示符下遇到以下错误:
PHP Fatal error: Class 'Symfony\Component\HttpKernel\Kernel' not found in /var/www/Symfony/app/AppKernel.php on line 7
如您在上述代码中所见,第 7 行指的是 AppKernel 类的声明。
我很困惑,我无法找到代码突然中断的原因。
你能帮忙吗?