Skip to content

Commit

Permalink
Fix clean test
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jul 9, 2017
1 parent 3c576dc commit a92effa
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/phpunit/RestAPIDocumentTest.php
Expand Up @@ -144,11 +144,11 @@ public function testPushDocument()

echo __METHOD__.' Request POST url='.$url."\n";


// Send to non existant directory

dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit');

//$data = '{ "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "" }';
$data = array(
'filename'=>"mynewfile.txt",
Expand All @@ -158,19 +158,19 @@ public function testPushDocument()
'filecontent'=>"content text",
'fileencoding'=>""
);

$result = getURLContent($url, 'POST', $data, 1);
echo __METHOD__.' Result for sending document: '.var_export($result, true)."\n";
echo __METHOD__.' curl_error_no: '.$result['curl_error_no']."\n";
$object = json_decode($result['content'], true);
$this->assertNotNull($object, 'Parsing of json result must no be null');
$this->assertEquals('401', $object['error']['code']);


// Send to existant directory

dol_mkdir(DOL_DATA_ROOT.'/medias/tmpphpunit/tmpphpunit2');

$data = array(
'filename'=>"mynewfile.txt",
'modulepart'=>"medias",
Expand All @@ -187,5 +187,7 @@ public function testPushDocument()
$this->assertNotNull($object2, 'Parsing of json result must no be null');
$this->assertEquals($result2['curl_error_no'], '');
$this->assertEquals($result2['content'], 'true');

dol_delete_dir_recursive(DOL_DATA_ROOT.'/medias/tmpphpunit');
}
}

0 comments on commit a92effa

Please sign in to comment.