mirror of
https://github.com/Mibew/handlebars.php.git
synced 2025-05-03 02:26:41 +03:00
fix a bug with helpers and add a test for that
This commit is contained in:
parent
8938fdc5c3
commit
25190010e1
@ -47,7 +47,7 @@ class Helpers
|
|||||||
* Create new helper container class
|
* Create new helper container class
|
||||||
*
|
*
|
||||||
* @param array $helpers array of name=>$value helpers
|
* @param array $helpers array of name=>$value helpers
|
||||||
* @param array|bool $defaults add defaults helper (if, unless, each,with)
|
* @param array|bool $defaults add defaults helper (if, unless, each,with, bindAttr)
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException when $helpers is not an array
|
* @throws \InvalidArgumentException when $helpers is not an array
|
||||||
* (or traversable) or helper is not a callable
|
* (or traversable) or helper is not a callable
|
||||||
@ -64,7 +64,7 @@ class Helpers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach ($helpers as $name => $helper) {
|
foreach ($helpers as $name => $helper) {
|
||||||
$this->add($name, $helpers);
|
$this->add($name, $helper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,4 +113,17 @@ class HandlebarsTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management helpers
|
||||||
|
*/
|
||||||
|
public function testHelpersManagement()
|
||||||
|
{
|
||||||
|
$helpers = new \Handlebars\Helpers(array('test'=> function(){}), false);
|
||||||
|
$engine = new \Handlebars\Handlebars(['helpers' => $helpers]);
|
||||||
|
$this->assertTrue(is_callable($engine->getHelper('test')));
|
||||||
|
$this->assertTrue($engine->hasHelper('test'));
|
||||||
|
$engine->removeHelper('test');
|
||||||
|
$this->assertFalse($engine->hasHelper('test'));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user