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

MoTest::testBigEndianFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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