Merge branch 'develop'

This commit is contained in:
Mateus Machado Luna 2018-10-25 10:40:28 -03:00
commit abd670c61d
3 changed files with 10 additions and 16 deletions

View File

@ -160,7 +160,7 @@ class CSV extends Importer {
$valueToInsert = $this->handle_encoding( $values[ $column ] );
if( !is_numeric($metadatum_id) ){
$metadatum = $this->create_metadata( $metadatum_id, $collection_definition['id']);
$metadatum = $this->create_metadata( $headers[ $column ], $collection_definition['id']);
} else {
$metadatum = new \Tainacan\Entities\Metadatum($metadatum_id);
}

View File

@ -908,8 +908,8 @@ abstract class Importer {
* @throws \Exception
*/
protected function create_metadata( $metadata_description, $collection_id){
$taxonomy_repo = \Repositories\Taxonomy::get_instance();
$metadata_repo = \Repositories\Metadata::get_instance();
$taxonomy_repo = \Tainacan\Repositories\Taxonomies::get_instance();
$metadata_repo = \Tainacan\Repositories\Metadata::get_instance();
$properties = array_filter( explode('|', $metadata_description) );

View File

@ -258,7 +258,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
$file = fopen($file_name, 'w');
// save the column headers
fputcsv($file, array('Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
fputcsv($file, array('novo metadatao|text', 'Column 2', 'Column 3', 'Column 4', 'Column 5'));
// Sample data
$data = array(
@ -363,7 +363,12 @@ class ImporterTests extends TAINACAN_UnitTestCase {
//create a random mapping
$map = [];
foreach ( $metadata as $index => $metadatum ){
if( $index === 0){
$map['create_metadata'] = $headers[$index];
} else {
$map[$metadatum->get_id()] = $headers[$index];
}
}
$collection_definition['mapping'] = $map;
@ -383,17 +388,6 @@ class ImporterTests extends TAINACAN_UnitTestCase {
$items = $Tainacan_Items->fetch( ['order'=> 'ASC','orderby' => 'date'], $collection, 'OBJECT' );
foreach ( $items as $index => $item ) {
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadata_taxonomy );
if( in_array( $item->get_title(),[ 'Data 11','Data 51', 'Data 12','Data 52'] ) ){
$term = $singleItemMetadata->get_value();
$this->assertTrue(in_array( $term->get_name(),['DATA 151','DATA551'] ));
}
}
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_source_number_of_items(), count( $items ) );
}