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 = |
||
34 | [ |
||
35 | 'adminName' => 'Test', |
||
36 | 'adminUser' => 'test', |
||
37 | 'adminPassword' => 'test', |
||
38 | 'adminEmail' => '[email protected]' |
||
39 | ]; |
||
40 | $installer = $this->installerFactory(); |
||
41 | $installer->init(); |
||
42 | $installer->rawCreate(); |
||
43 | $installer->insertSettings($optionArray); |
||
44 | $categoryOne = Db::forTablePrefix('categories')->create(); |
||
45 | $categoryOne |
||
46 | ->set( |
||
47 | [ |
||
48 | 'title' => 'Category One', |
||
49 | 'alias' => 'category-one' |
||
50 | ]) |
||
51 | ->save(); |
||
52 | Db::forTablePrefix('articles') |
||
53 | ->create() |
||
54 | ->set( |
||
55 | [ |
||
56 | 'title' => 'Article One', |
||
57 | 'alias' => 'article-one', |
||
58 | 'category' => $categoryOne->id |
||
59 | |||
60 | ]) |
||
61 | ->save(); |
||
62 | $setting = $this->settingFactory(); |
||
63 | $setting->set('captcha', 1); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * tearDown |
||
68 | * |
||
69 | * @since 3.1.0 |
||
70 | */ |
||
71 | |||
72 | public function tearDown() : void |
||
73 | { |
||
74 | $this->dropDatabase(); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * testProcess |
||
79 | * |
||
80 | * @since 3.0.0 |
||
81 | * |
||
82 | * @param array $postArray |
||
83 | * @param array $settingArray |
||
84 | * @param string $method |
||
85 | * @param string $expect |
||
86 | * |
||
87 | * @dataProvider providerAutoloader |
||
88 | */ |
||
89 | |||
90 | public function testProcess(array $postArray = [], array $settingArray = [], string $method = null, string $expect = null) : void |
||
91 | { |
||
92 | /* setup */ |
||
93 | |||
94 | $this->_request->set('post', $postArray); |
||
95 | $setting = $this->settingFactory(); |
||
96 | $setting->set('notification', $settingArray['notification']); |
||
97 | $setting->set('moderation', $settingArray['moderation']); |
||
98 | if ($method) |
||
0 ignored issues
–
show
|
|||
99 | { |
||
100 | $commentController = $this |
||
101 | ->getMockBuilder('Redaxscript\Controller\Comment') |
||
102 | ->setConstructorArgs( |
||
103 | [ |
||
104 | $this->_registry, |
||
105 | $this->_request, |
||
106 | $this->_language, |
||
107 | $this->_config |
||
108 | ]) |
||
109 | ->setMethods( |
||
110 | [ |
||
111 | $method |
||
112 | ]) |
||
113 | ->getMock(); |
||
114 | |||
115 | /* override */ |
||
116 | |||
117 | $commentController |
||
118 | ->expects($this->any()) |
||
119 | ->method($method); |
||
120 | } |
||
121 | else |
||
122 | { |
||
123 | $commentController = new Controller\Comment($this->_registry, $this->_request, $this->_language, $this->_config); |
||
124 | } |
||
125 | |||
126 | /* actual */ |
||
127 | |||
128 | $actual = $commentController->process(); |
||
129 | |||
130 | /* compare */ |
||
131 | |||
132 | $this->assertEquals($expect, $actual); |
||
133 | } |
||
134 | } |
||
135 |
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: