save_importer_instance #313
This commit is contained in:
parent
8931c32237
commit
d0e09f7b7e
|
@ -31,9 +31,14 @@ class TAINACAN_REST_Importers_Controller extends TAINACAN_UnitApiTestCase {
|
|||
}
|
||||
|
||||
public function test_update() {
|
||||
|
||||
|
||||
$importer = new \Tainacan\Importer\CSV();
|
||||
global $Tainacan_Importer_Handler;
|
||||
$slug='csv';
|
||||
if ($importer = $Tainacan_Importer_Handler->initialize_importer($slug)) {
|
||||
$response = $importer->_to_Array();
|
||||
$Tainacan_Importer_Handler->save_importer_instance($importer);
|
||||
} else {
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
$session_id = $importer->get_id();
|
||||
|
||||
$params = json_encode([
|
||||
|
@ -48,7 +53,6 @@ class TAINACAN_REST_Importers_Controller extends TAINACAN_UnitApiTestCase {
|
|||
'total_items' => 1234
|
||||
]
|
||||
]);
|
||||
|
||||
$request = new \WP_REST_Request('PATCH', $this->namespace . '/importers/session/' . $session_id);
|
||||
$request->set_body($params);
|
||||
|
||||
|
@ -56,18 +60,11 @@ class TAINACAN_REST_Importers_Controller extends TAINACAN_UnitApiTestCase {
|
|||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals(200, $response->get_status());
|
||||
|
||||
$__importer = $_SESSION['tainacan_importer'][$session_id];
|
||||
|
||||
$__importer = $Tainacan_Importer_Handler->get_importer_instance_by_session_id($session_id);
|
||||
$this->assertEquals('http://test.com', $__importer->get_url());
|
||||
$this->assertEquals(';', $__importer->get_option('delimiter'));
|
||||
|
||||
$this->assertEquals($__importer->get_url(), $data['url']);
|
||||
|
||||
$this->assertEquals(1234, $__importer->get_collections()[0]['total_items']);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue