diff --git a/src/Illuminate/Testing/AssertableJsonString.php b/src/Illuminate/Testing/AssertableJsonString.php index 1964a7c5ce7..584360b2c3c 100644 --- a/src/Illuminate/Testing/AssertableJsonString.php +++ b/src/Illuminate/Testing/AssertableJsonString.php @@ -213,11 +213,11 @@ public function assertMissingExact(array $data) /** * Assert that the expected value and type exists at the given path in the response. * - * @param string $path * @param mixed $expect + * @param string $path * @return $this */ - public function assertPath($path, $expect) + public function assertPath($expect, $path) { PHPUnit::assertSame($expect, $this->json($path)); diff --git a/src/Illuminate/Testing/TestResponse.php b/src/Illuminate/Testing/TestResponse.php index 2770f1b6079..35895082b7e 100644 --- a/src/Illuminate/Testing/TestResponse.php +++ b/src/Illuminate/Testing/TestResponse.php @@ -687,13 +687,13 @@ public function assertJson($value, $strict = false) /** * Assert that the expected value and type exists at the given path in the response. * - * @param string $path * @param mixed $expect + * @param string $path * @return $this */ - public function assertJsonPath($path, $expect) + public function assertJsonPath($expect, $path) { - $this->decodeResponseJson()->assertPath($path, $expect); + $this->decodeResponseJson()->assertPath($expect, $path); return $this; } diff --git a/tests/Testing/TestResponseTest.php b/tests/Testing/TestResponseTest.php index 6d14cd4b660..ce123c43dd2 100644 --- a/tests/Testing/TestResponseTest.php +++ b/tests/Testing/TestResponseTest.php @@ -765,33 +765,33 @@ public function testAssertJsonPath() { $response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceStub)); - $response->assertJsonPath('0.foo', 'foo 0'); + $response->assertJsonPath('foo 0', '0.foo'); - $response->assertJsonPath('0.foo', 'foo 0'); - $response->assertJsonPath('0.bar', 'bar 0'); - $response->assertJsonPath('0.foobar', 'foobar 0'); + $response->assertJsonPath('foo 0', '0.foo'); + $response->assertJsonPath('bar 0', '0.bar'); + $response->assertJsonPath('foobar 0', '0.foobar'); $response = TestResponse::fromBaseResponse(new Response(new JsonSerializableMixedResourcesStub)); - $response->assertJsonPath('foo', 'bar'); + $response->assertJsonPath('bar', 'foo'); - $response->assertJsonPath('foobar.foobar_foo', 'foo'); - $response->assertJsonPath('foobar.foobar_bar', 'bar'); + $response->assertJsonPath('foo', 'foobar.foobar_foo'); + $response->assertJsonPath('bar', 'foobar.foobar_bar'); - $response->assertJsonPath('foobar.foobar_foo', 'foo')->assertJsonPath('foobar.foobar_bar', 'bar'); + $response->assertJsonPath('foo', 'foobar.foobar_foo')->assertJsonPath('bar', 'foobar.foobar_bar'); - $response->assertJsonPath('bars', [ + $response->assertJsonPath([ ['bar' => 'foo 0', 'foo' => 'bar 0'], ['bar' => 'foo 1', 'foo' => 'bar 1'], ['bar' => 'foo 2', 'foo' => 'bar 2'], - ]); - $response->assertJsonPath('bars.0', ['bar' => 'foo 0', 'foo' => 'bar 0']); + ], 'bars'); + $response->assertJsonPath(['bar' => 'foo 0', 'foo' => 'bar 0'], 'bars.0'); $response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceWithIntegersStub)); - $response->assertJsonPath('0.id', 10); - $response->assertJsonPath('1.id', 20); - $response->assertJsonPath('2.id', 30); + $response->assertJsonPath(10, '0.id'); + $response->assertJsonPath(20, '1.id'); + $response->assertJsonPath(30, '2.id'); } public function testAssertJsonPathCanFail() @@ -801,7 +801,7 @@ public function testAssertJsonPathCanFail() $response = TestResponse::fromBaseResponse(new Response(new JsonSerializableSingleResourceWithIntegersStub)); - $response->assertJsonPath('0.id', '10'); + $response->assertJsonPath('10', '0.id'); } public function testAssertJsonFragment()