| @@ 755-774 (lines=20) @@ | ||
| 752 | * @param string $methodName |
|
| 753 | * @param array|null $params |
|
| 754 | */ |
|
| 755 | private function assertDICDefinitionMethodCallOnce(Definition $definition, $methodName, array $params = null) |
|
| 756 | { |
|
| 757 | $calls = $definition->getMethodCalls(); |
|
| 758 | $called = false; |
|
| 759 | foreach ($calls as $call) { |
|
| 760 | if ($call[0] === $methodName) { |
|
| 761 | if ($called) { |
|
| 762 | $this->fail("Method '".$methodName."' is expected to be called only once, a second call was registered though."); |
|
| 763 | } else { |
|
| 764 | $called = true; |
|
| 765 | if ($params !== null) { |
|
| 766 | $this->assertEquals($params, $call[1], "Expected parameters to methods '".$methodName."' do not match the actual parameters."); |
|
| 767 | } |
|
| 768 | } |
|
| 769 | } |
|
| 770 | } |
|
| 771 | if (!$called) { |
|
| 772 | $this->fail("Method '".$methodName."' is expected to be called once, definition does not contain a call though."); |
|
| 773 | } |
|
| 774 | } |
|
| 775 | ||
| 776 | private function compileContainer(ContainerBuilder $container) |
|
| 777 | { |
|
| @@ 1020-1039 (lines=20) @@ | ||
| 1017 | * @param string $methodName |
|
| 1018 | * @param array $params |
|
| 1019 | */ |
|
| 1020 | private function assertDICDefinitionMethodCallOnce(Definition $definition, $methodName, array $params = null) |
|
| 1021 | { |
|
| 1022 | $calls = $definition->getMethodCalls(); |
|
| 1023 | $called = false; |
|
| 1024 | foreach ($calls as $call) { |
|
| 1025 | if ($call[0] == $methodName) { |
|
| 1026 | if ($called) { |
|
| 1027 | $this->fail("Method '".$methodName."' is expected to be called only once, a second call was registered though."); |
|
| 1028 | } else { |
|
| 1029 | $called = true; |
|
| 1030 | if ($params !== null) { |
|
| 1031 | $this->assertEquals($params, $call[1], "Expected parameters to methods '".$methodName."' do not match the actual parameters."); |
|
| 1032 | } |
|
| 1033 | } |
|
| 1034 | } |
|
| 1035 | } |
|
| 1036 | if (!$called) { |
|
| 1037 | $this->fail("Method '".$methodName."' is expected to be called once, definition does not contain a call though."); |
|
| 1038 | } |
|
| 1039 | } |
|
| 1040 | ||
| 1041 | private function assertDICDefinitionMethodCallCount(Definition $definition, $methodName, array $params = array(), $nbCalls = 1) |
|
| 1042 | { |
|