diff --git a/admin/class-gcmi-activator.php b/admin/class-gcmi-activator.php index acce076..5a1b8e9 100644 --- a/admin/class-gcmi-activator.php +++ b/admin/class-gcmi-activator.php @@ -82,20 +82,25 @@ class GCMI_Activator { ), array( 'name' => 'stati', - /* 'downd_name' => 'stati.zip', */ 'downd_name' => 'stati.csv', 'featured_csv' => 'stati.csv', - /* 'remote_file' => 'Elenco-codici-e-denominazioni-unita-territoriali-estere.zip', */ 'remote_file' => 'Elenco-codici-e-denominazioni-al-31_12_2023.csv', - /* 'remote_URL' => 'https://www.istat.it/it/files//2011/01/Elenco-codici-e-denominazioni-unita-territoriali-estere.zip', */ 'remote_URL' => 'https://raw.githubusercontent.com/MocioF/campi-moduli-italiani/main/assets/data/Elenco-codici-e-denominazioni-al-31_12_2023.csv', 'table_name' => GCMI_TABLE_PREFIX . 'stati', 'optN_dwdtime' => 'gcmi_stati_downloaded_time', 'optN_remoteUpd' => 'gcmi_stati_remote_file_time', 'remoteUpd_method' => 'get_headers_by_get', - /* 'file_type' => 'zip', */ 'file_type' => 'csv', 'orig_encoding' => 'ISO-8859-1', + + /** + * Valori utilizzati per scaricare il file da istat + * + * 'downd_name' => 'stati.zip', + * 'remote_file' => 'Elenco-codici-e-denominazioni-unita-territoriali-estere.zip', + * 'remote_URL' => 'https://www.istat.it/it/files//2011/01/Elenco-codici-e-denominazioni-unita-territoriali-estere.zip', + * 'file_type' => 'zip', + */ ), array( 'name' => 'stati_cessati', @@ -796,7 +801,6 @@ public static function download_file( $remoteurl, $tmp_dwld_dir, $filename ) { 'timeout' => 300, 'stream' => true, 'sslverify' => true, - /* 'sslcertificates' => GCMI_PLUGIN_DIR . '/admin/assets/istat-it-catena.pem', */ 'filename' => $tmpfname, ); if( strpos( $remoteurl, 'istat.it' ) !== false ) { diff --git a/tests/phpunit/test-class-campi-moduli-italiani-activator.php b/tests/phpunit/test-class-campi-moduli-italiani-activator.php index c9bc7de..553fc0e 100644 --- a/tests/phpunit/test-class-campi-moduli-italiani-activator.php +++ b/tests/phpunit/test-class-campi-moduli-italiani-activator.php @@ -112,4 +112,27 @@ public function provideDownloadedTimes() { ), ); } + + /** + * @dataProvider remoteFileArray + * @group downloadf + */ + public function test_download_file( $name, $downd_name, $featured_csv, $remote_file, $remote_URL ) { + $tmp_dir = $this->gcmi_activator::make_tmp_dwld_dir(); + $this->gcmi_activator->download_file( $remote_URL, $tmp_dir, $downd_name ); + $tmpfname = $tmp_dir . $downd_name; + $this->assertFileExists( $tmpfname ); +} + + public function remoteFileArray(){ + $main_array = GCMI_Activator::$database_file_info; + $download_array = array(); + foreach( $main_array as $item ) { + if ( 'html' !== $item['file_type'] ) { + $download_array[] = $item; + } + } + return $download_array; + } + }