throws() public static méthode

Checks if the function throws exception, alias for exception().
public static throws ( callable $function, $class, $message = NULL, $code = NULL ) : Exception
$function callable
Résultat Exception
 public function testCallback()
 {
     $form = new Form();
     $sug = $form->addSuggestion('suggestion')->setCallback(array($this, 'suggestionCallback'));
     $this->assertSame(array('query1', 'query2'), $sug->call('query'));
     A::throws(function () use($sug) {
         $sug->getControl();
     }, 'Nette\\InvalidStateException');
     $this->assertInstanceOf('Nette\\Utils\\Html', $sug->getControl(FALSE));
     $sug->setLink('link');
     $this->assertInstanceOf('Nette\\Utils\\Html', $sug->getControl());
 }
 public function testMask()
 {
     $form = new Form();
     $mask = $form->addMask('mask');
     $mask->setMask('999 *** aaa');
     $mask->getControl();
     $rules = $mask->getRules()->getIterator();
     $this->assertSame('[0-9][0-9][0-9] [0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z] [a-zA-Z][a-zA-Z][a-zA-Z]', $rules[0]->arg);
     A::throws(function () use($mask) {
         $mask->setMask('999');
     }, 'Exception');
     A::throws(function () use($mask) {
         $mask->setRegex('999');
     }, 'Exception');
 }