2011-08-12 57 views
5

我有這個類:PHPUnit的生成框架測試類:對父類錯誤


namespace MyFirm\PlatformBundle\Entity\Destination\Content; 

class Event extends Content   //this is line 18 
{ 
    ... 

我想通過這個來生成骨架測試類:

$ phpunit --skeleton-test "MyFirm\PlatformBundle\Entity\Destination\Content\Event" Event.php

但我得到這個錯誤:

PHP Fatal error: Class 'MyFirm\PlatformBundle\Entity\Destination\Content\Content' not found in /home/me/mf/myfirm/src/MyFirm/PlatformBundle/Entity/Destination/Content/Event.php on line 18

這是內容類:


namespace MyFirm\PlatformBundle\Entity\Destination\Content; 

abstract class Content 
{ 
    ... 

我沒有任何問題首先生成內容類的骨架測試類。

有什麼想法?

PHP 5.3/3.5的PHPUnit

標籤:繼承

回答

3

只要你不把PHPUnit的命令來解決你的類名與實際文件可以自動加載,這將無法工作因爲在加載文件以創建框架時,MyFirm\PlatformBundle\Entity\Destination\Content\Content未被聲明。

將您的項目自動加載器添加到引導程序文件中,並使用啓用了此引導程序文件的phpunit構建骨架文件。然後,您將不會再收到此致命錯誤,因爲PHP也能夠找到MyFirm\PlatformBundle\Entity\Destination\Content\Content的聲明。

相關問題