/** * {@inheritdoc} */ public function getFileByHash($hash) { return FileQuery::create()->findOneByHash($hash, $this->getConnection()); }
/** * @group propel */ public function testPropelGetFor() { $manager = new FileManager($this->propelStorage, $this->rootDir); $total = FileQuery::create()->count(); $this->assertEquals(5, $total); // get an existing file $file = $manager->getFor('superTranslations.de.yml', '/test/root/dir/app/Resources/translations'); $file->save(); $total = FileQuery::create()->count(); $this->assertEquals(5, $total); // get a new file $file = $manager->getFor('superTranslations.it.yml', '/test/root/dir/app/Resources/translations'); $file->save(); $total = FileQuery::create()->count(); $this->assertEquals(6, $total); }
/** * @group orm */ public function testGetTranslationsForFile() { $con = $this->loadDatabase(); $repository = new TransUnitRepository($con); $file = FileQuery::create()->findOneByArray(array('Domain' => 'messages', 'Locale' => 'fr', 'Extention' => 'yml'), $con); $this->assertInstanceOf(self::PROPEL_FILE_CLASS, $file); $result = $repository->getTranslationsForFile($file, false); $expected = array('key.say_goodbye' => 'au revoir', 'key.say_wtf' => 'c\'est quoi ce bordel !?!'); $this->assertEquals($expected, $result); // update a translation and then get translations with onlyUpdated = true $now = new \DateTime('now'); $now->modify('+2 days'); TranslationQuery::create()->filterByLocale('fr')->filterByContent('au revoir')->update(array('UpdatedAt' => $now), $con, false); $result = $repository->getTranslationsForFile($file, true); $expected = array('key.say_goodbye' => 'au revoir'); $this->assertEquals($expected, $result); }