|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class FileNlsTest extends AriadneBaseTest |
|
4
|
|
|
{ |
|
5
|
|
|
|
|
6
|
|
|
public function setUp() |
|
7
|
|
|
{ |
|
8
|
|
|
$this->initAriadne(); |
|
9
|
|
|
} |
|
10
|
|
|
|
|
11
|
|
|
public function testDefaultNLS() { |
|
12
|
|
|
global $AR; |
|
13
|
|
|
|
|
14
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
15
|
|
|
$defaultnls = $obj->data->nls->default; |
|
16
|
|
|
|
|
17
|
|
|
$one = trim($obj->getFile('file',$defaultnls)); |
|
18
|
|
|
$two = trim($obj->getFile()); |
|
19
|
|
|
$this->assertEquals('taal '.$defaultnls,$one); |
|
20
|
|
|
$this->assertEquals($one,$two); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function testAllNLS() { |
|
24
|
|
|
global $AR; |
|
25
|
|
|
|
|
26
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
27
|
|
|
|
|
28
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
29
|
|
|
$content = $obj->getFile('file',$nls); |
|
30
|
|
|
$content = trim($content); |
|
31
|
|
|
$this->assertEquals('taal '.$nls , $content); |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testAllNLSPlain() { |
|
36
|
|
|
global $AR; |
|
37
|
|
|
|
|
38
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
39
|
|
|
|
|
40
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
41
|
|
|
$content = $obj->getPlainText('file',$nls); |
|
42
|
|
|
$content = trim($content); |
|
43
|
|
|
$this->assertEquals('taal '.$nls , $content); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testAllNLSShow() { |
|
48
|
|
|
global $AR; |
|
49
|
|
|
|
|
50
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
51
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
52
|
|
|
ob_start(); |
|
53
|
|
|
$obj->ShowFile('file',$nls); |
|
54
|
|
|
$content = ob_get_contents(); |
|
55
|
|
|
ob_end_clean(); |
|
56
|
|
|
$content = trim($content); |
|
57
|
|
|
$this->assertEquals('taal '.$nls , $content); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
View Code Duplication |
public function testunavailableNls() { |
|
62
|
|
|
global $AR; |
|
63
|
|
|
|
|
64
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
65
|
|
|
$content = $obj->getFile('file','zz'); |
|
66
|
|
|
$content = trim($content); |
|
67
|
|
|
$this->assertEquals('taal '.$obj->data->nls->default , $content); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
View Code Duplication |
public function testUnavailableNlsPlain() { |
|
71
|
|
|
global $AR; |
|
72
|
|
|
|
|
73
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
74
|
|
|
$nls = $obj->data->nls->default; |
|
75
|
|
|
$content = $obj->getPlainText('file','zz'); |
|
76
|
|
|
$content = trim($content); |
|
77
|
|
|
$this->assertEquals('taal '.$nls , $content); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function testunavailableNlsChangeDefault() { |
|
81
|
|
|
global $AR; |
|
82
|
|
|
|
|
83
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
84
|
|
|
$nls = $obj->data->nls->default; |
|
85
|
|
|
$obj->data->nls->default = 'de'; |
|
86
|
|
|
$content = $obj->getFile('file','zz'); |
|
87
|
|
|
$content = trim($content); |
|
88
|
|
|
$this->assertNotEquals('taal '.$nls , $content); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function testAllNLSPlainHTML() { |
|
92
|
|
|
global $AR; |
|
93
|
|
|
|
|
94
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-html/')->call('system.get.phtml')); |
|
95
|
|
|
|
|
96
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
97
|
|
|
$content = $obj->getPlainText('file',$nls); |
|
98
|
|
|
$content = trim($content); |
|
99
|
|
|
$this->assertEquals($nls , $content); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
public function testAllNLSPlainPDF() { |
|
103
|
|
|
global $AR; |
|
104
|
|
|
|
|
105
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-pdf/')->call('system.get.phtml')); |
|
106
|
|
|
|
|
107
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
108
|
|
|
$content = $obj->getPlainText('file',$nls); |
|
109
|
|
|
$content = trim($content); |
|
110
|
|
|
$this->assertEquals($nls , $content); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function testSaveExistingFile() { |
|
115
|
|
|
global $AR,$ARCurrent; |
|
116
|
|
|
$content = 'testfrmlfrop'; |
|
117
|
|
|
$obj = current(ar::get(TESTBASE.'/file-nls/file-nls/' )->call('system.get.phtml')); |
|
118
|
|
|
|
|
119
|
|
|
$res = $obj->SaveFile($content ,'text/plain', 'newfile', $obj->nls); |
|
120
|
|
|
$this->assertEquals(strlen($content), $res); |
|
121
|
|
|
|
|
122
|
|
|
$res = $obj->GetFile('newfile', $obj->nls); |
|
123
|
|
|
$this->assertEquals($content, $res); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function testParseFile() { |
|
127
|
|
|
global $AR; |
|
128
|
|
|
|
|
129
|
|
|
$obj =current(ar::get(TESTBASE.'/file-nls/file-nls/')->call('system.get.phtml')); |
|
130
|
|
|
foreach($obj->data->nls->list as $nls => $language) { |
|
131
|
|
|
$content = $obj->ParseFile('file',$nls); |
|
132
|
|
|
$content = trim($content); |
|
133
|
|
|
$this->assertEquals('taal '.$nls , $content); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/* |
|
138
|
|
|
TODO: |
|
139
|
|
|
- save file for new object |
|
140
|
|
|
- showfile |
|
141
|
|
|
- mimetype |
|
142
|
|
|
- headers |
|
143
|
|
|
- download file |
|
144
|
|
|
- file |
|
145
|
|
|
- mimetype |
|
146
|
|
|
- headers |
|
147
|
|
|
*/ |
|
148
|
|
|
} |
|
149
|
|
|
?> |
|
|
|
|
|
|
150
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.