Skip to content
Snippets Groups Projects
Commit c54a2ed4 authored by Unknown's avatar Unknown
Browse files

Correction d'un problème dans le tamponnage des actes sur les notifications ~Actes

parent a0011c0c
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ et adhère aux principes du [Semantic Versioning](http://semver.org/).
- Typo dans le nom d'un script supervisor ~Actes #328
- La signature par lot dans @ctes n'était plus fonctionnel ~Actes #334
- Modification script supervisor pour éviter les warning #327
- Correction d'un problème dans le tamponnage des actes sur les notifications ~Actes
## [3.0.1] - 2017-12-26
......
......@@ -5,22 +5,29 @@ class PDFStampWrapper {
private $pdf_stamp_url;
/** @var CurlWrapper */
private $curlWrapper;
/** @var CurlWrapperFactory */
private $curlWrapperFactory;
public function __construct($pdf_stamp_url) {
$this->pdf_stamp_url = $pdf_stamp_url;
$this->setCurlWrapper(new CurlWrapper());
$this->setCurlWrapperFactory(new CurlWrapperFactory());
}
public function setCurlWrapper(CurlWrapper $curlWrapper){
$this->curlWrapper = $curlWrapper;
public function setCurlWrapperFactory(CurlWrapperFactory $curlWrapperFactory){
$this->curlWrapperFactory = $curlWrapperFactory;
}
public function getLogoPath(){
return __DIR__."/../public.ssl/custom/images/s2low-stamp.png";
}
/**
* @param $pdf_filepath
* @param PDFStampData $pdfStampData
* @return bool|mixed
* @throws Exception
*/
public function stamp($pdf_filepath,PDFStampData $pdfStampData){
$date_affichage = "";
if ($pdfStampData->affichage_date){
......@@ -62,14 +69,14 @@ class PDFStampWrapper {
);
/* curl -F "file=@Courrier.pdf" -F "metadata=$SAMPLE" -X POST http://pdf-stamp:8080 (!) */
$this->curlWrapper->addPostFile('file',$pdf_filepath);
$this->curlWrapper->addPostData('metadata',json_encode(utf8_encode_array($data)));
$curlWrapper = $this->curlWrapperFactory->getNewInstance();
$curlWrapper->addPostFile('file',$pdf_filepath);
$curlWrapper->addPostData('metadata',json_encode(utf8_encode_array($data)));
$result = $this->curlWrapper->get($this->pdf_stamp_url);
$result = $curlWrapper->get($this->pdf_stamp_url);
if (!$result){
throw new Exception($this->curlWrapper->getLastError()." ".$this->curlWrapper->getLastOutput());
throw new Exception($curlWrapper->getLastError()." ".$curlWrapper->getLastOutput());
}
return $result;
}
......
......@@ -2,16 +2,21 @@
class PDFStampWrapperTest extends PHPUnit_Framework_TestCase {
private function getCurlWrapper($return_string){
private function getCurlWrapperFactory($return_string){
$curlWrapper = $this->getMockBuilder("CurlWrapper")->getMock();
$curlWrapper->expects($this->any())->method("get")->willReturn($return_string);
/** @var CurlWrapper $curlWrapper */
return $curlWrapper;
$curlWrapperFactory = $this->getMockBuilder("CurlWrapperFactory")->getMock();
$curlWrapperFactory->expects($this->any())->method("getNewInstance")->willReturn($curlWrapper);
/** @var CurlWrapperFactory $curlWrapperFactory */
return $curlWrapperFactory;
}
/**
* @throws Exception
*/
public function testStamp(){
$pdfStampWrapper = new PDFStampWrapper("http://pdf-stamp/");
$pdfStampWrapper->setCurlWrapper($this->getCurlWrapper("test"));
$pdfStampWrapper->setCurlWrapperFactory($this->getCurlWrapperFactory("test"));
$pdfStampData = new PDFStampData();
$pdfStampData->identifiant_unique = "toto";
$pdfStampData->affichage_date = "2017-09-18";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment