1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
<?php
namespace Gettext\Tests;
use Gettext\Translations;
use Gettext\Merge;
class MergeEntriesTest extends AbstractTestCase
{
protected $t1;
protected $t2;
protected function setUp(): void
{
$this->t1 = new Translations();
$this->t2 = new Translations();
$this->t1->insert(null, 'message-1');
$this->t1->insert(null, 'message-2');
$this->t2->insert(null, 'message-2');
$this->t2->insert(null, 'message-3');
}
public function testAdd()
{
$options = Merge::ADD;
$this->t1->mergeWith($this->t2, $options);
$this->assertNotFalse($this->t1->find(null, 'message-1'));
$this->assertNotFalse($this->t1->find(null, 'message-2'));
$this->assertNotFalse($this->t1->find(null, 'message-3'));
}
public function testRemove()
{
$options = Merge::REMOVE;
$this->t1->mergeWith($this->t2, $options);
$this->assertFalse($this->t1->find(null, 'message-1'));
$this->assertNotFalse($this->t1->find(null, 'message-2'));
$this->assertFalse($this->t1->find(null, 'message-3'));
}
public function testAddRemove()
{
$options = Merge::REMOVE | Merge::ADD;
$this->t1->mergeWith($this->t2, $options);
$this->assertFalse($this->t1->find(null, 'message-1'));
$this->assertNotFalse($this->t1->find(null, 'message-2'));
$this->assertNotFalse($this->t1->find(null, 'message-3'));
}
public function testNone()
{
$options = 0;
$this->t1->mergeWith($this->t2, $options);
$this->assertNotFalse($this->t1->find(null, 'message-1'));
$this->assertNotFalse($this->t1->find(null, 'message-2'));
$this->assertFalse($this->t1->find(null, 'message-3'));
}
}
|