/** * @return void */ protected function setUp() { /** @var StoreInterface $store */ $store = $this->getMockBuilder(StoreInterface::class)->getMock(); $config = (require __DIR__ . '/../../config/validation.php'); $this->errorRepository = new ErrorRepository(new Replacer()); $this->errorRepository->configure($config); $this->errorFactory = new ValidatorErrorFactory($this->errorRepository); $this->factory = new ValidatorFactory($this->errorFactory, $store); $this->store = $store; }
/** * @param $key * @param $id * @param $detail * @return $this */ private function willSee($key, $id, $detail = null) { $this->repository->configure([$key => [MutableErrorInterface::ID => $id, MutableErrorInterface::DETAIL => $detail]]); return $this; }
/** * Bind the error repository into the service container. */ protected function bindErrorRepository() { $this->app->singleton(ReplacerInterface::class, Replacer::class); $this->app->singleton(['json-api.errors' => ErrorRepositoryInterface::class], function () { /** @var ReplacerInterface $replacer */ $replacer = $this->app->make(ReplacerInterface::class); $repository = new ErrorRepository($replacer); $repository->configure($this->getErrorConfig()); return $repository; }); }