From f70c370cede7e1383c8c963ae0083826a6eb1587 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 28 Jan 2016 17:00:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0inputTest=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/thinkphp/library/think/inputTest.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/thinkphp/library/think/inputTest.php b/tests/thinkphp/library/think/inputTest.php index 8996c018..cdfeba8b 100644 --- a/tests/thinkphp/library/think/inputTest.php +++ b/tests/thinkphp/library/think/inputTest.php @@ -127,6 +127,15 @@ class inputTest extends \PHPUnit_Framework_TestCase $this->assertEquals(true, Input::post('d/b')); } + public function testHasValue() + { + $_GET['name'] = 'value'; + $this->assertEquals(true, Input::get('?name')); + $this->assertEquals(false, Input::get('?id')); + $this->assertEquals(true, Input::get('?get.name')); + $this->assertEquals(false, Input::get('?get.id')); + } + public function testSuperglobals() { Input::setFilter('trim'); @@ -165,7 +174,7 @@ class inputTest extends \PHPUnit_Framework_TestCase //$path = $_SERVER['PATH_INFO'] ? explode('/', $_SERVER['PATH_INFO'])[0] : ''; //$this->assertEquals($path, Input::path('0', '')); - $_FILES = ['file'=>['name'=>'test.png', 'type'=>'image/png', 'tmp_name'=>'/tmp/php5Wx0aJ', 'error'=>0, size=>15726]]; + $_FILES = ['file' => ['name' => 'test.png', 'type' => 'image/png', 'tmp_name' => '/tmp/php5Wx0aJ', 'error' => 0, size => 15726]]; $this->assertEquals('image/png', Input::file('file.type')); } @@ -173,7 +182,7 @@ class inputTest extends \PHPUnit_Framework_TestCase public function testFilterMerge() { Input::setFilter('htmlspecialchars'); - $input = ['a' => ' test<> ', 'b' => '']; + $input = ['a' => ' test<> ', 'b' => '']; $this->assertEquals(' test<> ', Input::data('a', '', '', false, $input)); $filters = ['trim']; $this->assertEquals('test<>', Input::data('a', '', $filters, false, $input));