-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCertConfigTest.php
More file actions
101 lines (85 loc) · 3.22 KB
/
CertConfigTest.php
File metadata and controls
101 lines (85 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
declare(strict_types=1);
namespace LibreCodeCoop\NfsePHP\Tests\Unit\Config;
use LibreCodeCoop\NfsePHP\Config\CertConfig;
use LibreCodeCoop\NfsePHP\Tests\TestCase;
/**
* @covers \LibreCodeCoop\NfsePHP\Config\CertConfig
*/
class CertConfigTest extends TestCase
{
public function testStoresAllProperties(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
transportCertificatePath: '/etc/nfse/certs/client.crt.pem',
transportPrivateKeyPath: '/etc/nfse/certs/client.key.pem',
);
self::assertSame('29842527000145', $config->cnpj);
self::assertSame('/etc/nfse/certs/company.pfx', $config->pfxPath);
self::assertSame('secret/nfse/29842527000145', $config->vaultPath);
self::assertSame('/etc/nfse/certs/client.crt.pem', $config->transportCertificatePath);
self::assertSame('/etc/nfse/certs/client.key.pem', $config->transportPrivateKeyPath);
}
public function testCnpjIsReadonly(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
);
$this->expectException(\Error::class);
/** @phpstan-ignore-next-line */
$config->cnpj = 'other';
}
public function testPfxPathIsReadonly(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
);
$this->expectException(\Error::class);
/** @phpstan-ignore-next-line */
$config->pfxPath = 'other';
}
public function testVaultPathIsReadonly(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
);
$this->expectException(\Error::class);
/** @phpstan-ignore-next-line */
$config->vaultPath = 'other';
}
public function testTransportCertificatePathIsReadonly(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
transportCertificatePath: '/etc/nfse/certs/client.crt.pem',
);
$this->expectException(\Error::class);
/** @phpstan-ignore-next-line */
$config->transportCertificatePath = 'other';
}
public function testTransportPrivateKeyPathIsReadonly(): void
{
$config = new CertConfig(
cnpj: '29842527000145',
pfxPath: '/etc/nfse/certs/company.pfx',
vaultPath: 'secret/nfse/29842527000145',
transportPrivateKeyPath: '/etc/nfse/certs/client.key.pem',
);
$this->expectException(\Error::class);
/** @phpstan-ignore-next-line */
$config->transportPrivateKeyPath = 'other';
}
}