Code Duplication    Length = 24-27 lines in 2 locations

Tests/DependencyInjection/AbstractDoctrineExtensionTest.php 1 location

@@ 1107-1133 (lines=27) @@
1104
    /**
1105
     * Assertion for the DI Container, check if the given definition contains a method call with the given parameters.
1106
     */
1107
    private function assertDICDefinitionMethodCallOnce(
1108
        Definition $definition,
1109
        string $methodName,
1110
        array $params = null
1111
    ) : void {
1112
        $calls  = $definition->getMethodCalls();
1113
        $called = false;
1114
        foreach ($calls as $call) {
1115
            if ($call[0] !== $methodName) {
1116
                continue;
1117
            }
1118
1119
            if ($called) {
1120
                $this->fail("Method '" . $methodName . "' is expected to be called only once, a second call was registered though.");
1121
            } else {
1122
                $called = true;
1123
                if ($params !== null) {
1124
                    $this->assertEquals($params, $call[1], "Expected parameters to methods '" . $methodName . "' do not match the actual parameters.");
1125
                }
1126
            }
1127
        }
1128
        if ($called) {
1129
            return;
1130
        }
1131
1132
        $this->fail("Method '" . $methodName . "' is expected to be called once, definition does not contain a call though.");
1133
    }
1134
1135
    private function assertDICDefinitionMethodCallCount(
1136
        Definition $definition,

Tests/DependencyInjection/DoctrineExtensionTest.php 1 location

@@ 865-888 (lines=24) @@
862
    /**
863
     * Assertion for the DI Container, check if the given definition contains a method call with the given parameters.
864
     */
865
    private function assertDICDefinitionMethodCallOnce(Definition $definition, string $methodName, array $params = null) : void
866
    {
867
        $calls  = $definition->getMethodCalls();
868
        $called = false;
869
        foreach ($calls as $call) {
870
            if ($call[0] !== $methodName) {
871
                continue;
872
            }
873
874
            if ($called) {
875
                $this->fail("Method '" . $methodName . "' is expected to be called only once, a second call was registered though.");
876
            } else {
877
                $called = true;
878
                if ($params !== null) {
879
                    $this->assertEquals($params, $call[1], "Expected parameters to methods '" . $methodName . "' do not match the actual parameters.");
880
                }
881
            }
882
        }
883
        if ($called) {
884
            return;
885
        }
886
887
        $this->fail("Method '" . $methodName . "' is expected to be called once, definition does not contain a call though.");
888
    }
889
890
    private function compileContainer(ContainerBuilder $container) : void
891
    {