/** * @param string $name * @param ApiManager $manager * @param integer $code * @param Exception $previous */ public function __construct($name, ApiManager $manager, $code = null, Exception $previous = null) { $this->manager = $manager; $this->name = $name; $message = sprintf('No API defined with name "%s".', $name); $suggestions = $manager->getNames(); if (!empty($suggestions)) { $imploded = implode('", "', $suggestions); $message .= sprintf(' Did you mean "%s"?', $imploded); } parent::__construct($message, $code, $previous); }
public function testGetNames() { $api = Mockery::mock('PhpTest\\Api\\ApiInterface'); $manager = new ApiManager(['foo' => $api]); $this->assertSame(['foo'], $manager->getNames()); }