Code Duplication    Length = 32-33 lines in 2 locations

tests/VersionsCheckTest.php 2 locations

@@ 107-139 (lines=33) @@
104
     * @param bool $preferStable
105
     * @param int  $outdatedPackagesCount
106
     */
107
    public function testMultiplePackagesComparison(array $packagesData, $preferStable, $outdatedPackagesCount)
108
    {
109
        $this->rootPackage->setMinimumStability('dev');
110
        $this->rootPackage->setPreferStable($preferStable);
111
112
        $shouldBeUpdatedOutput = array();
113
114
        foreach ($packagesData as $name => $packageData) {
115
            list($actualVersion, $availableVersions, $expectedVersion) = $packageData;
116
            $this->localRepository->addPackage(new Package($name, $actualVersion, $actualVersion));
117
            foreach ($availableVersions as $availableVersion) {
118
                $this->distRepository->addPackage(new Package($name, $availableVersion, $availableVersion));
119
            }
120
121
            if (false !== $expectedVersion) {
122
                $shouldBeUpdatedOutput[] = sprintf(
123
                    '  - <info>%s</info> (<comment>%s</comment>) latest is <comment>%s</comment>',
124
                    $name, $actualVersion, $expectedVersion
125
                );
126
            }
127
        }
128
129
        $this->checkPackages();
130
131
        $this->assertSame(sprintf(<<<'EOF'
132
<warning>%d packages are not up to date:</warning>
133
134
%s
135
136
137
EOF
138
        , $outdatedPackagesCount, implode("\n\n", $shouldBeUpdatedOutput)), $this->versionsCheck->getOutput());
139
    }
140
141
    /**
142
     * @return array
@@ 208-239 (lines=32) @@
205
    /**
206
     * @dataProvider getRootOnlyPackageTestsData
207
     */
208
    public function testRootOnlyPackage(array $packagesData, array $packagesRequired, array $packagesDevRequired, $rootOnly, $outdatedPackagesCount)
209
    {
210
211
        foreach ($packagesData as $name => $packageData) {
212
            list($actualVersion, $availableVersions, $expectedVersion) = $packageData;
213
            $this->localRepository->addPackage(new Package($name, $actualVersion, $actualVersion));
214
            foreach ($availableVersions as $availableVersion) {
215
                $this->distRepository->addPackage(new Package($name, $availableVersion, $availableVersion));
216
            }
217
218
            if (false !== $expectedVersion) {
219
                $shouldBeUpdatedOutput[] = sprintf(
220
                    '  - <info>%s</info> (<comment>%s</comment>) latest is <comment>%s</comment>',
221
                    $name, $actualVersion, $expectedVersion
222
                );
223
            }
224
        }
225
226
        $this->rootPackage->setRequires($packagesRequired);
227
        $this->rootPackage->setDevRequires($packagesDevRequired);
228
229
        $this->checkPackages($rootOnly);
230
231
        $this->assertSame(sprintf(<<<'EOF'
232
<warning>%d packages are not up to date:</warning>
233
234
%s
235
236
237
EOF
238
            , $outdatedPackagesCount, implode("\n\n", $shouldBeUpdatedOutput)), $this->versionsCheck->getOutput());
239
    }
240
241
    /**
242
     * @return array