forked from smarty-php/smarty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PluginModifierReplaceTest.php
54 lines (48 loc) · 1.39 KB
/
PluginModifierReplaceTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace UnitTests\TemplateSource\TagTests\PluginModifier;
/**
* class for modifier tests
*
* @runTestsInSeparateProcess
* @preserveGlobalState disabled
* @backupStaticAttributes enabled
*/
class PluginModifierReplaceTest extends \PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
}
/**
* @return void
* @throws \SmartyException
*
* @dataProvider replaceDataProvider
*/
public function testReplace($template, $subject, $expectedString)
{
$this->smarty->assign('subject', $subject);
$tpl = $this->smarty->createTemplate($template);
$this->assertEquals($expectedString, $this->smarty->fetch($tpl));
}
public function replaceDataProvider()
{
return [
'default' => [
'template' => 'string:{$subject|replace:",":"-"}',
'subject' => "a,b,c,d",
'expectedString' => "a-b-c-d",
],
'doNothing' => [
'template' => 'string:{$subject|replace:"":""}',
'subject' => "a,b,c,d",
'expectedString' => "a,b,c,d",
],
'withNull' => [
'template' => 'string:{$subject|replace:"":""}',
'subject' => null,
'expectedString' => "",
],
];
}
}