Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
s2low
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libriciel
s2low
Commits
c54a2ed4
"git@gitlab.adullact.net:pixelhumain/co2.git" did not exist on "98728a03045fbd3b59c9805043e934d413deccf2"
Commit
c54a2ed4
authored
7 years ago
by
Unknown
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
class/PDFStampWrapper.class.php
+17
-10
17 additions, 10 deletions
class/PDFStampWrapper.class.php
test/PHPUnit/class/PDFStampWrapperTest.php
+9
-4
9 additions, 4 deletions
test/PHPUnit/class/PDFStampWrapperTest.php
with
27 additions
and
14 deletions
CHANGELOG.md
+
1
−
0
View file @
c54a2ed4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
class/PDFStampWrapper.class.php
+
17
−
10
View file @
c54a2ed4
...
...
@@ -5,22 +5,29 @@ class PDFStampWrapper {
private
$pdf_stamp_url
;
/** @var
CurlWrapper */
private
$curlWrapper
;
/** @var CurlWrapper
Factory
*/
private
$curlWrapper
Factory
;
public
function
__construct
(
$pdf_stamp_url
)
{
$this
->
pdf_stamp_url
=
$pdf_stamp_url
;
$this
->
setCurlWrapper
(
new
CurlWrapper
());
$this
->
setCurlWrapper
Factory
(
new
CurlWrapper
Factory
());
}
public
function
setCurlWrapper
(
CurlWrapper
$curlWrapper
){
$this
->
curlWrapper
=
$curlWrapper
;
public
function
setCurlWrapper
Factory
(
CurlWrapper
Factory
$curlWrapper
Factory
){
$this
->
curlWrapper
Factory
=
$curlWrapper
Factory
;
}
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
;
}
...
...
This diff is collapsed.
Click to expand it.
test/PHPUnit/class/PDFStampWrapperTest.php
+
9
−
4
View file @
c54a2ed4
...
...
@@ -2,16 +2,21 @@
class
PDFStampWrapperTest
extends
PHPUnit_Framework_TestCase
{
private
function
getCurlWrapper
(
$return_string
){
private
function
getCurlWrapper
Factory
(
$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
->
setCurlWrapper
Factory
(
$this
->
getCurlWrapper
Factory
(
"test"
));
$pdfStampData
=
new
PDFStampData
();
$pdfStampData
->
identifiant_unique
=
"toto"
;
$pdfStampData
->
affichage_date
=
"2017-09-18"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment