Skip to content

ImportFullyQualifiedNamesRector breaks Doctrine annotations : add a failing test case#2111

Closed
gnutix wants to merge 1 commit intorectorphp:masterfrom
gnutix:ImportFullyQualifiedNamesRector/add-test-case
Closed

ImportFullyQualifiedNamesRector breaks Doctrine annotations : add a failing test case#2111
gnutix wants to merge 1 commit intorectorphp:masterfrom
gnutix:ImportFullyQualifiedNamesRector/add-test-case

Conversation

@gnutix
Copy link
Copy Markdown
Contributor

@gnutix gnutix commented Oct 5, 2019

I've noticed two more errors when running ImportFullyQualifiedNamesRector on our codebase :

  1. inverseJoinColumns -> @ORM\JoinColumn -> name is modified to match the one in joinColumns -> @ORM\JoinColumn -> name (which is wrong : it should be different, as one is the "owner side" and the other the inverse side of the relationship, so both properties have different names : here template_id (owner) and area_id (inversed))
  2. The indentation is broken and the doc block's * characters are missing

Results in :

vendor/bin/phpunit packages/CodingStyle/tests/Rector/Namespace_/ImportFullyQualifiedNamesRector/ImportFullyQualifiedNamesRectorTest.php 
PHPUnit 7.5.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.3.9-1+ubuntu18.04.1+deb.sury.org+1
Configuration: /home/gnutix/dev/oss/rectorphp/rector/phpunit.xml

.......................F...                                       27 / 27 (100%)

Time: 1.43 seconds, Memory: 58.50MB

There was 1 failure:

1) Rector\CodingStyle\Tests\Rector\Namespace_\ImportFullyQualifiedNamesRector\ImportFullyQualifiedNamesRectorTest::test with data set #23 ('/home/gnutix/dev/oss/rectorph...hp.inc')
Caused by /home/gnutix/dev/oss/rectorphp/rector/packages/CodingStyle/tests/Rector/Namespace_/ImportFullyQualifiedNamesRector/Fixture/should_not_break_doctrine_inverse_join_columns_annotations.php.inc
Failed asserting that string matches format description.
--- Expected
+++ Actual
@@ @@
     private $id;
 
     /**
-     * @var Area[]|ArrayCollection
-     *
-     * @ORM\ManyToMany(targetEntity="Area", cascade={"remove", "persist"}, inversedBy="templates")
-     * @ORM\JoinTable(name="page_template_area",
-     *      joinColumns={@ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="CASCADE")},
-     *      inverseJoinColumns={@ORM\JoinColumn(name="area_id", referencedColumnName="id")}
-     * )
-     */
+    * @var Area[]|ArrayCollection
+    *
+    * @ORM\ManyToMany(targetEntity="Area", cascade={"remove", "persist"}, inversedBy="templates")
+    * @ORM\JoinTable(name="page_template_area", joinColumns={
+        @ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="CASCADE")
+    }, inverseJoinColumns={
+        @ORM\JoinColumn(name="template_id", referencedColumnName="id")
+    }
+    )
+    */
     private $areas;
 
     public function __construct()

/home/gnutix/dev/oss/rectorphp/rector/src/Testing/PHPUnit/AbstractRectorTestCase.php:182
/home/gnutix/dev/oss/rectorphp/rector/src/Testing/PHPUnit/AbstractRectorTestCase.php:136
/home/gnutix/dev/oss/rectorphp/rector/packages/CodingStyle/tests/Rector/Namespace_/ImportFullyQualifiedNamesRector/ImportFullyQualifiedNamesRectorTest.php:17

FAILURES!
Tests: 27, Assertions: 55, Failures: 1.

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented Oct 5, 2019

Thanks, I see it now:

 inverseJoinColumns={@ORM\JoinColumn(
-    name="area_id",
+    name="template_id", 
 referencedColumnName="id")

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented Oct 5, 2019

Surpassed by #2112

TomasVotruba added a commit that referenced this pull request Apr 21, 2022
rectorphp/rector-src@5f5b43a [DogFood] Failing fixture do not flip phpversion feature set after import (#2111)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants