1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* (c) Christian Gripp <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Core23\AntiSpamBundle\Tests\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Core23\AntiSpamBundle\DependencyInjection\Configuration; |
15
|
|
|
use PHPUnit\Framework\TestCase; |
16
|
|
|
use Symfony\Component\Config\Definition\Processor; |
17
|
|
|
|
18
|
|
|
final class ConfigurationTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
public function testDefaultOptions(): void |
21
|
|
|
{ |
22
|
|
|
$processor = new Processor(); |
23
|
|
|
|
24
|
|
|
$config = $processor->processConfiguration(new Configuration(), [[ |
25
|
|
|
]]); |
26
|
|
|
|
27
|
|
|
$expected = [ |
28
|
|
|
'twig' => [ |
29
|
|
|
'mail' => [ |
30
|
|
|
'css_class' => 'spamme', |
31
|
|
|
'dot_text' => ['[DOT]', '(DOT)', '[.]'], |
32
|
|
|
'at_text' => ['[AT]', '(AT)', '[ÄT]'], |
33
|
|
|
], |
34
|
|
|
], |
35
|
|
|
'time' => [ |
36
|
|
|
'min' => 5, |
37
|
|
|
'max' => 3600, |
38
|
|
|
'global' => false, |
39
|
|
|
], |
40
|
|
|
'honeypot' => [ |
41
|
|
|
'field' => 'email_address', |
42
|
|
|
'class' => 'hidden', |
43
|
|
|
'global' => false, |
44
|
|
|
'provider' => 'core23_antispam.provider.session', |
45
|
|
|
], |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
$this->assertSame($expected, $config); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testOptions(): void |
52
|
|
|
{ |
53
|
|
|
$processor = new Processor(); |
54
|
|
|
|
55
|
|
|
$config = $processor->processConfiguration(new Configuration(), [[ |
56
|
|
|
'twig' => [ |
57
|
|
|
'mail' => [ |
58
|
|
|
'css_class' => 'spamme', |
59
|
|
|
'dot_text' => ['[DOT]'], |
60
|
|
|
'at_text' => ['[AT'], |
61
|
|
|
], |
62
|
|
|
], |
63
|
|
|
'time' => [ |
64
|
|
|
'min' => 0, |
65
|
|
|
'max' => 600, |
66
|
|
|
'global' => true, |
67
|
|
|
], |
68
|
|
|
'honeypot' => [ |
69
|
|
|
'field' => 'custom', |
70
|
|
|
'class' => 'hide', |
71
|
|
|
'global' => true, |
72
|
|
|
'provider' => 'core23_antispam.provider.custom', |
73
|
|
|
], |
74
|
|
|
]]); |
75
|
|
|
|
76
|
|
|
$expected = [ |
77
|
|
|
'twig' => [ |
78
|
|
|
'mail' => [ |
79
|
|
|
'css_class' => 'spamme', |
80
|
|
|
'dot_text' => ['[DOT]'], |
81
|
|
|
'at_text' => ['[AT'], |
82
|
|
|
], |
83
|
|
|
], |
84
|
|
|
'time' => [ |
85
|
|
|
'min' => 0, |
86
|
|
|
'max' => 600, |
87
|
|
|
'global' => true, |
88
|
|
|
], |
89
|
|
|
'honeypot' => [ |
90
|
|
|
'field' => 'custom', |
91
|
|
|
'class' => 'hide', |
92
|
|
|
'global' => true, |
93
|
|
|
'provider' => 'core23_antispam.provider.custom', |
94
|
|
|
], |
95
|
|
|
]; |
96
|
|
|
|
97
|
|
|
$this->assertSame($expected, $config); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|