Example #1
0
 function testPlaceholderHookParameters()
 {
     // function to run if filter works
     function render_placeholder_parameter($x)
     {
         $colors = array();
         foreach (func_get_args() as $fruit) {
             switch ($fruit) {
                 case 'apple':
                     $colors[] = 'Red';
                     break;
                 case 'banana':
                     $colors[] = 'Yellow';
                     break;
             }
         }
         return implode($colors, " ");
     }
     \Sleepy\Hook::applyFilter('render_placeholder_colorof', 'render_placeholder_parameter');
     // lets capture what the \Sleepy\Template
     $t = new \Sleepy\Template();
     $t->directory = "./templates/";
     $t->setTemplate('parameters');
     ob_start();
     $t->show();
     $color = ob_get_clean();
     // test if the extra bang was added
     $this->assertEqual($color, 'Yellow Red');
 }
Example #2
0
 function testHooksFilter()
 {
     // function to run if filter works
     function filter($arg)
     {
         return $arg . " Smith";
     }
     \Sleepy\Hook::applyFilter('TestFilter', 'filter');
     // Did the filter do anything?
     if (\Sleepy\Hook::addFilter('TestFilter', "John") === "John Smith") {
         $this->pass();
     } else {
         $this->fail();
     }
 }