Skip to content

Commit

Permalink
Minor improvements to MockContainerTrait. (vufind-org#3764)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Jun 7, 2024
1 parent 7b4320b commit f0db4d7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion module/VuFind/src/VuFindTest/Container/MockContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ public function createMock($id, $methods = [])
if ($methods) {
$builder->onlyMethods($methods);
}
return $builder->getMock();
try {
return $builder->getMock();
} catch (\Throwable $e) {
throw new \Exception("Cannot mock service $id", $e->getCode(), $e);
}
}

/**
Expand Down Expand Up @@ -164,4 +168,18 @@ public function set($id, $obj)
$this->mockServices[$id] = $obj;
return $this;
}

/**
* Add an alias.
*
* @param string $alias Alias of the service.
* @param string $target Target service.
*
* @return object
*/
public function setAlias($alias, $target)
{
$this->mockAliases[$alias] = $target;
return $this;
}
}

0 comments on commit f0db4d7

Please sign in to comment.