File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ public function getOctal(string $name, int $default = null): ?int
172172 return $ default ;
173173 }
174174
175- if (false == preg_match ('/^[\+\-]?[0-9 ]*$/ ' , $ value )) {
175+ if (false == preg_match ('/^0 [\+\-]?[0-7 ]*$/ ' , $ value )) {
176176 throw InvalidQueryParameterTypeException::create ($ name , 'integer ' );
177177 }
178178
Original file line number Diff line number Diff line change @@ -134,6 +134,33 @@ public function testThrowIfQueryParameterNotInt()
134134 $ dsn ->getInt ('aName ' );
135135 }
136136
137+ public function testThrowIfQueryParameterNotOctalButString ()
138+ {
139+ $ dsn = new Dsn ('foo:?aName=notInt ' );
140+
141+ $ this ->expectException (InvalidQueryParameterTypeException::class);
142+ $ this ->expectExceptionMessage ('The query parameter "aName" has invalid type. It must be "integer" ' );
143+ $ dsn ->getOctal ('aName ' );
144+ }
145+
146+ public function testThrowIfQueryParameterNotOctalButDecimal ()
147+ {
148+ $ dsn = new Dsn ('foo:?aName=123 ' );
149+
150+ $ this ->expectException (InvalidQueryParameterTypeException::class);
151+ $ this ->expectExceptionMessage ('The query parameter "aName" has invalid type. It must be "integer" ' );
152+ $ dsn ->getOctal ('aName ' );
153+ }
154+
155+ public function testThrowIfQueryParameterInvalidOctal ()
156+ {
157+ $ dsn = new Dsn ('foo:?aName=0128 ' );
158+
159+ $ this ->expectException (InvalidQueryParameterTypeException::class);
160+ $ this ->expectExceptionMessage ('The query parameter "aName" has invalid type. It must be "integer" ' );
161+ $ dsn ->getOctal ('aName ' );
162+ }
163+
137164 /**
138165 * @dataProvider provideFloatQueryParameters
139166 */
You can’t perform that action at this time.
0 commit comments