0 can be inserted into an integer number field via insert_model_entry() without throwing an error.
Decimal values can be inserting into a decimal number field via insert_model_entry() without throwing an error.
Currently on main, running wp eval "acm_test_import_post_content()"; after activating the test plugin below produces errors:
<?php
/* Plugin Name: WPE Test Plugin */
use function WPE\AtlasContentModeler\API\insert_model_entry;
function acm_test_import_post_content() {
$model_slug = 'rabbit';
$field_data = [
'name' => 'Peter',
'speedDec' => 2.2,
'speedInt' => 0,
];
$post_id = insert_model_entry( $model_slug, $field_data );
var_dump( $post_id );
}
Error sample:
class WPE\AtlasContentModeler\WP_Error#2322 (3) {
public $errors =>
array(2) {
'speedInt' =>
array(1) {
[0] =>
string(32) "speedInt must be of type integer"
}
'speedDec' =>
array(1) {
[0] =>
string(32) "speedDec must be of type decimal"
}
}
public $error_data =>
array(0) {
}
protected $additional_data =>
array(0) {
}
}
Checklist
I have:
[x] Added an entry to CHANGELOG.md.
Testing
Extended unit tests extensively to test validate_number_type more thoroughly.
To test manually:
Create a rabbits model with 'name' (text field), 'speedDec' (numeric field, decimal) and 'speedInt` (numeric field, integer) fields.
Create a file named test-plugin.php in wp-content/plugins/ with the PHP content above.
Activate the "WPE Test Plugin" plugin.
Run wp eval "acm_test_import_post_content();" in the command line.
You should see output including the generated post ID such as:
Description
Fixes
validate_number_type()
so that:insert_model_entry()
without throwing an error.insert_model_entry()
without throwing an error.Currently on
main
, runningwp eval "acm_test_import_post_content()";
after activating the test plugin below produces errors:Error sample:
Checklist
I have:
Testing
Extended unit tests extensively to test validate_number_type more thoroughly.
To test manually:
test-plugin.php
inwp-content/plugins/
with the PHP content above.wp eval "acm_test_import_post_content();"
in the command line.You should see output including the generated post ID such as: