小编may*_*rop的帖子

$ .Deferred与新的$ .Deferred

有什么区别

var dfd = new $.Deferred
Run Code Online (Sandbox Code Playgroud)

var dfd = $.Deferred
Run Code Online (Sandbox Code Playgroud)

在哪些情况下你需要使用新的vs不使用它?

jquery jquery-deferred

9
推荐指数
3
解决办法
1435
查看次数

PHPUnit测试Laravel资源控制器的异常

是否可以使用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)

我用\ ExceptionException尝试过这个.

在我的资源控制器中,我有:

public function store() {
    throw new \Exception('Just for testing!');
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道我可以测试例外?我也尝试过使用:

    $this->setExpectedException('InvalidArgumentException');
Run Code Online (Sandbox Code Playgroud)

phpunit unit-testing exception-handling exception laravel

3
推荐指数
1
解决办法
3068
查看次数