Code Duplication    Length = 16-21 lines in 3 locations

tests/unit/ControllerAnnotatorTest.php 1 location

@@ 56-71 (lines=16) @@
53
        $this->assertContains('@property string $SubTitle', $content);
54
    }
55
56
    public function testPageControllerGetsAnnotator()
57
    {
58
        $classInfo = new AnnotateClassInfo(AnnotatorPageTestController::class);
59
        $filePath = $classInfo->getClassFilePath();
60
61
        $content = $this->annotator->getGeneratedFileContent(
62
            file_get_contents($filePath),
63
            AnnotatorPageTestController::class
64
        );
65
66
        $this->assertContains(' * Class \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTestController', $content);
67
        $this->assertContains('@property \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest dataRecord', $content);
68
        $this->assertContains('@method \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest data()', $content);
69
        $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest', $content);
70
        $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\AnnotatorPageTest_Extension', $content);
71
    }
72
73
    /**
74
     * Test the generation of annotations for an Extension

tests/unit/DataObjectAnnotatorTest.php 2 locations

@@ 89-109 (lines=21) @@
86
        $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\Team_Extension', $content);
87
    }
88
89
    public function testInversePlayerRelationOfTeam()
90
    {
91
        $classInfo = new AnnotateClassInfo(Player::class);
92
        $filePath = $classInfo->getClassFilePath();
93
94
        $content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), Player::class);
95
96
        $this->assertContains('@property boolean $IsRetired', $content);
97
        $this->assertContains('@property string $ShirtNumber', $content);
98
        $this->assertContains('@property int $FavouriteTeamID', $content);
99
        $this->assertContains('@method \SilverLeague\IDEAnnotator\Tests\Team FavouriteTeam()', $content);
100
101
        $this->assertContains(
102
            '@method \SilverStripe\ORM\ManyManyList|\SilverLeague\IDEAnnotator\Tests\Team[] TeamPlayer()',
103
            $content
104
        );
105
        $this->assertContains(
106
            '@method \SilverStripe\ORM\ManyManyList|\SilverLeague\IDEAnnotator\Tests\Team[] TeamReserve()',
107
            $content
108
        );
109
    }
110
111
    public function testExistingMethodsWillNotBeTagged()
112
    {
@@ 139-157 (lines=19) @@
136
    /**
137
     * Test the generation of annotations for a DataExtension
138
     */
139
    public function testAnnotateDataExtension()
140
    {
141
        $classInfo = new AnnotateClassInfo(Team_Extension::class);
142
        $filePath = $classInfo->getClassFilePath();
143
        $original = file_get_contents($filePath);
144
        $annotated = $this->annotator->getGeneratedFileContent($original, Team_Extension::class);
145
146
        $this->assertContains(
147
            '@property \SilverLeague\IDEAnnotator\Tests\Team|\SilverLeague\IDEAnnotator\Tests\Team_Extension $owner',
148
            $annotated
149
        );
150
        $this->assertContains('@property string $ExtendedVarcharField', $annotated);
151
        $this->assertContains('@property int $ExtendedIntField', $annotated);
152
        $this->assertContains('@property int $ExtendedHasOneRelationshipID', $annotated);
153
        $this->assertContains(
154
            '@method \SilverLeague\IDEAnnotator\Tests\Player ExtendedHasOneRelationship()',
155
            $annotated
156
        );
157
    }
158
159
    /**
160
     *