public function testExceptionScenario() { $exceptionClass = '\\LogicException'; $this->setExpectedException($exceptionClass); $exception = new $exceptionClass(); $this->em->expects($this->once())->method('beginTransaction'); $this->em->expects($this->exactly(5))->method('persist'); $this->em->expects($this->exactly(3))->method('flush'); $this->em->expects($this->exactly(3))->method('clear'); $this->em->expects($this->once())->method('commit')->will($this->throwException($exception)); $this->em->expects($this->once())->method('rollback'); $this->metadataCache->expects($this->never())->method('updateTimestamp'); $this->persister->persist($this->testLocale, $this->testData); }
/** * Apply downloaded and extracted language packs to Symfony, in app/Resources dir * Returns applied locale codes * * @param string $locale * @param string $sourceDir */ protected function apply($locale, $sourceDir) { $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourceDir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); $catalog = new MessageCatalogue($locale); /** @var \SplFileInfo $fileInfo */ foreach ($iterator as $fileInfo) { if ($iterator->getDepth() < 1 || $fileInfo->isDir()) { continue; } // fix bad formatted yaml that may come from third-party service YamlFixer::fixStrings($fileInfo->getPathname()); } $this->translationLoader->loadMessages($sourceDir, $catalog); $this->databasePersister->persist($locale, $catalog->all()); }