Definition::removeMethodCall should remove all matching calls
It would only remove the first match, leaving the other method call(s) there to exist. This leads to unexpected situations.
This commit is contained in:
parent
4a32fd0446
commit
944ba23b58
@ -392,7 +392,6 @@ class Definition
|
||||
foreach ($this->calls as $i => $call) {
|
||||
if ($call[0] === $method) {
|
||||
unset($this->calls[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,4 +425,20 @@ class DefinitionTest extends TestCase
|
||||
$def->addError('Second error');
|
||||
$this->assertSame(['First error', 'Second error'], $def->getErrors());
|
||||
}
|
||||
|
||||
public function testMultipleMethodCalls()
|
||||
{
|
||||
$def = new Definition('stdClass');
|
||||
|
||||
$def->addMethodCall('configure', ['arg1']);
|
||||
$this->assertTrue($def->hasMethodCall('configure'));
|
||||
$this->assertCount(1, $def->getMethodCalls());
|
||||
|
||||
$def->addMethodCall('configure', ['arg2']);
|
||||
$this->assertTrue($def->hasMethodCall('configure'));
|
||||
$this->assertCount(2, $def->getMethodCalls());
|
||||
|
||||
$def->removeMethodCall('configure');
|
||||
$this->assertFalse($def->hasMethodCall('configure'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user