File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class MockModel extends Model {
1111 'lastName ' => 'string ' ,
1212 'emails ' => [ 'array ' , [] ],
1313 'microseconds ' => 'float ' ,
14- 'number ' => 'number ' ,
14+ 'number ' => 'int ' ,
15+ 'date ' => \DateTime::class,
1516 ];
1617}
Original file line number Diff line number Diff line change @@ -275,10 +275,8 @@ public function testShouldSetMultipleAttributes() {
275275
276276 /**
277277 * @since 1.0.0
278- *
279- * @return void
280278 */
281- public function testIsSet () {
279+ public function testIsSet (): void {
282280 $ model = new MockModel ();
283281
284282 // This has a default so we should see as set.
@@ -292,7 +290,10 @@ public function testIsSet() {
292290 $ this ->assertTrue ( $ model ->isSet ( 'lastName ' ) );
293291 }
294292
295- public function testFromData () {
293+ /**
294+ * @since 2.0.0
295+ */
296+ public function testFromDataShouldCreateInstanceWithCorrectTypes (): void {
296297 $ model = MockModel::fromData ( [
297298 'id ' => '1 ' ,
298299 'firstName ' => 'Bill ' ,
@@ -310,6 +311,17 @@ public function testFromData() {
310311 $ this ->assertEquals ( 1234567890 , $ model ->number );
311312 }
312313
314+ /**
315+ * @since 2.0.0
316+ */
317+ public function testFromDataShouldThrowExceptionForNonPrimitiveTypes (): void {
318+ $ this ->expectException ( Config::getInvalidArgumentException () );
319+
320+ MockModel::fromData ( [
321+ 'date ' => '123 ' ,
322+ ] );
323+ }
324+
313325 /**
314326 * @since 1.0.0
315327 *
You can’t perform that action at this time.
0 commit comments