Code Duplication    Length = 24-28 lines in 3 locations

test/phpunit/tests/EntryNameResolverChainFunctionalTest.php 3 locations

@@ 33-58 (lines=26) @@
30
     * @throws \Interop\Container\Exception\NotFoundException
31
     * @throws \Interop\Container\Exception\ContainerException
32
     */
33
    public function testInvalidEntryNameResolverChainConfig()
34
    {
35
        /** @noinspection PhpIncludeInspection */
36
        $this->setApplicationConfig(
37
            include TestPaths::getPathToDefaultAppConfig()
38
        );
39
40
        /** @var EntryNameResolverManagerInterface $entryNameResolverManager */
41
        $entryNameResolverManager = $this->getApplicationServiceLocator()->get(EntryNameResolverManagerInterface::class);
42
43
        $e = null;
44
        try {
45
            $entryNameResolverManager->get(EntryNameResolverChain::class, [
46
                'resolvers' => [
47
                    'invalidEntryNameResolver'
48
                ]
49
            ]);
50
        } catch (\Exception $ex) {
51
            $e = $ex;
52
        }
53
54
        static::assertInstanceOf(\Exception::class, $e);
55
        $prevException = $e->getPrevious();
56
        static::assertInstanceOf(RuntimeException::class, $prevException);
57
        static::assertEquals('Entry name resolver config is not array', $prevException->getMessage());
58
    }
59
60
    /**
61
     * Проверка получения резолвера с конфигом, в котором в описание вложенного резолвера не указано имя.
@@ 69-96 (lines=28) @@
66
     * @throws \Interop\Container\Exception\NotFoundException
67
     * @throws \Interop\Container\Exception\ContainerException
68
     */
69
    public function testNestedResolverInvalidName()
70
    {
71
        /** @noinspection PhpIncludeInspection */
72
        $this->setApplicationConfig(
73
            include TestPaths::getPathToDefaultAppConfig()
74
        );
75
76
        /** @var EntryNameResolverManagerInterface $entryNameResolverManager */
77
        $entryNameResolverManager = $this->getApplicationServiceLocator()->get(EntryNameResolverManagerInterface::class);
78
79
        $e = null;
80
        try {
81
            $entryNameResolverManager->get(EntryNameResolverChain::class, [
82
                'resolvers' => [
83
                    [
84
85
                    ]
86
                ]
87
            ]);
88
        } catch (\Exception $ex) {
89
            $e = $ex;
90
        }
91
92
        static::assertInstanceOf(\Exception::class, $e);
93
        $prevException = $e->getPrevious();
94
        static::assertInstanceOf(RuntimeException::class, $prevException);
95
        static::assertEquals('Resolver entry name not found', $prevException->getMessage());
96
    }
97
98
    /**
99
     * Проверка получения резолвера с конфигом, в котором в опции вложенного резолвера описаны не строкой
@@ 427-450 (lines=24) @@
424
     * @throws \Interop\Container\Exception\NotFoundException
425
     * @throws \Interop\Container\Exception\ContainerException
426
     */
427
    public function testInvalidEntryNameResolverChainClassName()
428
    {
429
        /** @noinspection PhpIncludeInspection */
430
        $this->setApplicationConfig(
431
            include TestPaths::getPathToDefaultAppConfig()
432
        );
433
434
        /** @var EntryNameResolverManagerInterface $entryNameResolverManager */
435
        $entryNameResolverManager = $this->getApplicationServiceLocator()->get(EntryNameResolverManagerInterface::class);
436
437
        $e = null;
438
        try {
439
            $entryNameResolverManager->get(EntryNameResolverChain::class, [
440
                'className' => \stdClass::class
441
            ]);
442
        } catch (\Exception $ex) {
443
            $e = $ex;
444
        }
445
446
        static::assertInstanceOf(\Exception::class, $e);
447
        $prevException = $e->getPrevious();
448
        static::assertInstanceOf(RuntimeException::class, $prevException);
449
        static::assertEquals('EntryNameResolverChain not implements: Nnx\EntryNameResolver\EntryNameResolverChain', $prevException->getMessage());
450
    }
451
}
452