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
|
|
|
|