Updated export unit test
This commit is contained in:
@ -27,7 +27,7 @@ class ImportExport extends APIEndpoint {
|
|||||||
$mailChimp = new MailChimp($data['api_key']);
|
$mailChimp = new MailChimp($data['api_key']);
|
||||||
$subscribers = $mailChimp->getSubscribers($data['lists']);
|
$subscribers = $mailChimp->getSubscribers($data['lists']);
|
||||||
return $this->successResponse($subscribers);
|
return $this->successResponse($subscribers);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
return $this->errorResponse(array(
|
return $this->errorResponse(array(
|
||||||
$e->getCode() => $e->getMessage()
|
$e->getCode() => $e->getMessage()
|
||||||
));
|
));
|
||||||
|
@ -222,21 +222,36 @@ class ExportTest extends MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItRequiresWritableExportFile() {
|
function testItRequiresWritableExportFile() {
|
||||||
$this->export->export_path = '/fake_folder';
|
try {
|
||||||
$result = $this->export->process();
|
$this->export->export_path = '/fake_folder';
|
||||||
expect($result['errors'][0])
|
$this->export->process();
|
||||||
->equals("Couldn't save export file on the server");
|
$this->fail('Export did not throw an exception');
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
expect($e->getMessage())
|
||||||
|
->equals("Couldn't save export file on the server");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItCanProcess() {
|
function testItCanProcess() {
|
||||||
$this->export->export_file = $this->export->getExportFile('csv');
|
try {
|
||||||
$this->export->export_format_option = 'csv';
|
$this->export->export_file = $this->export->getExportFile('csv');
|
||||||
$result = $this->export->process();
|
$this->export->export_format_option = 'csv';
|
||||||
expect($result['result'])->true();
|
$result = $this->export->process();
|
||||||
$this->export->export_file = $this->export->getExportFile('xlsx');
|
} catch(\Exception $e) {
|
||||||
$this->export->export_format_option = 'xlsx';
|
$this->fail('Export to .csv process threw an exception');
|
||||||
$result = $this->export->process();
|
}
|
||||||
expect($result['result'])->true();
|
expect($result['totalExported'])->equals(3);
|
||||||
|
expect($result['exportFileURL'])->notEmpty();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->export->export_file = $this->export->getExportFile('xlsx');
|
||||||
|
$this->export->export_format_option = 'xlsx';
|
||||||
|
$result = $this->export->process();
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
$this->fail('Export to .xlsx process threw an exception');
|
||||||
|
}
|
||||||
|
expect($result['totalExported'])->equals(3);
|
||||||
|
expect($result['exportFileURL'])->notEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _after() {
|
function _after() {
|
||||||
|
Reference in New Issue
Block a user