Skip to content

Commit 740cea1

Browse files
committed
chore: return method to be private
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 55884fa commit 740cea1

2 files changed

Lines changed: 21 additions & 14 deletions

File tree

src/Sign/JSignService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private function pkcs12Read(JSignParam $params)
205205
return [];
206206
}
207207

208-
public function exportToPkcs12(\OpenSSLCertificate|string $certificate, \OpenSSLAsymmetricKey|\OpenSSLCertificate|string $privateKey, string $password)
208+
private function exportToPkcs12(\OpenSSLCertificate|string $certificate, \OpenSSLAsymmetricKey|\OpenSSLCertificate|string $privateKey, string $password)
209209
{
210210
$certContent = null;
211211
openssl_pkcs12_export(

tests/JSignPDFTest.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Jeidison\JSignPDF\Sign;
44

55
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);
6+
global $mockExec;
7+
if ($mockExec) {
8+
$output = $mockExec;
9+
return $output;
10+
}
11+
return \exec($command, $output, $return_var);
1212
}
1313

1414
namespace Jeidison\JSignPDF\Tests;
@@ -27,8 +27,8 @@ class JSignPDFTest extends TestCase
2727

2828
protected function setUp(): void
2929
{
30-
global $mockExec;
31-
$mockExec = null;
30+
global $mockExec;
31+
$mockExec = null;
3232
$this->service = new JSignService();
3333
}
3434

@@ -54,7 +54,14 @@ private function getNewCert($password)
5454
$temporaryFile = tempnam(sys_get_temp_dir(), 'cfg');
5555
$csr = openssl_csr_new($csrNames, $privateKey);
5656
$x509 = openssl_csr_sign($csr, $rootCertificate, $rootPrivateKey, 365);
57-
return $this->service->exportToPkcs12($x509, $privateKey, $password);
57+
$certContent = null;
58+
openssl_pkcs12_export(
59+
$x509,
60+
$certContent,
61+
$privateKey,
62+
$password,
63+
);
64+
return $certContent;
5865
}
5966

6067
public function testSignSuccess()
@@ -73,16 +80,16 @@ public function testSignSuccess()
7380
*/
7481
public function testSignUsingDifferentPasswords(string $password)
7582
{
76-
global $mockExec;
83+
global $mockExec;
7784
if (!class_exists('JSignPDF\JSignPDFBin\JavaCommandService')) {
7885
$this->markTestSkipped('Install jsignpdf/jsignpdf-bin');
7986
}
8087
$params = JSignParamBuilder::instance()->withDefault();
8188
$params->setCertificate($this->getNewCert($password));
8289
$params->setPassword($password);
83-
$mockExec = 'Finished: Signature succesfully created.';
84-
$path = $params->getTempPdfSignedPath();
85-
file_put_contents($path, 'dummy');
90+
$mockExec = 'Finished: Signature succesfully created.';
91+
$path = $params->getTempPdfSignedPath();
92+
file_put_contents($path, 'dummy');
8693
$fileSigned = $this->service->sign($params);
8794
$this->assertNotNull($fileSigned);
8895
}

0 commit comments

Comments
 (0)