/** * Create an instance of given validator. * * @param string $validatorName * @param array $arguments * * @return ValidatorInterface * * @throws ClassNotFoundException * @throws InvalidValidatorException */ public function createInstance($validatorName, $arguments) { $validatorClassName = $this->getFullClassName($validatorName); if (!$this->assertIfClassExists($validatorClassName)) { throw new ClassNotFoundException(sprintf($this->translator->get('class_not_found'), $validatorName)); } $instance = $this->createValidatorInstance($validatorClassName, $arguments); if (!$instance instanceof ValidatorInterface) { throw new InvalidValidatorException(sprintf($this->translator->get('invalid_validator'), $validatorName)); } $instance->setMessages($this->translator->get($validatorName)); return $instance; }
/** * Ensure that a loaded language file will not be loaded again * * @return void */ public function testAlreadyLoadedFileWillNotBeLoadedTwice() { $this->translator->load(); $this->assertArrayHasKey('test_message', $this->translator->all()); $this->translator->load(); $this->assertTrue($this->translator->hasBeenLoaded('en')); }
/** * Set the application translation instance. * * @param $translator */ public function setTranslationInstance($translator) { if (is_null($translator)) { $this->translator = new Translator(__DIR__ . '/lang/'); } else { $this->translator = $translator; } $this->translator->load(); }
/** * Setup test environment */ public function setUp() { $this->translator = m::mock('Sparta\\Translator'); $this->translator->shouldReceive('load'); $this->translator->shouldReceive('get')->atLeast(1); }