11<?php
22
3+ namespace Jeidison \JSignPDF \Sign ;
4+
5+ function exec (string $ command , array &$ output = null , int &$ return_var = null ) {
6+ global $ mockExec ;
7+ if ($ mockExec ) {
8+ $ output = $ mockExec ;
9+ return $ output ;
10+ }
11+ return \exec ($ command , $ output , $ return_var );
12+ }
13+
314namespace Jeidison \JSignPDF \Tests ;
415
516use Exception ;
@@ -16,6 +27,8 @@ class JSignPDFTest extends TestCase
1627
1728 protected function setUp (): void
1829 {
30+ global $ mockExec ;
31+ $ mockExec = null ;
1932 $ this ->service = new JSignService ();
2033 }
2134
@@ -57,17 +70,21 @@ public function testSignSuccess()
5770
5871 /**
5972 * @dataProvider providerSignUsingDifferentPasswords
60- * @doesNotPerformAssertions
6173 */
6274 public function testSignUsingDifferentPasswords (string $ password )
6375 {
76+ global $ mockExec ;
6477 if (!class_exists ('JSignPDF\JSignPDFBin\JavaCommandService ' )) {
6578 $ this ->markTestSkipped ('Install jsignpdf/jsignpdf-bin ' );
6679 }
6780 $ params = JSignParamBuilder::instance ()->withDefault ();
6881 $ params ->setCertificate ($ this ->getNewCert ($ password ));
6982 $ params ->setPassword ($ password );
70- $ this ->service ->validation ($ params );
83+ $ mockExec = 'Finished: Signature succesfully created. ' ;
84+ $ path = $ params ->getTempPdfSignedPath ();
85+ file_put_contents ($ path , 'dummy ' );
86+ $ fileSigned = $ this ->service ->sign ($ params );
87+ $ this ->assertNotNull ($ fileSigned );
7188 }
7289
7390 public function providerSignUsingDifferentPasswords ()
0 commit comments