Passed
Push — master ( ba009d...b62909 )
by Aimeos
02:13
created

MemoryTest   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 9
eloc 21
c 2
b 0
f 0
dl 0
loc 69
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 2 1
A setUp() 0 13 1
A testDn() 0 4 1
A testDtNone() 0 3 1
A testDnPlural() 0 4 1
A testAll() 0 3 1
A testDnNone() 0 4 1
A testDt() 0 3 1
A testDnPluralCs() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2022
6
 */
7
8
9
namespace Aimeos\Base\Translation\Decorator;
10
11
12
class MemoryTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp() : void
18
	{
19
		$strings = array( 'domain' => array(
20
			'test singular' => array( 0 => 'translation singular' ),
21
			'test plural' => array(
22
				0 => 'plural translation singular',
23
				1 => 'plural translation plural',
24
				2 => 'plural translation plural (cs)',
25
			)
26
		) );
27
28
		$conf = new \Aimeos\Base\Translation\None( 'cs' );
29
		$this->object = new \Aimeos\Base\Translation\Decorator\Memory( $conf, $strings );
30
	}
31
32
33
	protected function tearDown() : void
34
	{
35
	}
36
37
38
	public function testAll()
39
	{
40
		$this->assertEquals( [], $this->object->all( 'domain' ) );
41
	}
42
43
44
	public function testDt()
45
	{
46
		$this->assertEquals( 'translation singular', $this->object->dt( 'domain', 'test singular' ) );
47
	}
48
49
50
	public function testDtNone()
51
	{
52
		$this->assertEquals( 'test none', $this->object->dt( 'domain', 'test none' ) );
53
	}
54
55
56
	public function testDn()
57
	{
58
		$translation = $this->object->dn( 'domain', 'test plural', 'test plural 2', 1 );
59
		$this->assertEquals( 'plural translation singular', $translation );
60
	}
61
62
63
	public function testDnNone()
64
	{
65
		$translation = $this->object->dn( 'domain', 'test none', 'test none plural', 0 );
66
		$this->assertEquals( 'test none plural', $translation );
67
	}
68
69
70
	public function testDnPlural()
71
	{
72
		$translation = $this->object->dn( 'domain', 'test plural', 'test plural 2', 2 );
73
		$this->assertEquals( 'plural translation plural', $translation );
74
	}
75
76
77
	public function testDnPluralCs()
78
	{
79
		$translation = $this->object->dn( 'domain', 'test plural', 'test plural 2', 5 );
80
		$this->assertEquals( 'plural translation plural (cs)', $translation );
81
	}
82
}
83