2020-04-13 15:30:52 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Smarty PHPunit tests assign method
|
|
|
|
|
*
|
2023-08-08 00:04:14 +02:00
|
|
|
|
2020-04-13 15:30:52 +02:00
|
|
|
* @author Uwe Tews
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* class for assign tests
|
|
|
|
|
*
|
2023-08-08 00:04:14 +02:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
2020-04-13 15:30:52 +02:00
|
|
|
*/
|
|
|
|
|
class AssignTest extends PHPUnit_Smarty
|
|
|
|
|
{
|
2021-10-13 12:15:17 +02:00
|
|
|
public function setUp(): void
|
2020-04-13 15:30:52 +02:00
|
|
|
{
|
2022-09-27 13:03:34 +03:00
|
|
|
$this->setUpSmarty(__DIR__);
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* test simple assign
|
|
|
|
|
*/
|
|
|
|
|
public function testSimpleAssign()
|
|
|
|
|
{
|
|
|
|
|
$this->smarty->assign('foo', 'bar');
|
|
|
|
|
$this->assertEquals('bar', $this->smarty->fetch('eval:{$foo}'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* test assign array of variables
|
|
|
|
|
*/
|
|
|
|
|
public function testArrayAssign()
|
|
|
|
|
{
|
|
|
|
|
$this->smarty->assign(array('foo' => 'bar', 'foo2' => 'bar2'));
|
|
|
|
|
$this->assertEquals('bar bar2', $this->smarty->fetch('eval:{$foo} {$foo2}'));
|
|
|
|
|
}
|
2024-03-28 11:22:29 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test that assign returns this.
|
|
|
|
|
*/
|
|
|
|
|
public function testAssignReturnsThis()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
'data',
|
|
|
|
|
$this->smarty->assign(['dummy' => 'data'])->fetch('eval:{$dummy}')
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-13 15:30:52 +02:00
|
|
|
}
|