/** * Method: getEandomTranslation * When: a translation is missing a key * Should: throw exception */ public function testGetRandomTranslationFileIsMissingAKeyThrowException() { /** @var vfsStreamDirectory $rootDir */ $rootDir = vfsStream::newDirectory('rootDir'); vfsStreamWrapper::setRoot($rootDir); /** @var vfsStreamFile $file */ $file = vfsStream::newFile(self::TEST_FILENAME); $file->open(); $file->write(self::TEST_MISSING_KEY_TRANSLATIONS_JSON); $rootDir->addChild($file); $this->setExpectedException('Exception', 'Error. Language file is not found or is invalid. File: vfs://rootDir/' . self::TEST_FILENAME); $translation = $this->sut->getRandomTranslation(vfsStream::url('rootDir' . DIRECTORY_SEPARATOR . self::TEST_FILENAME)); }
/** * Method: getStatusMessage * When: is called * Should: return randomTranslation correct method */ public function testGetStatusMessageIsCalledReturnRandomTranslationCorrectMethod() { $this->randomTranslationMock->getRandomTranslation(Argument::any())->shouldBeCalled()->willReturn('kaixo: hola'); $statusMessage = $this->sut->getStatusMessage(); $this->assertEquals('kaixo: hola', $statusMessage); }