I’ve written some tests on an symfony 4.4 application and I would like to run these tests on my gitlab CI but I get this error :
Error [Semantical Error] The annotation “@DoctrineORMMappingOnetoMany” in property AppEntityClient::$logsRegions was never imported . Did you maybe forget to add a “use” statement for this annotation?
but I haven’t this error neither in my local env nor in production env and I import DoctrineORMMapping as ORM
in my entity
Here my Client entity
<?php namespace AppEntity; use DoctrineCommonCollectionsArrayCollection; use DoctrineORMMapping as ORM; use AppEntityRegionAccessLogRegion; use AppEntityTraitsClientTrait; use SymfonyComponentValidatorConstraints as Assert; /** * Client * * @ORMTable(name="client") * @ORMEntity(repositoryClass="AppRepositoryClientRepository") * @ORMHasLifecycleCallbacks */ class Client { use ClientTrait; /** * @var int * * @ORMColumn(name="id", type="integer") * @ORMId * @ORMGeneratedValue(strategy="AUTO") */ private $id; //... /** * @ORMOnetoMany(targetEntity=AccessLogRegion::class, mappedBy="client") */ private $logsRegions; public function __construct() { $this->logsRegions = new ArrayCollection(); } public function getLogsRegions() { return $this->logsRegions; } }
My .gitlab-ci.yml
image: jakzal/phpqa:php7.4 before_script: - composer install cache: paths: - vendor/ stages: - UnitTests phpunit: image: php:7.4-apache stage: UnitTests services: - name: mysql:5.7 alias: mysql variables: MYSQL_ROOT_PASSWORD: project MYSQL_DATABASE: project_test MYSQL_USER: root MYSQL_PASSWORD: project DATABASE_URL: 'mysql://root:project@mysql:3306/project_test' before_script: - apt-get update && apt-get install -y git libzip-dev - curl -sSk https://getcomposer.org/installer | php -- --disable-tls && mv composer.phar /usr/local/bin/composer - docker-php-ext-install mysqli pdo pdo_mysql zip - php bin/console doctrine:database:drop --force --env=test - php bin/console doctrine:database:create --env=test - php bin/console doctrine:schema:update --env=test --force script: - php bin/phpunit allow_failure: false
Complete gitlab error log :
$ php bin/console doctrine:database:drop –force –env=test Dropped database /tmp/test/test_db.sqlite for connection named default
$ php bin/console doctrine:database:create –env=test Created database /tmp/test/test_db.sqlite for connection named default $ php bin/console doctrine:schema:update –env=test –force
In AnnotationException.php line 39: [Semantical Error] The annotation “@DoctrineORMMappingOnetoMany” in prop erty AppEntityClient::$logsRegions was never imported . Did you maybe forget to add a “use” statement for this annotation?
doctrine:schema:update [–em EM] [–complete] [–dump-sql] [-f|–force] [-h|–help] [-q|–quiet] [-v|vv|vvv|–verbose] [-V|–version] [–ansi] [–no-ansi] [-n|–no-interaction] [-e|–env ENV] [–no-debug] [–]
Cleaning up file based variables
ERROR: Job failed: exit code 1
I don’t understand why it doesn’t work, any help is welcome 🙂
Advertisement
Answer
It seems that the problem is your annotation OnetoMany
is invalid because of the case, the proper spelling should be OneToMany
.
Try replacing it with :
/** * @ORMOneToMany(targetEntity=AccessLogRegion::class, mappedBy="client") */ private $logsRegions;