Exemple #1
0
 public function testGettersAndSetters()
 {
     $this->assertNull($this->translation->getId());
     $this->assertNull($this->translation->getKey());
     $this->assertNull($this->translation->getValue());
     $this->assertNull($this->translation->getLocale());
     $this->assertNull($this->translation->getDomain());
     $this->assertEquals(Translation::SCOPE_SYSTEM, $this->translation->getScope());
     $this->translation->setKey('test.key')->setValue('Test value')->setLocale('en')->setDomain('messages')->setScope(Translation::SCOPE_UI);
     $this->assertNull($this->translation->getId());
     $this->assertEquals('test.key', $this->translation->getKey());
     $this->assertEquals('Test value', $this->translation->getValue());
     $this->assertEquals('en', $this->translation->getLocale());
     $this->assertEquals('messages', $this->translation->getDomain());
     $this->assertEquals(Translation::SCOPE_UI, $this->translation->getScope());
 }
 public function testPersistUpdateScenario()
 {
     $testValue = 'some Value';
     $existsTranslation = new Translation();
     $existsTranslation->setValue($testValue);
     $this->repo->expects($this->any())->method('findValue')->will($this->returnValueMap([['key_1', $this->testLocale, 'messages', Translation::SCOPE_SYSTEM, null], ['key_2', $this->testLocale, 'messages', Translation::SCOPE_SYSTEM, null], ['key_3', $this->testLocale, 'messages', Translation::SCOPE_SYSTEM, null], ['key_1', $this->testLocale, 'validators', Translation::SCOPE_SYSTEM, $existsTranslation], ['key_2', $this->testLocale, 'validators', Translation::SCOPE_SYSTEM, null]]));
     $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');
     $this->em->expects($this->never())->method('rollback');
     $this->metadataCache->expects($this->once())->method('updateTimestamp')->with($this->testLocale);
     $this->persister->persist($this->testLocale, $this->testData);
     $this->assertSame($this->testData['validators']['key_1'], $existsTranslation->getValue());
     $this->assertNotSame($testValue, $existsTranslation->getValue());
 }