mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 12:34:33 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3232277bc5 |
@@ -0,0 +1 @@
|
||||
- Fix warning when calling hasVariable for an undefined variable [#977](https://github.com/smarty-php/smarty/issues/977)
|
||||
+1
-1
@@ -290,7 +290,7 @@ class Data
|
||||
* @return bool
|
||||
*/
|
||||
public function hasVariable($varName): bool {
|
||||
return !($this->getVariable($varName) instanceof UndefinedVariable);
|
||||
return !($this->getVariable($varName, true, false) instanceof UndefinedVariable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -1,2 +0,0 @@
|
||||
# Ignore anything in here, but keep this directory
|
||||
*
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests the ::hasVariable method
|
||||
*/
|
||||
class HasVariableTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
|
||||
public function testInit()
|
||||
{
|
||||
$this->cleanDirs();
|
||||
}
|
||||
|
||||
public function testSimpleTrue()
|
||||
{
|
||||
$this->smarty->assign('foo', 'bar');
|
||||
$this->assertTrue($this->smarty->hasVariable('foo'));
|
||||
}
|
||||
|
||||
|
||||
public function testSimpleFalse()
|
||||
{
|
||||
$this->smarty->assign('foo', 'bar');
|
||||
$this->assertFalse($this->smarty->hasVariable('foox'));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user