-
Notifications
You must be signed in to change notification settings - Fork 699
/
PluginModifierExplodeTest.php
55 lines (49 loc) · 1.46 KB
/
PluginModifierExplodeTest.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
55
<?php
namespace UnitTests\TemplateSource\TagTests\PluginModifier;
/**
* class for modifier tests
*
* @runTestsInSeparateProcess
* @preserveGlobalState disabled
* @backupStaticAttributes enabled
*/
class PluginModifierExplodeTest extends \PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
}
/**
* @return void
* @throws \SmartyException
*
* @dataProvider explodeDataProvider
*/
public function testExplode($template, $subject, $expectedString)
{
$this->smarty->assign('subject', $subject);
$tpl = $this->smarty->createTemplate($template);
$res = $this->smarty->fetch($tpl);
$this->assertEquals($expectedString, $res);
}
public function explodeDataProvider()
{
return [
'default' => [
'template' => 'string:{","|explode:$subject|json_encode}',
'subject' => 'a,b,c,d',
'expectedString' => '["a","b","c","d"]',
],
'withNoDelimiterFound' => [
'template' => 'string:{","|explode:$subject|json_encode}',
'subject' => 'abcd',
'expectedString' => '["abcd"]',
],
'withNull' => [
'template' => 'string:{","|explode:$subject|json_encode}',
'subject' => null,
'expectedString' => '[""]',
],
];
}
}