File tree 2 files changed +28
-1
lines changed
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
172
172
return $ default ;
173
173
}
174
174
175
- if (false == preg_match ('/^[\+\-]?[0-9 ]*$/ ' , $ value )) {
175
+ if (false == preg_match ('/^0 [\+\-]?[0-7 ]*$/ ' , $ value )) {
176
176
throw InvalidQueryParameterTypeException::create ($ name , 'integer ' );
177
177
}
178
178
Original file line number Diff line number Diff line change @@ -134,6 +134,33 @@ public function testThrowIfQueryParameterNotInt()
134
134
$ dsn ->getInt ('aName ' );
135
135
}
136
136
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
+
137
164
/**
138
165
* @dataProvider provideFloatQueryParameters
139
166
*/
You can’t perform that action at this time.
0 commit comments