Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit cc934fd

Browse files
committed
update config tests
1 parent 0ff32f1 commit cc934fd

File tree

25 files changed

+127
-38
lines changed

25 files changed

+127
-38
lines changed

UnitTests/ConfigFileTests/DefaultConfigHandlerTest.php renamed to UnitTests/ConfigFileTests/defaultHandler/DefaultConfigHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testDefaultConfigHandlerReplacement()
6161
{
6262
$this->smarty->registerDefaultConfigHandler('configHandlerData');
6363
$this->smarty->configLoad('foo.conf');
64-
$this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}'));
64+
$this->assertEquals("bar", $this->smarty->fetch('foo.tpl'));
6565
}
6666

6767
/**
@@ -74,7 +74,7 @@ public function testDefaultConfigHandlerReplacementByConfigFile()
7474
{
7575
$this->smarty->registerDefaultConfigHandler('configHandlerFile');
7676
$this->smarty->configLoad('foo.conf');
77-
$this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}'));
77+
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
7878
}
7979

8080
/**
@@ -87,7 +87,7 @@ public function testDefaultConfigHandlerReplacementByConfigFileFail()
8787
{
8888
$this->smarty->registerDefaultConfigHandler('configHandlerFile');
8989
$this->smarty->configLoad('fo.conf');
90-
$this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}'));
90+
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
9191
}
9292

9393
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#foo#}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#Number#}

UnitTests/ConfigFileTests/ConfigVarTest.php renamed to UnitTests/ConfigFileTests/file/ConfigVarTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testInit()
3939
public function testConfigNumber()
4040
{
4141
$this->smarty->configLoad('test.conf');
42-
$this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}'));
42+
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
4343
}
4444

4545
/**
@@ -51,7 +51,7 @@ public function testConfigNumber()
5151
public function testConfigText()
5252
{
5353
$this->smarty->configLoad('test.conf');
54-
$this->assertEquals("123bvc", $this->smarty->fetch('eval:{#text#}'));
54+
$this->assertEquals("123bvc", $this->smarty->fetch('text.tpl'));
5555
}
5656

5757
/**
@@ -75,7 +75,7 @@ public function testConfigLine()
7575
public function testConfigVariableGlobalSections()
7676
{
7777
$this->smarty->configLoad('test.conf');
78-
$this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}'));
78+
$this->assertEquals("Welcome to Smarty! Global Section1 Global Section2", $this->smarty->fetch('sec1sec2.tpl'));
7979
}
8080

8181
/**
@@ -87,7 +87,7 @@ public function testConfigVariableGlobalSections()
8787
public function testConfigVariableSection2()
8888
{
8989
$this->smarty->configLoad('test.conf', 'section2');
90-
$this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}'));
90+
$this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('sec1sec2.tpl'));
9191
}
9292

9393
/**
@@ -99,7 +99,7 @@ public function testConfigVariableSection2()
9999
public function testConfigVariableSectionSpecialChar()
100100
{
101101
$this->smarty->configLoad('test.conf', '/');
102-
$this->assertEquals("Welcome to Smarty! special char", $this->smarty->fetch('eval:{#title#} {#sec#}'));
102+
$this->assertEquals("Welcome to Smarty! special char", $this->smarty->fetch('sec.tpl'));
103103
}
104104

105105
/**
@@ -111,7 +111,7 @@ public function testConfigVariableSectionSpecialChar()
111111
public function testConfigVariableSectionFooBar()
112112
{
113113
$this->smarty->configLoad('test.conf', 'foo/bar');
114-
$this->assertEquals("Welcome to Smarty! section foo/bar", $this->smarty->fetch('eval:{#title#} {#sec#}'));
114+
$this->assertEquals("Welcome to Smarty! section foo/bar", $this->smarty->fetch('sec.tpl'));
115115
}
116116

117117
/**
@@ -123,9 +123,9 @@ public function testConfigVariableSectionFooBar()
123123
public function testConfigDifferentScope()
124124
{
125125
$this->smarty->configLoad('test.conf', 'section2');
126-
$tpl = $this->smarty->createTemplate('eval:{#title#} {#sec1#} {#sec2#}');
126+
$tpl = $this->smarty->createTemplate('sec1sec2.tpl');
127127
$tpl->configLoad('test.conf', 'section1');
128-
$this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('eval:{#title#} {#sec1#} {#sec2#}'));
128+
$this->assertEquals("Welcome to Smarty! Global Section1 Hello Section2", $this->smarty->fetch('sec1sec2.tpl'));
129129
$this->assertEquals("Welcome to Smarty! Hello Section1 Global Section2", $this->smarty->fetch($tpl));
130130
}
131131

@@ -140,7 +140,7 @@ public function testConfigVariableHidden()
140140
{
141141
$this->smarty->config_read_hidden = true;
142142
$this->smarty->configLoad('test.conf', 'hidden');
143-
$this->assertEquals("Welcome to Smarty!Hidden Section", $this->smarty->fetch('eval:{#title#}{#hiddentext#}'));
143+
$this->assertEquals("Welcome to Smarty!Hidden Section", $this->smarty->fetch('hidden.tpl'));
144144
}
145145

146146
/**
@@ -155,7 +155,7 @@ public function testConfigVariableHiddenDisable()
155155
$this->smarty->setErrorReporting(error_reporting() & ~(E_NOTICE | E_USER_NOTICE));
156156
$this->smarty->config_read_hidden = false;
157157
$this->smarty->configLoad('test.conf', 'hidden');
158-
$this->assertEquals("Welcome to Smarty!", $this->smarty->fetch('eval:{#title#}{#hiddentext#}'));
158+
$this->assertEquals("Welcome to Smarty!", $this->smarty->fetch('hidden.tpl'));
159159
}
160160

161161
/**
@@ -223,7 +223,7 @@ public function testConfigTextData()
223223
{
224224
$data = $this->smarty->createData();
225225
$data->configLoad('test.conf');
226-
$this->assertEquals("123bvc", $this->smarty->fetch('eval:{#text#}', $data));
226+
$this->assertEquals("123bvc", $this->smarty->fetch('text.tpl', $data));
227227
}
228228

229229
/**
@@ -294,7 +294,7 @@ public function testConfigClearConfigAllData()
294294
*/
295295
public function testConfigTextTemplate()
296296
{
297-
$tpl = $this->smarty->createTemplate('eval:{#text#}');
297+
$tpl = $this->smarty->createTemplate('text.tpl');
298298
$tpl->configLoad('test.conf');
299299
$this->assertEquals("123bvc", $this->smarty->fetch($tpl));
300300
}
@@ -307,7 +307,7 @@ public function testConfigTextTemplate()
307307
*/
308308
public function testConfigGetSingleConfigVarTemplate()
309309
{
310-
$tpl = $this->smarty->createTemplate('eval:{#text#}');
310+
$tpl = $this->smarty->createTemplate('text.tpl');
311311
$tpl->configLoad('test.conf');
312312
$this->assertEquals("Welcome to Smarty!", $tpl->getConfigVars('title'));
313313
}
@@ -320,7 +320,7 @@ public function testConfigGetSingleConfigVarTemplate()
320320
*/
321321
public function testConfigGetAllConfigVarsTemplate()
322322
{
323-
$tpl = $this->smarty->createTemplate('eval:{#text#}');
323+
$tpl = $this->smarty->createTemplate('text.tpl');
324324
$tpl->configLoad('test.conf');
325325
$vars = $tpl->getConfigVars();
326326
$this->assertTrue(is_array($vars));
@@ -336,7 +336,7 @@ public function testConfigGetAllConfigVarsTemplate()
336336
*/
337337
public function testConfigClearSingleConfigVarTemplate()
338338
{
339-
$tpl = $this->smarty->createTemplate('eval:{#text#}');
339+
$tpl = $this->smarty->createTemplate('text.tpl');
340340
$tpl->configLoad('test.conf');
341341
$tpl->clearConfig('title');
342342
$this->assertEquals("", $tpl->getConfigVars('title'));
@@ -351,7 +351,7 @@ public function testConfigClearSingleConfigVarTemplate()
351351
*/
352352
public function testConfigClearConfigAllTemplate()
353353
{
354-
$tpl = $this->smarty->createTemplate('eval:{#text#}');
354+
$tpl = $this->smarty->createTemplate('text.tpl');
355355
$tpl->configLoad('test.conf');
356356
$tpl->clearConfig();
357357
$vars = $tpl->getConfigVars();
@@ -369,25 +369,25 @@ public function testConfigAbsolutePath()
369369
{
370370
$file = realpath($this->smarty->getConfigDir(0) . 'test.conf');
371371
$this->smarty->configLoad($file);
372-
$this->assertEquals("123.4", $this->smarty->fetch('eval:{#Number#}'));
372+
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
373373
}
374374

375375
public function testConfigResourceDb4()
376376
{
377377
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
378378
$this->smarty->configLoad('db4:foo.conf');
379-
$this->assertEquals("bar", $this->smarty->fetch('eval:{#foo#}'));
379+
$this->assertEquals("bar", $this->smarty->fetch('foo.tpl'));
380380
}
381381
public function testConfigUndefinedSilent()
382382
{
383-
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
383+
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
384384
}
385385

386386
public function testConfigUndefinedNotice()
387387
{
388388
$this->smarty->error_unassigned = true;
389389
try {
390-
$this->assertEquals("", $this->smarty->fetch('eval:{#foo#}'));
390+
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
391391
}
392392
catch (Exception $e) {
393393
$this->assertEquals('Undefined variable: foo', $e->getMessage());
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
title = Welcome to Smarty!
2+
3+
overwrite = Overwrite1
4+
overwrite = Overwrite2
5+
6+
booleanon = on
7+
8+
Intro = """This is a value that spans more
9+
than one line. you must enclose
10+
it in triple quotes."""
11+
12+
Number = 123.4
13+
14+
text = 123bvc
15+
16+
line = 123 This is a line
17+
18+
sec1 = Global Section1
19+
20+
sec2 = Global Section2
21+
22+
sec = Global char
23+
[/]
24+
sec = special char
25+
26+
[foo/bar]
27+
sec = section foo/bar
28+
29+
[section1]
30+
sec1 = Hello Section1
31+
32+
[section2]
33+
sec2 = 'Hello Section2'
34+
35+
[.hidden]
36+
hiddentext = Hidden Section
37+
38+
#Comment
39+
# Comment with a space first line first
40+
#Comment line starting with space
41+
# Space before and after #
42+
#The line below only contains a #
43+
#
44+
#
45+
# title = This is not the correct title
46+
47+
#[section1]
48+
#sec1 = Wrong text
49+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#foo#}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{#title#}{#hiddentext#}

0 commit comments

Comments
 (0)