Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Translation/Handlers/TranslatableEntityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public function translate(TranslationArgs $args)

$clone->setLocale($args->getTargetLocale());

$this->em->persist($clone);

return $clone;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TranslatableManyToManyBidirectionalParent implements TranslatableInterface
*
* @ORM\ManyToMany(
* targetEntity="AppTestBundle\Entity\Translatable\TranslatableManyToManyBidirectionalChild",
* cascade={"persist"},
* mappedBy="simpleParents"
* )
*/
Expand All @@ -39,6 +40,7 @@ class TranslatableManyToManyBidirectionalParent implements TranslatableInterface
*
* @ORM\ManyToMany(
* targetEntity="AppTestBundle\Entity\Translatable\TranslatableManyToManyBidirectionalChild",
* cascade={"persist"},
* mappedBy="emptyParents"
* )
* @ORM\JoinTable(name="empty_translatablemanytomanybidirectionalchild_translatablemanytomanybidirectionalparent")
Expand Down
2 changes: 2 additions & 0 deletions tests/ScalarTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function it_can_translate_scalar_value()
{
$entity = $this->createEntity();
$translation = $this->translator->translate($entity, 'fr');
$this->em->persist($translation);
$this->em->flush();
$this->assertAttributeContains('Test title', 'title', $translation);
$this->assertIsTranslation($entity, $translation);
Expand Down Expand Up @@ -48,6 +49,7 @@ public function it_can_empty_scalar_value_on_translate()
$entity = $this->createEntity();
$translation = $this->translator->translate($entity, 'fr');

$this->em->persist($translation);
$this->em->flush();
$this->assertAttributeEmpty('empty', $translation);
$this->assertIsTranslation($entity, $translation);
Expand Down
3 changes: 3 additions & 0 deletions tests/TranslatableManyToOneEntityTranslationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function it_can_translate_simple_value()
/** @var TranslatableManyToOne $translation */
$translation = $this->translator->translate($entity, self::TARGET_LOCALE);

$this->em->persist($translation);
$this->em->flush();
$this->assertNotEquals($associatedEntity, $translation->getSimple());
$this->assertAttributeContains(self::TARGET_LOCALE, 'locale', $translation->getSimple());
Expand All @@ -41,6 +42,7 @@ public function it_must_associate_existing_translation()
$this->em->persist($associatedEntity);

$translatedAssociatedEntity = $this->translator->translate($associatedEntity, self::TARGET_LOCALE);
$this->em->persist($translatedAssociatedEntity);

$entity =
(new TranslatableManyToOne())
Expand All @@ -52,6 +54,7 @@ public function it_must_associate_existing_translation()
/** @var TranslatableManyToOne $translation */
$translation = $this->translator->translate($entity, self::TARGET_LOCALE);

$this->em->persist($translation);
$this->em->flush();
$this->assertNotEquals($associatedEntity, $translation->getSimple());
$this->assertEquals($translatedAssociatedEntity, $translation->getSimple());
Expand Down
1 change: 1 addition & 0 deletions tests/TranslatableOneToOneUnidirectionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function it_can_translate_simple_value()
/** @var TranslatableOneToOneUnidirectional $translation */
$translation = $this->translator->translate($entity, self::TARGET_LOCALE);

$this->em->persist($translation);
$this->em->flush();
$this->assertNotEquals($associatedEntity, $translation->getSimple());
$this->assertAttributeContains(self::TARGET_LOCALE, 'locale', $translation->getSimple());
Expand Down