Skip to content

Commit eeb87b7

Browse files
committed
test(config): add CertConfig unit tests
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 543413a commit eeb87b7

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
// SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
4+
// SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
declare(strict_types=1);
7+
8+
namespace LibreCodeCoop\NfsePHP\Tests\Unit\Config;
9+
10+
use LibreCodeCoop\NfsePHP\Config\CertConfig;
11+
use LibreCodeCoop\NfsePHP\Tests\TestCase;
12+
13+
/**
14+
* @covers \LibreCodeCoop\NfsePHP\Config\CertConfig
15+
*/
16+
class CertConfigTest extends TestCase
17+
{
18+
public function testStoresAllProperties(): void
19+
{
20+
$config = new CertConfig(
21+
cnpj: '29842527000145',
22+
pfxPath: '/etc/nfse/certs/company.pfx',
23+
vaultPath: 'secret/nfse/29842527000145',
24+
);
25+
26+
self::assertSame('29842527000145', $config->cnpj);
27+
self::assertSame('/etc/nfse/certs/company.pfx', $config->pfxPath);
28+
self::assertSame('secret/nfse/29842527000145', $config->vaultPath);
29+
}
30+
31+
public function testCnpjIsReadonly(): void
32+
{
33+
$config = new CertConfig(
34+
cnpj: '29842527000145',
35+
pfxPath: '/etc/nfse/certs/company.pfx',
36+
vaultPath: 'secret/nfse/29842527000145',
37+
);
38+
39+
$this->expectException(\Error::class);
40+
/** @phpstan-ignore-next-line */
41+
$config->cnpj = 'other';
42+
}
43+
44+
public function testPfxPathIsReadonly(): void
45+
{
46+
$config = new CertConfig(
47+
cnpj: '29842527000145',
48+
pfxPath: '/etc/nfse/certs/company.pfx',
49+
vaultPath: 'secret/nfse/29842527000145',
50+
);
51+
52+
$this->expectException(\Error::class);
53+
/** @phpstan-ignore-next-line */
54+
$config->pfxPath = 'other';
55+
}
56+
57+
public function testVaultPathIsReadonly(): void
58+
{
59+
$config = new CertConfig(
60+
cnpj: '29842527000145',
61+
pfxPath: '/etc/nfse/certs/company.pfx',
62+
vaultPath: 'secret/nfse/29842527000145',
63+
);
64+
65+
$this->expectException(\Error::class);
66+
/** @phpstan-ignore-next-line */
67+
$config->vaultPath = 'other';
68+
}
69+
}

0 commit comments

Comments
 (0)