1 | <?php |
||
14 | class ConfigurationTest extends \PHPUnit_Framework_TestCase |
||
15 | { |
||
16 | /** |
||
17 | * testNoConfiguration |
||
18 | */ |
||
19 | public function testNoConfiguration() |
||
20 | { |
||
21 | $this->expectException(InvalidConfigurationException::class); |
||
22 | $config = []; |
||
23 | $processor = new Processor(); |
||
24 | $configuration = new Configuration(); |
||
25 | $processor->processConfiguration($configuration, $config); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * testDefaultClasses |
||
30 | */ |
||
31 | public function testDefaultClasses() |
||
32 | { |
||
33 | $config = [[ |
||
34 | 'mapping_fields' => [ |
||
35 | 'TY' => ['BOOK'], |
||
36 | ], |
||
37 | ]]; |
||
38 | $processor = new Processor(); |
||
39 | $configuration = new Configuration(); |
||
40 | $config = $processor->processConfiguration($configuration, $config); |
||
41 | |||
42 | $this->assertEquals('Funstaff\RefLibRis\RisFieldsMapping', $config['classes']['ris_fields_mapping']); |
||
43 | $this->assertEquals('Funstaff\RefLibRis\RecordProcessing', $config['classes']['record_processing']); |
||
44 | $this->assertEquals('Funstaff\RefLibRis\RisDefinition', $config['classes']['ris_definition']); |
||
45 | $this->assertEquals('Funstaff\RefLibRis\RisWriter', $config['classes']['ris_writer']); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * testClasses |
||
50 | */ |
||
51 | public function testClasses() |
||
52 | { |
||
53 | $config = [[ |
||
54 | 'classes' => [ |
||
55 | 'ris_fields_mapping' => 'Funstaff\RefLibRis\FooBar', |
||
56 | ], |
||
57 | 'mapping_fields' => [ |
||
58 | 'TY' => ['BOOK'], |
||
59 | ], |
||
60 | ]]; |
||
61 | $processor = new Processor(); |
||
62 | $configuration = new Configuration(); |
||
63 | $config = $processor->processConfiguration($configuration, $config); |
||
64 | |||
65 | $this->assertEquals('Funstaff\RefLibRis\FooBar', $config['classes']['ris_fields_mapping']); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * testMappingWithMissingFieldTY |
||
70 | */ |
||
71 | public function testMappingWithMissingFieldTY() |
||
72 | { |
||
73 | $this->expectException(InvalidConfigurationException::class); |
||
74 | $config = [[ |
||
75 | 'mapping_fields' => [ |
||
76 | 'AU' => ['author'], |
||
77 | ], |
||
78 | ]]; |
||
79 | $processor = new Processor(); |
||
80 | $configuration = new Configuration(); |
||
81 | $processor->processConfiguration($configuration, $config); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * testMapping |
||
86 | */ |
||
87 | public function testMapping() |
||
88 | { |
||
89 | $config = [[ |
||
90 | 'mapping_fields' => [ |
||
91 | 'TY' => ['BOOK'], |
||
92 | 'AU' => ['author'], |
||
93 | ], |
||
94 | ]]; |
||
95 | $processor = new Processor(); |
||
96 | $configuration = new Configuration(); |
||
97 | $config = $processor->processConfiguration($configuration, $config); |
||
98 | |||
99 | $this->assertEquals(['BOOK'], $config['mapping_fields']['TY']); |
||
100 | $this->assertEquals(['author'], $config['mapping_fields']['AU']); |
||
101 | } |
||
102 | } |
||
103 |