From 3cbd876cb64e696c729e0cc4ff4cdcc7173a386d Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 26 Aug 2015 16:09:22 +0200 Subject: [PATCH 1/2] [input] Test for getXValue after isValid --- test/InputTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/InputTest.php b/test/InputTest.php index a24d47ca..4734f126 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -350,6 +350,8 @@ public function testIsRequiredVsAllowEmptyVsContinueIfEmptyVsIsValid( 'isValid() value not match. Detail: ' . json_encode($this->input->getMessages()) ); $this->assertEquals($expectedMessages, $this->input->getMessages(), 'getMessages() value not match'); + $this->assertEquals($value, $this->input->getRawValue(), 'getRawValue() must return the value always'); + $this->assertEquals($value, $this->input->getValue(), 'getValue() must return the filtered value always'); } /** From 7bda89f2a34ea7b06227d6736595be53740d39aa Mon Sep 17 00:00:00 2001 From: Maks3w Date: Wed, 2 Sep 2015 08:14:50 +0200 Subject: [PATCH 2/2] normalize mixedValueProvider --- test/ArrayInputTest.php | 2 +- test/FileInputTest.php | 21 +++++++++++++++ test/InputTest.php | 60 ++++++++++++++++++++++++++++++++--------- 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/test/ArrayInputTest.php b/test/ArrayInputTest.php index 4d613aed..6c83ef81 100644 --- a/test/ArrayInputTest.php +++ b/test/ArrayInputTest.php @@ -208,7 +208,7 @@ public function mixedValueProvider() { $dataSets = parent::mixedValueProvider(); array_walk($dataSets, function (&$set) { - $set[0] = [$set[0]]; // Wrap value into an array. + $set['raw'] = [$set['raw']]; // Wrap value into an array. }); return $dataSets; diff --git a/test/FileInputTest.php b/test/FileInputTest.php index 1c9f12c5..401bf14c 100644 --- a/test/FileInputTest.php +++ b/test/FileInputTest.php @@ -456,4 +456,25 @@ public function emptyValueProvider() ], ]; } + + public function mixedValueProvider() + { + $fooUploadErrOk = [ + 'tmp_name' => 'foo', + 'error' => UPLOAD_ERR_OK, + ]; + + return [ + 'single' => [ + 'raw' => $fooUploadErrOk, + 'filtered' => $fooUploadErrOk, + ], + 'multi' => [ + 'raw' => [ + $fooUploadErrOk, + ], + 'filtered' => $fooUploadErrOk, + ], + ]; + } } diff --git a/test/InputTest.php b/test/InputTest.php index 4734f126..2ac49c53 100644 --- a/test/InputTest.php +++ b/test/InputTest.php @@ -553,19 +553,55 @@ public function mixedValueProvider() { return [ // Description => [$value] - '"0"' => ['0'], - '0' => [0], - '0.0' => [0.0], - 'false' => [false], - 'php' => ['php'], - 'whitespace' => [' '], - '1' => [1], - '1.0' => [1.0], - 'true' => [true], - '["php"]' => [['php']], - 'object' => [new stdClass()], + '"0"' => [ + 'raw' => '0', + 'filtered' => '0', + ], + '0' => [ + 'raw' => 0, + 'filtered' => 0, + ], + '0.0' => [ + 'raw' => 0.0, + 'filtered' => 0.0, + ], + 'false' => [ + 'raw' => false, + 'filtered' => false, + ], + 'php' => [ + 'raw' => 'php', + 'filtered' => 'php', + ], + 'whitespace' => [ + 'raw' => ' ', + 'filtered' => ' ', + ], + '1' => [ + 'raw' => 1, + 'filtered' => 1, + ], + '1.0' => [ + 'raw' => 1.0, + 'filtered' => 1.0, + ], + 'true' => [ + 'raw' => true, + 'filtered' => true, + ], + '["php"]' => [ + 'raw' => ['php'], + 'filtered' => ['php'], + ], + 'object' => [ + 'raw' => new stdClass(), + 'filtered' => new stdClass(), + ], // @codingStandardsIgnoreStart - 'callable' => [function () {}], + 'callable' => [ + 'raw' => function () {}, + 'filtered' => function () {}, + ], // @codingStandardsIgnoreEnd ]; }