Skip to content

Commit

Permalink
Merge pull request #24 from tomaszdurka/issue-24
Browse files Browse the repository at this point in the history
Do not recreate mock methods when mocking again
  • Loading branch information
tomaszdurka committed Apr 23, 2015
2 parents 960b38c + 3a883cb commit e084c49
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/Mocka/MethodMockCollection.php
Expand Up @@ -7,13 +7,21 @@ class MethodMockCollection {
/** @var MethodMock[] */
private $_mockedMethods = array();

public function __clone() {
foreach ($this->_mockedMethods as $name => $method) {
$this->_mockedMethods[$name] = clone $method;
}
}

/**
* @param string $name
* @return MethodMock
*/
public function mockMethod($name) {
$name = (string) $name;
$this->_mockedMethods[$name] = new MethodMock();
if (!isset($this->_mockedMethods[$name])) {
$this->_mockedMethods[$name] = new MethodMock();
}
return $this->_mockedMethods[$name];
}

Expand Down

0 comments on commit e084c49

Please sign in to comment.