Improve TemplateTest
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
5a4435a40d
commit
4bbe23f1df
2
templates/test/add_data_twig.twig
Normal file
2
templates/test/add_data_twig.twig
Normal file
@ -0,0 +1,2 @@
|
||||
{{ variable1 }}
|
||||
{{ variable2 }}
|
||||
1
templates/test/echo_twig.twig
Normal file
1
templates/test/echo_twig.twig
Normal file
@ -0,0 +1 @@
|
||||
{{ variable -}}
|
||||
1
templates/test/static_twig.twig
Normal file
1
templates/test/static_twig.twig
Normal file
@ -0,0 +1 @@
|
||||
static content
|
||||
@ -18,11 +18,13 @@ class TemplateTest extends PMATestCase
|
||||
/**
|
||||
* Test for set function
|
||||
*
|
||||
* @dataProvider providerTestSet
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSet()
|
||||
public function testSet($data)
|
||||
{
|
||||
$template = PMA\libraries\Template::get('test/add_data');
|
||||
$template = PMA\libraries\Template::get($data);
|
||||
$template->set('variable1', 'value1');
|
||||
$template->set(
|
||||
array(
|
||||
@ -34,6 +36,19 @@ class TemplateTest extends PMATestCase
|
||||
$this->assertContains('value2', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testSet
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function providerTestSet()
|
||||
{
|
||||
return [
|
||||
['test/add_data'],
|
||||
['test/add_data_twig'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for setHelper
|
||||
*
|
||||
@ -64,6 +79,10 @@ class TemplateTest extends PMATestCase
|
||||
'static content',
|
||||
PMA\libraries\Template::get('test/static')->render()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'static content',
|
||||
PMA\libraries\Template::get('test/static_twig')->render()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,5 +100,13 @@ class TemplateTest extends PMATestCase
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
'value',
|
||||
PMA\libraries\Template::get('test/echo_twig')->render(
|
||||
array(
|
||||
'variable' => 'value'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user