开发者

PHPUnit-generating skeleton test class: error about the parent class

I have this class:


namespace MyFirm\PlatformBundle\Entity\Destination\Content;

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

I'm trying to generate its skeleton test class through this:

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

but I'm getting this error:

PHP Fatal error:  Class 'MyFirm\PlatformBundle\E开发者_JAVA技巧ntity\Destination\Content\Content' not found in /home/me/mf/myfirm/src/MyFirm/PlatformBundle/Entity/Destination/Content/Event.php on line 18

This is the Content class:


namespace MyFirm\PlatformBundle\Entity\Destination\Content;

abstract class Content
{
    ...

I didn't have any problem to generate first the skeleton test class for the Content class.

Any idea?

php 5.3/phpunit 3.5

tags: inheritance


As long as you don't make the phpunit command to resolve your classnames to actual files that can be auto-loaded, this won't work because in the moment the file is loaded to create the skeleton, MyFirm\PlatformBundle\Entity\Destination\Content\Content is not declared.

Add your projects autoloader to a bootstrap file and build the skeleton files with phpunit having this bootstrap file enabled. Then you won't get this fatal error any longer as PHP is able to find the declaration of MyFirm\PlatformBundle\Entity\Destination\Content\Content as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜