Ejemplo n.º 1
0
 public function testArrayToJsonWithBoolean()
 {
     $function = new JsFunction();
     $function->setBody("alert('Hello world')");
     $encodedVal = Json::arrayToJson(array('foo' => 'bar', 'boolean' => false, 'onclick' => $function));
     $this->assertEquals("{foo:'bar',boolean:false,onclick:function(){alert('Hello world')}}", $encodedVal);
 }
Ejemplo n.º 2
0
 public function testAssingToVar()
 {
     $function = new JsFunction();
     $function->setBody("alert('Hello world')");
     $function->setCondition('5 = 5', "alert('failure')");
     $function->setVarName('foo_bar');
     $this->assertEquals("foo_bar = function(){if(5 = 5){alert('Hello world')}else{alert('failure')}}", $function);
 }