/** * Registers the function to be mocked and sets up its expectations * * @param string $function * @param array $arguments * * @throws \Exception If the function name is invalid */ public function register($function, $arguments) { try { $this->generate_function($function); if (empty($this->mocked_functions[$function])) { $this->mocked_functions[$function] = Mockery::mock('wp_api'); } $mock = $this->mocked_functions[$function]; $method = preg_replace('/\\\\+/', '_', $function); $this->set_up_mock($mock, $method, $arguments); Handler::register_handler($function, array($mock, $method)); } catch (\Exception $e) { throw $e; } }