Ejemplo n.º 1
0
 public function testMixin()
 {
     // from js
     __::mixin(array('myReverse' => function ($string) {
         $chars = str_split($string);
         krsort($chars);
         return join('', $chars);
     }));
     $this->assertEquals('aecanap', __::myReverse('panacea'), 'mixed in a function to _');
     $this->assertEquals('pmahc', __('champ')->myReverse(), 'mixed in a function to _ with OO-style call');
     // docs
     __::mixin(array('capitalize' => function ($string) {
         return ucwords($string);
     }, 'yell' => function ($string) {
         return strtoupper($string);
     }));
     $this->assertEquals('Moe', __::capitalize('moe'));
     $this->assertEquals('MOE', __::yell('moe'));
 }