diff --git a/src/Illuminate/Http/Concerns/InteractsWithInput.php b/src/Illuminate/Http/Concerns/InteractsWithInput.php index e00b1323d417..4f9f430b4ad8 100644 --- a/src/Illuminate/Http/Concerns/InteractsWithInput.php +++ b/src/Illuminate/Http/Concerns/InteractsWithInput.php @@ -64,7 +64,7 @@ public function bearerToken() * @param string|array $key * @return bool */ - public function exists($key) + public function has($key) { $keys = is_array($key) ? $key : func_get_args(); @@ -85,7 +85,7 @@ public function exists($key) * @param string|array $key * @return bool */ - public function has($key) + public function filled($key) { $keys = is_array($key) ? $key : func_get_args(); diff --git a/tests/Http/HttpRequestTest.php b/tests/Http/HttpRequestTest.php index daedecc8f6fd..f3e7513bcc3a 100644 --- a/tests/Http/HttpRequestTest.php +++ b/tests/Http/HttpRequestTest.php @@ -190,46 +190,50 @@ public function testSecureMethod() $this->assertTrue($request->secure()); } - public function testExistsMethod() + public function testHasMethod() { - $request = Request::create('/', 'GET', ['name' => 'Taylor']); - $this->assertTrue($request->exists('name')); - $this->assertFalse($request->exists('foo')); - $this->assertFalse($request->exists('name', 'email')); + $request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => '', 'city' => null]); + $this->assertTrue($request->has('name')); + $this->assertTrue($request->has('age')); + $this->assertTrue($request->has('city')); + $this->assertFalse($request->has('foo')); + $this->assertFalse($request->has('name', 'email')); $request = Request::create('/', 'GET', ['name' => 'Taylor', 'email' => 'foo']); - $this->assertTrue($request->exists('name')); - $this->assertTrue($request->exists('name', 'email')); + $this->assertTrue($request->has('name')); + $this->assertTrue($request->has('name', 'email')); $request = Request::create('/', 'GET', ['foo' => ['bar', 'bar']]); - $this->assertTrue($request->exists('foo')); + $this->assertTrue($request->has('foo')); $request = Request::create('/', 'GET', ['foo' => '', 'bar' => null]); - $this->assertTrue($request->exists('foo')); - $this->assertTrue($request->exists('bar')); + $this->assertTrue($request->has('foo')); + $this->assertTrue($request->has('bar')); $request = Request::create('/', 'GET', ['foo' => ['bar' => null, 'baz' => '']]); - $this->assertTrue($request->exists('foo.bar')); - $this->assertTrue($request->exists('foo.baz')); + $this->assertTrue($request->has('foo.bar')); + $this->assertTrue($request->has('foo.baz')); } - public function testHasMethod() + public function testFilledMethod() { - $request = Request::create('/', 'GET', ['name' => 'Taylor']); - $this->assertTrue($request->has('name')); - $this->assertFalse($request->has('foo')); - $this->assertFalse($request->has('name', 'email')); + $request = Request::create('/', 'GET', ['name' => 'Taylor', 'age' => '', 'city' => null]); + $this->assertTrue($request->filled('name')); + $this->assertFalse($request->filled('age')); + $this->assertFalse($request->filled('city')); + $this->assertFalse($request->filled('foo')); + $this->assertFalse($request->filled('name', 'email')); $request = Request::create('/', 'GET', ['name' => 'Taylor', 'email' => 'foo']); - $this->assertTrue($request->has('name')); - $this->assertTrue($request->has('name', 'email')); + $this->assertTrue($request->filled('name')); + $this->assertTrue($request->filled('name', 'email')); //test arrays within query string $request = Request::create('/', 'GET', ['foo' => ['bar', 'baz']]); - $this->assertTrue($request->has('foo')); + $this->assertTrue($request->filled('foo')); $request = Request::create('/', 'GET', ['foo' => ['bar' => 'baz']]); - $this->assertTrue($request->has('foo.bar')); + $this->assertTrue($request->filled('foo.bar')); } public function testInputMethod()