{"record":{"id":"22d05bc10222f27b","repo":"sebastianbergmann/phpunit","slug":"not-enough-parameter-sets-configured-only-d-para","errorCode":null,"errorMessage":"Not enough parameter sets configured, only %d parameter sets given for %s::%s()","messagePattern":"Not enough parameter sets configured, only (.+?) parameter sets given for (.+?)::(.+?)\\(\\)","errorType":"exception","errorClass":"NoMoreParameterSetsConfiguredException","httpStatus":null,"severity":"error","filePath":"src/Framework/MockObject/Runtime/Rule/OrderedParameterSets.php","lineNumber":61,"sourceCode":"        foreach ($stack as $parameters) {\n            if (!$parameters instanceof IndexedParameters) {\n                if (is_array($parameters)) {\n                    $parameters = new Parameters($parameters);\n                } else {\n                    $parameters = new Parameters([$parameters]);\n                }\n            }\n\n            $this->stack[] = $parameters;\n        }\n\n        $this->numberOfConfiguredParameterSets = count($stack);\n    }\n\n    public function apply(BaseInvocation $invocation): void\n    {\n        if ($this->stack === []) {\n            throw new NoMoreParameterSetsConfiguredException(\n                $invocation,\n                $this->numberOfConfiguredParameterSets,\n            );\n        }\n\n        $parameters      = array_shift($this->stack);\n        $this->applied[] = $parameters;\n\n        $parameters->apply($invocation);\n    }\n\n    /**\n     * Checks if the invocation $invocation matches the current rules. If it\n     * does the rule will get the invoked() method called which should check\n     * if an expectation is met.\n     *\n     * @throws ExpectationFailedException\n     */","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/sebastianbergmann/phpunit/blob/f123cdb2a2d49f15025794166cfed8bda8627dd2/src/Framework/MockObject/Runtime/Rule/OrderedParameterSets.php#L43-L79","documentation":"Thrown during test execution when a mocked method configured with withParameterSetsInOrder(...) receives more calls than you configured parameter sets for. OrderedParameterSets::apply() pops one parameter set per invocation; once the stack is empty, the next invocation raises NoMoreParameterSetsConfiguredException naming the class::method that ran out. The old withConsecutive() API of PHPUnit 9 produced the same class of failure.","triggerScenarios":"$mock->expects($this->any())->method('push')->withParameterSetsInOrder([1], [2]) while the code under test calls push() a third time. The exception escapes from the third $mock->push(...) call itself, so the failure points at the call site in the code under test.","commonSituations":"Loops or batch processors that iterate more items than the two or three parameter sets written in the test; a retry adding an extra call; an event listener invoked per entity; leftover withConsecutive() tests migrated to PHPUnit 10/11 where the new withParameterSetsInOrder() replaces it; fixtures growing without updating the configured sets.","solutions":["Identify the extra call from the exception message (it names Class::method) and the stack trace at the mocked call site.","Add parameter sets for every legitimate invocation: withParameterSetsInOrder([...set1], [...set2], [...set3]).","If the number of calls varies, replace the strict ordered sets with withParameterSetsInAnyOrder() plus expects($this->exactly(n)), or match arguments per-call with a willReturnCallback()/Callback constraint.","Make the fixture smaller or deterministic so the call count is known and each call gets a set.","If extra calls are a production bug (duplicate processing), fix the calling code instead of the test."],"exampleFix":"// before\n$queue->expects($this->any())->method('push')\n    ->withParameterSetsInOrder(['a'], ['b']);\nforeach (['a', 'b', 'c'] as $job) { $queue->push($job); } // third call has no set\n\n// after: one set per expected call\n$queue->expects($this->exactly(3))->method('push')\n    ->withParameterSetsInOrder(['a'], ['b'], ['c']);","handlingStrategy":"try-catch","validationCode":"// Before relying on ordered parameter sets, make the call count deterministic:\n// a fixed fixture plus expects(exactly(n)) guarantees every call has a set.\n$items = ['a', 'b'];\n$mock->expects($this->exactly(count($items)))->method('push')\n    ->withParameterSetsInOrder(['a'], ['b']);","typeGuard":null,"tryCatchPattern":"// NoMoreParameterSetsConfiguredException escapes the mocked call itself;\n// catch it only to convert it into a clearer failure:\nuse PHPUnit\\Framework\\MockObject\\NoMoreParameterSetsConfiguredException;\ntry {\n    $sut->import($rows);\n} catch (NoMoreParameterSetsConfiguredException $e) {\n    self::fail('More calls than configured parameter sets: ' . $e->getMessage());\n}","preventionTips":["Configure exactly one parameter set per expected invocation and pin the count with expects(exactly(n)).","Derive fixtures with a fixed size so the number of sets is stable.","Migrate withConsecutive() tests by mapping each historical array argument to one parameter set — none left behind.","For variable call counts, prefer argument-capturing callbacks over ordered sets."],"tags":["phpunit","mock","parameter-sets","consecutive-calls"],"backgroundTag":"mock-parameter-set-mismatch","analyzedSha":"f123cdb2a2d49f15025794166cfed8bda8627dd2","analyzedAt":"2026-08-23T01:20:58.058Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}