These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests\Controller; |
||
3 | |||
4 | use Redaxscript\Controller; |
||
5 | use Redaxscript\Db; |
||
6 | use Redaxscript\Tests\TestCaseAbstract; |
||
7 | |||
8 | /** |
||
9 | * CommentTest |
||
10 | * |
||
11 | * @since 3.0.0 |
||
12 | * |
||
13 | * @package Redaxscript |
||
14 | * @category Tests |
||
15 | * @author Henry Ruhs |
||
16 | * @author Balázs Szilágyi |
||
17 | * |
||
18 | * @covers Redaxscript\Controller\Comment |
||
19 | * @covers Redaxscript\Controller\ControllerAbstract |
||
20 | */ |
||
21 | |||
22 | class CommentTest extends TestCaseAbstract |
||
23 | { |
||
24 | /** |
||
25 | * setUp |
||
26 | * |
||
27 | * @since 3.1.0 |
||
28 | */ |
||
29 | |||
30 | public function setUp() : void |
||
31 | { |
||
32 | parent::setUp(); |
||
33 | $optionArray = $this->getOptionArray(); |
||
34 | $installer = $this->installerFactory(); |
||
35 | $installer->init(); |
||
36 | $installer->rawCreate(); |
||
37 | $installer->insertSettings($optionArray); |
||
38 | Db::forTablePrefix('articles') |
||
39 | ->create() |
||
40 | ->set( |
||
41 | [ |
||
42 | 'title' => 'Article One', |
||
43 | 'alias' => 'article-one' |
||
44 | |||
45 | ]) |
||
46 | ->save(); |
||
47 | $setting = $this->settingFactory(); |
||
48 | $setting->set('captcha', 1); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * tearDown |
||
53 | * |
||
54 | * @since 3.1.0 |
||
55 | */ |
||
56 | |||
57 | public function tearDown() : void |
||
58 | { |
||
59 | $this->dropDatabase(); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * testProcess |
||
64 | * |
||
65 | * @since 3.0.0 |
||
66 | * |
||
67 | * @param array $postArray |
||
68 | * @param array $settingArray |
||
69 | * @param string $method |
||
70 | * @param string $expect |
||
71 | * |
||
72 | * @dataProvider providerAutoloader |
||
73 | */ |
||
74 | |||
75 | public function testProcess(array $postArray = [], array $settingArray = [], string $method = null, string $expect = null) : void |
||
76 | { |
||
77 | /* setup */ |
||
78 | |||
79 | $this->_request->set('post', $postArray); |
||
80 | $setting = $this->settingFactory(); |
||
81 | $setting->set('notification', $settingArray['notification']); |
||
82 | $setting->set('moderation', $settingArray['moderation']); |
||
83 | if ($method) |
||
0 ignored issues
–
show
|
|||
84 | { |
||
85 | $commentController = $this |
||
86 | ->getMockBuilder('Redaxscript\Controller\Comment') |
||
87 | ->setConstructorArgs( |
||
88 | [ |
||
89 | $this->_registry, |
||
90 | $this->_request, |
||
91 | $this->_language, |
||
92 | $this->_config |
||
93 | ]) |
||
94 | ->setMethods( |
||
95 | [ |
||
96 | $method |
||
97 | ]) |
||
98 | ->getMock(); |
||
99 | |||
100 | /* override */ |
||
101 | |||
102 | $commentController |
||
103 | ->expects($this->any()) |
||
104 | ->method($method); |
||
105 | } |
||
106 | else |
||
107 | { |
||
108 | $commentController = new Controller\Comment($this->_registry, $this->_request, $this->_language, $this->_config); |
||
109 | } |
||
110 | |||
111 | /* actual */ |
||
112 | |||
113 | $actual = $commentController->process(); |
||
114 | |||
115 | /* compare */ |
||
116 | |||
117 | $this->assertEquals($expect, $actual); |
||
118 | } |
||
119 | } |
||
120 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: