Code Duplication    Length = 18-21 lines in 4 locations

test/RoaveTest/ComposerGpgVerify/VerifyTest.php 4 locations

@@ 363-380 (lines=18) @@
360
        $this->assertWillFailPackageVerification();
361
    }
362
363
    public function testWillRejectSignedTagsFromUnknownKey() : void
364
    {
365
        $personalGpgDirectory = $this->makeGpgHomeDirectory();
366
        $foreignGpgDirectory  = $this->makeGpgHomeDirectory();
367
        $vendorName  = 'Mr. Magoo';
368
        $vendorEmail = '[email protected]';
369
        $vendorKey   = $this->makeKey($foreignGpgDirectory, $vendorEmail, $vendorName);
370
        $vendorDir   = $this->makeVendorDirectory();
371
        $vendor1     = $this->makeDependencyGitRepository($vendorDir, 'vendor1/package1', $vendorEmail, $vendorName);
372
373
        $this->createDependencySignedTag($vendor1, $foreignGpgDirectory, $vendorKey);
374
375
        $this->configureCorrectComposerSetup();
376
377
        putenv('GNUPGHOME=' . $personalGpgDirectory);
378
379
        $this->assertWillFailPackageVerification();
380
    }
381
382
    public function testWillRejectSignedTagsFromNonHeadCommit() : void
383
    {
@@ 382-402 (lines=21) @@
379
        $this->assertWillFailPackageVerification();
380
    }
381
382
    public function testWillRejectSignedTagsFromNonHeadCommit() : void
383
    {
384
        $gpgHome     = $this->makeGpgHomeDirectory();
385
        $vendorName  = 'Mr. Magoo';
386
        $vendorEmail = '[email protected]';
387
        $vendorKey   = $this->makeKey($gpgHome, $vendorEmail, $vendorName);
388
        $vendorDir   = $this->makeVendorDirectory();
389
        $vendor1     = $this->makeDependencyGitRepository($vendorDir, 'vendor1/package1', $vendorEmail, $vendorName);
390
391
        $this->createDependencySignedTag($vendor1, $gpgHome, $vendorKey);
392
393
        (new Process('git commit --allow-empty -m "unsigned commit"', $vendor1))
394
            ->setTimeout(30)
395
            ->mustRun();
396
397
        $this->configureCorrectComposerSetup();
398
399
        putenv('GNUPGHOME=' . $gpgHome);
400
401
        $this->assertWillFailPackageVerification();
402
    }
403
404
    public function testWillOnlyConsiderTheHeadCommitForValidation() : void
405
    {
@@ 404-424 (lines=21) @@
401
        $this->assertWillFailPackageVerification();
402
    }
403
404
    public function testWillOnlyConsiderTheHeadCommitForValidation() : void
405
    {
406
        $gpgHome     = $this->makeGpgHomeDirectory();
407
        $vendorName  = 'Mr. Magoo';
408
        $vendorEmail = '[email protected]';
409
        $vendorKey   = $this->makeKey($gpgHome, $vendorEmail, $vendorName);
410
        $vendorDir   = $this->makeVendorDirectory();
411
        $vendor1     = $this->makeDependencyGitRepository($vendorDir, 'vendor1/package1', $vendorEmail, $vendorName);
412
413
        $this->signDependency($vendor1, $gpgHome, $vendorKey);
414
415
        (new Process('git commit --allow-empty -m "unsigned commit"', $vendor1))
416
            ->setTimeout(30)
417
            ->mustRun();
418
419
        $this->configureCorrectComposerSetup();
420
421
        putenv('GNUPGHOME=' . $gpgHome);
422
423
        $this->assertWillFailPackageVerification();
424
    }
425
426
    public function testWillRejectSignedCommitsFromUnknownKeys() : void
427
    {
@@ 426-444 (lines=19) @@
423
        $this->assertWillFailPackageVerification();
424
    }
425
426
    public function testWillRejectSignedCommitsFromUnknownKeys() : void
427
    {
428
        $personalGpgDirectory = $this->makeGpgHomeDirectory();
429
        $foreignGpgDirectory  = $this->makeGpgHomeDirectory();
430
431
        $vendorName  = 'Mr. Magoo';
432
        $vendorEmail = '[email protected]';
433
        $vendorKey   = $this->makeKey($foreignGpgDirectory, $vendorEmail, $vendorName);
434
        $vendorDir   = $this->makeVendorDirectory();
435
        $vendor1     = $this->makeDependencyGitRepository($vendorDir, 'vendor1/package1', $vendorEmail, $vendorName);
436
437
        $this->signDependency($vendor1, $foreignGpgDirectory, $vendorKey);
438
439
        $this->configureCorrectComposerSetup();
440
441
        putenv('GNUPGHOME=' . $personalGpgDirectory);
442
443
        $this->assertWillFailPackageVerification();
444
    }
445
446
    private function makeVendorDirectory() : string
447
    {