Code Duplication    Length = 15-16 lines in 2 locations

Tests/Repository/ContainerRepositoryFactoryTest.php 2 locations

@@ 98-112 (lines=15) @@
95
     * @expectedException \RuntimeException
96
     * @expectedExceptionMessage The "Doctrine\Bundle\DoctrineBundle\Tests\Repository\StubServiceRepository" entity repository implements "Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepositoryInterface", but its service could not be found. Make sure the service exists and is tagged with "doctrine.repository_service".
97
     */
98
    public function testRepositoryMatchesServiceInterfaceButServiceNotFound()
99
    {
100
        if (!interface_exists(ContainerInterface::class)) {
101
            $this->markTestSkipped('Symfony 3.3 is needed for this feature.');
102
        }
103
104
        $container = $this->createContainer([]);
105
106
        $em = $this->createEntityManager([
107
            'Foo\CoolEntity' => StubServiceRepository::class,
108
        ]);
109
110
        $factory = new ContainerRepositoryFactory($container);
111
        $factory->getRepository($em, 'Foo\CoolEntity');
112
    }
113
114
    /**
115
     * @expectedException \RuntimeException
@@ 118-133 (lines=16) @@
115
     * @expectedException \RuntimeException
116
     * @expectedExceptionMessage The "Foo\CoolEntity" entity has a repositoryClass set to "not_a_real_class", but this is not a valid class. Check your class naming. If this is meant to be a service id, make sure this service exists and is tagged with "doctrine.repository_service".
117
     */
118
    public function testCustomRepositoryIsNotAValidClass()
119
    {
120
        if (interface_exists(ContainerInterface::class)) {
121
            $container = $this->createContainer([]);
122
        } else {
123
            // Symfony 3.2 and lower support
124
            $container = null;
125
        }
126
127
        $em = $this->createEntityManager([
128
            'Foo\CoolEntity' => 'not_a_real_class',
129
        ]);
130
131
        $factory = new ContainerRepositoryFactory($container);
132
        $factory->getRepository($em, 'Foo\CoolEntity');
133
    }
134
135
    private function createContainer(array $services)
136
    {