Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel php单元中的assertRedirectedToRoute给定错误_Laravel_Laravel 4_Phpunit - Fatal编程技术网

Laravel php单元中的assertRedirectedToRoute给定错误

Laravel php单元中的assertRedirectedToRoute给定错误,laravel,laravel-4,phpunit,Laravel,Laravel 4,Phpunit,运行PHPunit后,我在 $this->assertRedirectedToRoute('posts.index'); // line 50 $this->assertRedirectedToRoute('posts.index', ['flash']); //line 84 (一) (二) 如果你看到文件 public void AssertRedirectedToRute(字符串$name,数组$parameters=array(),数组$with=array()) 断言客

运行PHPunit后,我在

$this->assertRedirectedToRoute('posts.index'); // line 50
$this->assertRedirectedToRoute('posts.index', ['flash']);  //line 84
(一)

(二)

如果你看到文件

public void AssertRedirectedToRute(字符串$name,数组$parameters=array(),数组$with=array())

断言客户端是否重定向到给定路由。 参数 字符串$name
数组$参数 数组$with

因此,您应该在assertRedirectedToRoute第三个参数中传递“with”,如下所示:

$this->assertRedirectedToRoute('posts.index', [] ,['flash']); 
希望能有帮助

PostsControllerTest::testStoreSuccess
Failed asserting that two strings are equal.
-- Expected
+++ Actual
@@ @@


/usr/share/nginx/www/laravelphpunitest/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:245
/usr/share/nginx/www/laravelphpunitest/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:260
/usr/share/nginx/www/laravelphpunitest/app/tests/controllers/PostsControllerTest.php:84
$this->assertRedirectedToRoute('posts.index', [] ,['flash']);