有什么区别
var dfd = new $.Deferred
Run Code Online (Sandbox Code Playgroud)
和
var dfd = $.Deferred
Run Code Online (Sandbox Code Playgroud)
在哪些情况下你需要使用新的vs不使用它?
是否可以使用Laravel资源控制器测试Exceptions?每次我尝试执行以下操作:
/**
* @expectedException Exception
* @expectedExceptionMessage Just testing this out
*/
public function testMyPost() {
$response = $this->call('POST', '/api/myapi/', array('testing' => 1));
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
Failed asserting that exception of type "Exception" is thrown.
Run Code Online (Sandbox Code Playgroud)
我用\ Exception和Exception尝试过这个.
在我的资源控制器中,我有:
public function store() {
throw new \Exception('Just for testing!');
}
Run Code Online (Sandbox Code Playgroud)
有没有人知道我可以测试例外?我也尝试过使用:
$this->setExpectedException('InvalidArgumentException');
Run Code Online (Sandbox Code Playgroud)