begin tests on tainacan Old importer
This commit is contained in:
parent
b7839998b5
commit
ca9b855522
|
@ -765,9 +765,13 @@ class Old_Tainacan extends Importer
|
|||
*/
|
||||
public function get_total_items_from_source()
|
||||
{
|
||||
if(!isset($this->tmp_file)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||
$file_content = unserialize($file->fread($file->getSize()));
|
||||
|
||||
return $this->total_items = $file_content->found_items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use Tainacan\Importer;
|
|||
/**
|
||||
* Class Importer
|
||||
*
|
||||
* @group importer
|
||||
* @package Test_Tainacan
|
||||
*/
|
||||
|
||||
|
@ -45,8 +46,9 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
//}
|
||||
|
||||
//$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' );
|
||||
$url = 'http://localhost/';
|
||||
$url = 'http://localhost/wordpress_tainacan/';
|
||||
$_SESSION['tainacan_importer'][$id]->set_url($url);
|
||||
$_SESSION['tainacan_importer'][$id]->set_repository();
|
||||
|
||||
while (!$_SESSION['tainacan_importer'][$id]->is_finished())
|
||||
{
|
||||
|
@ -161,9 +163,9 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$file_name = 'demosaved.csv';
|
||||
$csv_importer = new Importer\CSV();
|
||||
$id = $csv_importer->get_id();
|
||||
|
||||
|
||||
$_SESSION['tainacan_importer'][$id]->set_items_per_step(2);
|
||||
|
||||
|
||||
// open the file "demosaved.csv" for writing
|
||||
$file = fopen($file_name, 'w');
|
||||
|
||||
|
@ -230,7 +232,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_mapping(), $map );
|
||||
|
||||
//execute the process
|
||||
|
||||
|
||||
$this->assertEquals(2, $_SESSION['tainacan_importer'][$id]->run(), 'first step should import 2 items');
|
||||
$this->assertEquals(4, $_SESSION['tainacan_importer'][$id]->run(), 'second step should import 2 items');
|
||||
$this->assertEquals(5, $_SESSION['tainacan_importer'][$id]->run(), 'third step should import 3 items');
|
||||
|
@ -250,4 +252,4 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
|||
$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' );
|
||||
$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue