Code Duplication    Length = 27-27 lines in 3 locations

tests/MetadataManagerTest.php 3 locations

@@ 486-512 (lines=27) @@
483
        $this->assertEquals('BorkBorkBorken', $result->getReturnType()[0]->getEntitySetAttribute());
484
    }
485
486
    public function testCreateSingletonWithDocumentation()
487
    {
488
        $msg = null;
489
        $name = 'singleton';
490
        $shortDesc = new TTextType();
491
        $longDesc = new TTextType();
492
493
        $returnType = m::mock(TEntityTypeType::class)->makePartial();
494
        $returnType->shouldReceive('getName')->andReturn('doubleton');
495
496
        $entityContainer = m::mock(EntityContainer::class)->makePartial();
497
        $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once();
498
499
        $schema = m::mock(Schema::class)->makePartial();
500
        $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once();
501
        $edmx = m::mock(Edmx::class)->makePartial();
502
        $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once();
503
504
        $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods();
505
        $foo->shouldReceive('getEdmx')->andReturn($edmx);
506
        $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1);
507
508
        $result = $foo->createSingleton($name, $returnType, null, $shortDesc, $longDesc);
509
        $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result));
510
        $this->assertTrue($result->isOK($msg));
511
        $this->assertNotNull($result->getDocumentation());
512
    }
513
514
    public function testCreateSingletonWithDocumentationOnlyShortDesc()
515
    {
@@ 514-540 (lines=27) @@
511
        $this->assertNotNull($result->getDocumentation());
512
    }
513
514
    public function testCreateSingletonWithDocumentationOnlyShortDesc()
515
    {
516
        $msg = null;
517
        $name = 'singleton';
518
        $shortDesc = new TTextType();
519
        $longDesc = null;
520
521
        $returnType = m::mock(TEntityTypeType::class)->makePartial();
522
        $returnType->shouldReceive('getName')->andReturn('doubleton');
523
524
        $entityContainer = m::mock(EntityContainer::class)->makePartial();
525
        $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once();
526
527
        $schema = m::mock(Schema::class)->makePartial();
528
        $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once();
529
        $edmx = m::mock(Edmx::class)->makePartial();
530
        $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once();
531
532
        $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods();
533
        $foo->shouldReceive('getEdmx')->andReturn($edmx);
534
        $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1);
535
536
        $result = $foo->createSingleton($name, $returnType, null, $shortDesc, $longDesc);
537
        $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result));
538
        $this->assertTrue($result->isOK($msg));
539
        $this->assertNull($result->getDocumentation());
540
    }
541
542
    public function testCreateSingletonWithDocumentationOnlyLongDesc()
543
    {
@@ 542-568 (lines=27) @@
539
        $this->assertNull($result->getDocumentation());
540
    }
541
542
    public function testCreateSingletonWithDocumentationOnlyLongDesc()
543
    {
544
        $msg = null;
545
        $name = 'singleton';
546
        $shortDesc = null;
547
        $longDesc = new TTextType();
548
549
        $returnType = m::mock(TEntityTypeType::class)->makePartial();
550
        $returnType->shouldReceive('getName')->andReturn('doubleton');
551
552
        $entityContainer = m::mock(EntityContainer::class)->makePartial();
553
        $entityContainer->shouldReceive('addToFunctionImport')->andReturn(null)->once();
554
555
        $schema = m::mock(Schema::class)->makePartial();
556
        $schema->shouldReceive('getEntityContainer')->andReturn([$entityContainer])->once();
557
        $edmx = m::mock(Edmx::class)->makePartial();
558
        $edmx->shouldReceive('getDataServiceType->getSchema')->andReturn([$schema])->once();
559
560
        $foo = m::mock(MetadataManager::class)->makePartial()->shouldAllowMockingProtectedMethods();
561
        $foo->shouldReceive('getEdmx')->andReturn($edmx);
562
        $foo->shouldReceive('getNamespace')->andReturn('Data')->atLeast(1);
563
564
        $result = $foo->createSingleton($name, $returnType, $shortDesc, $longDesc);
565
        $this->assertTrue($result instanceof EntityContainer\FunctionImportAnonymousType, get_class($result));
566
        $this->assertTrue($result->isOK($msg));
567
        $this->assertNull($result->getDocumentation());
568
    }
569
570
    public function testMalformedMultiplicity()
571
    {