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

@@ 155-175 (lines=21) @@
152
        $this->assertContains('@mixin \SilverLeague\IDEAnnotator\Tests\Team_Extension', $content);
153
    }
154
155
    public function testInversePlayerRelationOfTeam()
156
    {
157
        $classInfo = new AnnotateClassInfo(Player::class);
158
        $filePath = $classInfo->getClassFilePath();
159
160
        $content = $this->annotator->getGeneratedFileContent(file_get_contents($filePath), Player::class);
161
162
        $this->assertContains('@property boolean $IsRetired', $content);
163
        $this->assertContains('@property string $ShirtNumber', $content);
164
        $this->assertContains('@property int $FavouriteTeamID', $content);
165
        $this->assertContains('@method \SilverLeague\IDEAnnotator\Tests\Team FavouriteTeam()', $content);
166
167
        $this->assertContains(
168
            '@method \SilverStripe\ORM\ManyManyList|\SilverLeague\IDEAnnotator\Tests\Team[] TeamPlayer()',
169
            $content
170
        );
171
        $this->assertContains(
172
            '@method \SilverStripe\ORM\ManyManyList|\SilverLeague\IDEAnnotator\Tests\Team[] TeamReserve()',
173
            $content
174
        );
175
    }
176
177
    public function testExistingMethodsWillNotBeTagged()
178
    {
@@ 216-234 (lines=19) @@
213
    /**
214
     * Test the generation of annotations for a DataExtension
215
     */
216
    public function testAnnotateDataExtension()
217
    {
218
        $classInfo = new AnnotateClassInfo(Team_Extension::class);
219
        $filePath = $classInfo->getClassFilePath();
220
        $original = file_get_contents($filePath);
221
        $annotated = $this->annotator->getGeneratedFileContent($original, Team_Extension::class);
222
223
        $this->assertContains(
224
            '@property \SilverLeague\IDEAnnotator\Tests\Team|\SilverLeague\IDEAnnotator\Tests\Team_Extension $owner',
225
            $annotated
226
        );
227
        $this->assertContains('@property string $ExtendedVarcharField', $annotated);
228
        $this->assertContains('@property int $ExtendedIntField', $annotated);
229
        $this->assertContains('@property int $ExtendedHasOneRelationshipID', $annotated);
230
        $this->assertContains(
231
            '@method \SilverLeague\IDEAnnotator\Tests\Player ExtendedHasOneRelationship()',
232
            $annotated
233
        );
234
    }
235
236
    /**
237
     *