Passed
Push — master ( f17c4a...767498 )
by Aimeos
02:18
created

MoTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 17
c 1
b 0
f 0
dl 0
loc 50
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testGet() 0 4 1
A testAll() 0 6 1
A testGetFallback() 0 4 1
A testInvalidFile() 0 4 1
A testEmptyFile() 0 4 1
A testBigEndianFile() 0 4 1
A testConstructorException() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2022
6
 */
7
8
9
namespace Aimeos\Base\Translation\File;
10
11
12
class MoTest extends \PHPUnit\Framework\TestCase
13
{
14
	public function testConstructorException()
15
	{
16
		$this->expectException( \Aimeos\Base\Translation\Exception::class );
17
		new Mo( 'notexisting' );
18
	}
19
20
21
	public function testAll()
22
	{
23
		$object = new Mo( dirname( __DIR__ ) . '/testfiles/case1/de' );
24
		$this->assertArrayHasKey( 'Car', $object->all() );
25
		$this->assertArrayHasKey( 'File', $object->all() );
26
		$this->assertArrayHasKey( 'Update', $object->all() );
27
	}
28
29
30
	public function testBigEndianFile()
31
	{
32
		$object = new Mo( dirname( __DIR__ ) . '/testfiles/bigendian' );
33
		$this->assertEquals( [], $object->all() );
34
	}
35
36
37
	public function testEmptyFile()
38
	{
39
		$this->expectException( \Aimeos\Base\Translation\Exception::class );
40
		new Mo( dirname( __DIR__ ) . '/testfiles/empty' );
41
	}
42
43
44
	public function testGet()
45
	{
46
		$object = new Mo( dirname( __DIR__ ) . '/testfiles/case1/de' );
47
		$this->assertEquals( 'Aktualisierung', $object->get( 'Update' ) );
48
	}
49
50
51
	public function testGetFallback()
52
	{
53
		$object = new Mo( dirname( __DIR__ ) . '/testfiles/case1/de' );
54
		$this->assertEquals( null, $object->get( 'unknown' ) );
55
	}
56
57
58
	public function testInvalidFile()
59
	{
60
		$this->expectException( \Aimeos\Base\Translation\Exception::class );
61
		new Mo( dirname( __DIR__ ) . '/testfiles/invalid' );
62
	}
63
}
64