setCallbacks() public method

public setCallbacks ( )
示例#1
0
 /**
  * @expectedException Exception
  */
 public function testSetCallbacks()
 {
     $this->table->setCallbacks('foo', 'bar');
     $this->assertArrayHasKey('foo', $this->table->getCallbacks());
     $this->table->setCallbacks(array('foo2' => 'bar2', 'foo3' => 'bar3'));
     $this->assertArrayHasKey('foo2', $this->table->getCallbacks());
     $this->assertArrayHasKey('foo3', $this->table->getCallbacks());
     $this->table->setCallbacks('foo', 'bar', 'baz');
     $this->assertTrue(False);
     // should throw exception before here
 }
示例#2
0
 public function testSetNamedFunctionAsCallback()
 {
     //set an anonymous function
     $this->table->setCallbacks(['foo' => 'function(){ return foo; }']);
     //set a named function
     $this->table->setCallbacks(['bar' => 'myBar']);
     $parameters = $this->table->getViewParameters();
     //an anonymous function should be included as it is.
     $this->assertThat($parameters['options'], $this->stringContains('"foo":function(){ return foo; }'));
     //the callback it's a function name, it shouldn't be quoted
     $this->assertThat($parameters['options'], $this->stringContains('"bar":myBar'));
 }