-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommand.spec.php
More file actions
62 lines (45 loc) · 2.23 KB
/
Command.spec.php
File metadata and controls
62 lines (45 loc) · 2.23 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
<?php
/**
* This file is part of BlitzPHP Parametres.
*
* (c) 2025 Dimitri Sitchet Tomkeu <devcode.dst@gmail.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
use function Kahlan\expect;
describe('Parametres / Command', function () {
it('La commande `parametres:clear` fonctionne', function () {
config()->set('parametres.file.path', $path = storage_path('.parametres.json'));
$parametres = service('parametres');
$parametres->set('foo.site_name', 'Humpty');
$parametres->set('foo.site_name', 'Jack', 'context:male');
$parametres->set('foo.site_name', 'Jill', 'context:female');
$parametres->set('foo.site_name', 'Jane', 'context:female');
expect($parametres->get('foo.site_name'))->toBe('Humpty');
expect($parametres->get('foo.site_name', 'context:male'))->toBe('Jack');
expect($parametres->get('foo.site_name', 'context:female'))->toBe('Jane');
command('parametres:clear --yes');
expect($parametres->get('foo.site_name'))->toBeNull();
expect($parametres->get('foo.site_name', 'context:male'))->toBeNull();
expect($parametres->get('foo.site_name', 'context:female'))->toBeNull();
});
it('Publisher', function () {
config()->ghost('publisher')->set('publisher.restrictions', [ROOTPATH => '*']);
$path = CONFIG_PATH . 'parametres.php';
expect(file_exists($path))->toBeFalsy();
// conserver les fichiers originaux car a la fin, on suppimera tous les fichiers publiés
$original_files = array_map(fn ($f) => $f->getRelativePathname(), service('fs')->files(CONFIG_PATH));
command('publish');
// command('publish --namespace=BlitzPHP\\\\Parametres');
expect(file_exists($path))->toBeTruthy();
$content = file_get_contents($path);
expect(str_contains($content, 'Paramètres du gestionnaire "Database".'))->toBeTruthy();
foreach (service('fs')->files(CONFIG_PATH) as $f) {
if (! in_array($f->getRelativePathname(), $original_files, true)) {
@unlink($f->getPathname());
}
}
expect(file_exists($path))->toBeFalsy();
});
});