Skip to content

Commit b838c79

Browse files
committed
test: adds fromData model test
1 parent 29359f3 commit b838c79

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/wpunit/ModelTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,24 @@ public function testIsSet() {
292292
$this->assertTrue( $model->isSet( 'lastName' ) );
293293
}
294294

295+
public function testFromData() {
296+
$model = MockModel::fromData( [
297+
'id' => '1',
298+
'firstName' => 'Bill',
299+
'lastName' => 'Murray',
300+
'emails' => [ 'billMurray@givewp.com' ],
301+
'microseconds' => '1234567890',
302+
'number' => '1234567890',
303+
] );
304+
305+
$this->assertEquals( 1, $model->id );
306+
$this->assertEquals( 'Bill', $model->firstName );
307+
$this->assertEquals( 'Murray', $model->lastName );
308+
$this->assertEquals( [ 'billMurray@givewp.com' ], $model->emails );
309+
$this->assertEquals( 1234567890, $model->microseconds );
310+
$this->assertEquals( 1234567890, $model->number );
311+
}
312+
295313
/**
296314
* @since 1.0.0
297315
*

0 commit comments

Comments
 (0)