Code Duplication    Length = 20-20 lines in 2 locations

Tests/DependencyInjection/DoctrineExtensionTest.php 1 location

@@ 731-750 (lines=20) @@
728
     * @param string     $methodName
729
     * @param array|null $params
730
     */
731
    private function assertDICDefinitionMethodCallOnce(Definition $definition, $methodName, array $params = null)
732
    {
733
        $calls = $definition->getMethodCalls();
734
        $called = false;
735
        foreach ($calls as $call) {
736
            if ($call[0] === $methodName) {
737
                if ($called) {
738
                    $this->fail("Method '".$methodName."' is expected to be called only once, a second call was registered though.");
739
                } else {
740
                    $called = true;
741
                    if ($params !== null) {
742
                        $this->assertEquals($params, $call[1], "Expected parameters to methods '".$methodName."' do not match the actual parameters.");
743
                    }
744
                }
745
            }
746
        }
747
        if (!$called) {
748
            $this->fail("Method '".$methodName."' is expected to be called once, definition does not contain a call though.");
749
        }
750
    }
751
752
    private function compileContainer(ContainerBuilder $container)
753
    {

Tests/DependencyInjection/AbstractDoctrineExtensionTest.php 1 location

@@ 995-1014 (lines=20) @@
992
     * @param string     $methodName
993
     * @param array      $params
994
     */
995
    private function assertDICDefinitionMethodCallOnce(Definition $definition, $methodName, array $params = null)
996
    {
997
        $calls = $definition->getMethodCalls();
998
        $called = false;
999
        foreach ($calls as $call) {
1000
            if ($call[0] == $methodName) {
1001
                if ($called) {
1002
                    $this->fail("Method '".$methodName."' is expected to be called only once, a second call was registered though.");
1003
                } else {
1004
                    $called = true;
1005
                    if ($params !== null) {
1006
                        $this->assertEquals($params, $call[1], "Expected parameters to methods '".$methodName."' do not match the actual parameters.");
1007
                    }
1008
                }
1009
            }
1010
        }
1011
        if (!$called) {
1012
            $this->fail("Method '".$methodName."' is expected to be called once, definition does not contain a call though.");
1013
        }
1014
    }
1015
1016
    private function assertDICDefinitionMethodCallCount(Definition $definition, $methodName, array $params = array(), $nbCalls = 1)
1017
    {