fix test instanceof Item_Metadata_Entity #17
This commit is contained in:
parent
875b828eea
commit
dbed32b98d
|
@ -183,7 +183,7 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
$item_id = $request['item_id'];
|
||||
$metadatum_id = $request['metadatum_id'];
|
||||
$value = $body['values'];
|
||||
$parent_meta_id = isset( $body['parent_meta_id'] ) && $parent_meta_id > 0 ? $body['parent_meta_id'] : null;
|
||||
$parent_meta_id = isset( $body['parent_meta_id'] ) && $body['parent_meta_id'] > 0 ? $body['parent_meta_id'] : null;
|
||||
|
||||
$item = $this->item_repository->fetch( $item_id );
|
||||
$metadatum = $this->metadatum_repository->fetch( $metadatum_id );
|
||||
|
@ -279,6 +279,11 @@ class REST_Item_Metadata_Controller extends REST_Controller {
|
|||
],
|
||||
'description' => __('The value(s) of item metadata')
|
||||
];
|
||||
$endpoint_args['parent_meta_id'] = [
|
||||
'type' => 'array/string/object/integer',
|
||||
'items' => ['type' => 'array/string/object/integer'],
|
||||
'description' => __('The parent meta ID for group children item metadatas')
|
||||
];
|
||||
}
|
||||
|
||||
return $endpoint_args;
|
||||
|
|
|
@ -42,8 +42,6 @@ class Item_Metadata_Entity extends Entity {
|
|||
if (!is_null($parent_meta_id) && is_int($parent_meta_id)) {
|
||||
$this->set_parent_meta_id($parent_meta_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -214,7 +212,7 @@ class Item_Metadata_Entity extends Entity {
|
|||
$metadata = new Metadatum( $child['id'] );
|
||||
$itemMetadata = new self( $this->get_item(), $metadata );
|
||||
$child_primitive_type = $metadata->get_metadata_type_object()->get_primitive_type();
|
||||
if ( $itemMetadata instanceof ItemMetadataEntity && $child_primitive_type === 'term' ) {
|
||||
if ( $itemMetadata instanceof Item_Metadata_Entity && $child_primitive_type === 'term' ) {
|
||||
$compounds[$child['id']] = $itemMetadata->_toArray();
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +221,7 @@ class Item_Metadata_Entity extends Entity {
|
|||
if( is_array($value) ) {
|
||||
foreach ($value as $itemMetadata) {
|
||||
$child_primitive_type = $itemMetadata->get_metadatum()->get_metadata_type_object()->get_primitive_type();
|
||||
if ( $itemMetadata instanceof ItemMetadataEntity && $child_primitive_type !== 'term' ) {
|
||||
if ( $itemMetadata instanceof Item_Metadata_Entity && $child_primitive_type !== 'term' ) {
|
||||
$compounds[$itemMetadata->get_metadatum()->get_id()] = $itemMetadata->_toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,8 +429,8 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
$this->assertEquals($metadata_order[0]['id'], $order[0]['id']);
|
||||
//$this->assertEquals($metadata_order[1]['id'], $order[1]['id']);
|
||||
//$this->assertEquals($metadata_order[2]['id'], $order[2]['id']);
|
||||
$this->assertEquals($metadata_order[3]['id'], $order[3]['id']);
|
||||
$this->assertEquals($metadata_order[4]['id'], $order[4]['id']);
|
||||
$this->assertEquals($metadata_order[1]['id'], $order[3]['id']);
|
||||
$this->assertEquals($metadata_order[2]['id'], $order[4]['id']);
|
||||
|
||||
$order = [
|
||||
['id' => $metadatum1->get_id(), 'enabled' => true],
|
||||
|
|
Loading…
Reference in New Issue