PHP致命错误:无法重新声明类Gedmo \ Loggable \ Loggable

时间:2016-01-08 16:23:00

标签: php symfony doctrine-orm phpunit

我正在努力将我的symfony应用程序2.8更改为3.0,并使用"symfony/phpunit-bridge" : "^3.0"来修复弃用。

在我的代码中,我使用"stof/doctrine-extensions-bundle" : "^1.2"来记录我的学说实体(我有2个使用Loggable的类):

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Security\Core\User\UserInterface;
use FOS\UserBundle\Model\User as BaseUser;
use Volvo\ScoreBundle\Tools\PropertyAccessor;

/**
 * Class User
 *
 * @package Volvo\ScoreBundle\Entity
 *
 * @ORM\Entity(repositoryClass="Volvo\ScoreBundle\Entity\UserRepository")
 * @ORM\Table(name="users")
 * @Gedmo\Loggable
 */
class User extends BaseUser
{

const ROLE_ADMIN = 'ROLE_ADMIN';
const ROLE_USER = 'ROLE_USER';

/**
 * @var int
 *
 * @ORM\Id
 * @ORM\Column(type="bigint")
 * @ORM\GeneratedValue
 */
protected $id = null;


/**
 * @var string
 *
 * @ORM\Column(type="string")
 * @Gedmo\Versioned
 */
protected $surname = '';

/**
 * @var \DateTime $created
 *
 * @Gedmo\Timestampable(on="create")
 * @ORM\Column(type="datetime")
 */
private $createdAt;

/**
 * @var \DateTime $updated
 *
 * @Gedmo\Timestampable(on="update")
 * @ORM\Column(type="datetime")
 */
private $updatedAt;

...

}

但是如果我用PHPUnit和phpunit-bridge执行测试,我有一个像这样的PHP致命错误:

PHP Fatal error:  Cannot redeclare class Gedmo\Loggable\Loggable in /home/vincent/developpement/volvoSf2/vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Loggable.php on line 13

如果你有解决方案......谢谢

0 个答案:

没有答案