Exemplo n.º 1
0
 /**
  * @test
  */
 public function it_has_methods_to_call_the_wrapped_callback()
 {
     $callback = new Callback(function ($result = 'success') {
         return $result;
     });
     $this->assertEquals('success', $callback->call());
     $this->assertEquals('pass', $callback->call('pass'));
     $sumCallback = new Callback(function ($a, $b, $c) {
         return $a + $b + $c;
     });
     $this->assertEquals(12, $sumCallback->callArray([4, 10, -2]));
 }
Exemplo n.º 2
0
 /**
  * Call the callback.
  *
  * @param  array $arguments  All arguments passed to the callback
  *
  * @return mixed  The value returned from the callback
  */
 protected function invokeCallback($arguments)
 {
     $returned = $this->callback->callArray(array_slice($arguments, 0, $this->callbackParamCount ?: null));
     $this->iterations++;
     return $returned;
 }