Issues (153)

Tests/Unit/Scheduler/Provider/Email6Test.php (21 issues)

Labels
1
<?php
2
3
4
namespace Aimeos\Aimeos\Tests\Unit\Scheduler\Provider;
5
6
7
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
8
use TYPO3\CMS\Scheduler\Task\Enumeration\Action;
9
use Aimeos\Aimeos\Scheduler;
10
11
12
class Email6Test extends \TYPO3\CMS\Core\Tests\UnitTestCase
0 ignored issues
show
The type TYPO3\CMS\Core\Tests\UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
    private $object;
15
16
17
    public function setUp()
18
    {
19
        $this->object = new Scheduler\Provider\Email6();
20
    }
21
22
23
    public function tearDown()
24
    {
25
        unset($this->object);
26
    }
27
28
29
    /**
30
     * @test
31
     */
32
    public function getAdditionalFields()
33
    {
34
        $taskInfo = [];
35
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
36
37
        $result = $this->object->getAdditionalFields($taskInfo, $this->object, $module);
38
39
        $this->assertInternalType('array', $result);
40
        $this->assertArrayHasKey('aimeos_controller', $result);
41
        $this->assertArrayHasKey('aimeos_sitecode', $result);
42
        $this->assertArrayHasKey('aimeos_config', $result);
43
        $this->assertArrayHasKey('aimeos_sender_from', $result);
44
        $this->assertArrayHasKey('aimeos_sender_email', $result);
45
        $this->assertArrayHasKey('aimeos_reply_email', $result);
46
    }
47
48
49
    /**
50
     * @test
51
     */
52
    public function getAdditionalFieldsException()
53
    {
54
        $taskInfo = [];
55
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
56
        $module->setCurrentAction(new Action('EDIT'));
0 ignored issues
show
The method setCurrentAction() does not exist on TYPO3\CMS\Scheduler\Cont...hedulerModuleController. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
        $module->/** @scrutinizer ignore-call */ 
57
                 setCurrentAction(new Action('EDIT'));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58
        $mock = $this->getMockBuilder('\Aimeos\Aimeos\Scheduler\Provider\Email6')
59
            ->setMethods(['getFields'])->getMock();
60
61
        $mock->expects($this->once())->method('getFields')
62
            ->will($this->throwException(new \RuntimeException()));
63
64
        $result = $mock->getAdditionalFields($taskInfo, $mock, $module);
65
66
        $this->assertEquals([], $result);
67
    }
68
69
70
    /**
71
     * @test
72
     */
73
    public function saveAdditionalFields()
74
    {
75
        $data = [
76
            'aimeos_sitecode' => 'testsite',
77
            'aimeos_controller' => 'testcntl',
78
            'aimeos_config' => 'testconf',
79
            'aimeos_sender_from' => 'test name',
80
            'aimeos_sender_email' => 'sender@test',
81
            'aimeos_reply_email' => 'reply@test',
82
        ];
83
        $task = new Scheduler\Task\Typo6();
84
85
        $this->object->saveAdditionalFields($data, $task);
86
87
        $this->assertEquals('testsite', $task->aimeos_sitecode);
0 ignored issues
show
The property aimeos_sitecode does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
88
        $this->assertEquals('testcntl', $task->aimeos_controller);
0 ignored issues
show
The property aimeos_controller does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
89
        $this->assertEquals('testconf', $task->aimeos_config);
0 ignored issues
show
The property aimeos_config does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
90
        $this->assertEquals('test name', $task->aimeos_sender_from);
0 ignored issues
show
The property aimeos_sender_from does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
91
        $this->assertEquals('sender@test', $task->aimeos_sender_email);
0 ignored issues
show
The property aimeos_sender_email does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
92
        $this->assertEquals('reply@test', $task->aimeos_reply_email);
0 ignored issues
show
The property aimeos_reply_email does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
93
    }
94
95
96
    /**
97
     * @test
98
     */
99
    public function validateAdditionalFieldsNoController()
100
    {
101
        $data = [];
102
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
103
104
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
105
    }
106
107
108
    /**
109
     * @test
110
     */
111
    public function validateAdditionalFieldsNoSite()
112
    {
113
        $data = [
114
            'aimeos_controller' => 'testcntl',
115
        ];
116
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

116
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
117
118
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
119
    }
120
121
122
    /**
123
     * @test
124
     */
125
    public function validateAdditionalFieldsNoSiteFound()
126
    {
127
        $data = [
128
            'aimeos_controller' => 'testcntl',
129
            'aimeos_sitecode' => 'testsite',
130
            'aimeos_config' => 'testconf',
131
            'aimeos_sender_email' => 'sender@test',
132
        ];
133
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

133
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
134
135
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
136
    }
137
138
139
    /**
140
     * @test
141
     */
142
    public function validateAdditionalFieldsNoSenderEmail()
143
    {
144
        $data = [
145
            'aimeos_controller' => 'testcntl',
146
            'aimeos_sitecode' => 'testsite',
147
            'aimeos_config' => 'testconf',
148
        ];
149
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
150
151
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
152
    }
153
154
155
    /**
156
     * @test
157
     */
158
    public function validateAdditionalFieldsInvalidSenderEmail()
159
    {
160
        $data = [
161
            'aimeos_controller' => 'testcntl',
162
            'aimeos_sitecode' => 'testsite',
163
            'aimeos_config' => 'testconf',
164
            'aimeos_sender_email' => 'sender-test',
165
        ];
166
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

166
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
167
168
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
169
    }
170
171
172
    /**
173
     * @test
174
     */
175
    public function validateAdditionalFieldsInvalidReplyEmail()
176
    {
177
        $data = [
178
            'aimeos_controller' => 'testcntl',
179
            'aimeos_sitecode' => 'testsite',
180
            'aimeos_config' => 'testconf',
181
            'aimeos_sender_email' => 'sender@test',
182
            'aimeos_reply_email' => 'reply-test',
183
        ];
184
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

184
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
185
186
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
187
    }
188
189
190
    /**
191
     * @test
192
     */
193
    public function validateAdditionalFieldsInvalidPageID()
194
    {
195
        $data = [
196
            'aimeos_controller' => 'testcntl',
197
            'aimeos_sitecode' => 'testsite',
198
            'aimeos_sender_email' => 'sender@test',
199
            'aimeos_pageid_detail' => 'a',
200
        ];
201
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

201
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
202
203
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
204
    }
205
206
207
    /**
208
     * @test
209
     */
210
    public function validateAdditionalFieldsInvalidDownloadPage()
211
    {
212
        $data = [
213
            'aimeos_controller' => 'testcntl',
214
            'aimeos_sitecode' => 'testsite',
215
            'aimeos_sender_email' => 'sender@test',
216
            'aimeos_pageid_detail' => '123',
217
            'aimeos_pageid_download' => 'a',
218
        ];
219
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

219
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
220
221
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
222
    }
223
224
225
    /**
226
     * @test
227
     */
228
    public function validateAdditionalFieldsInvalidBaseurlNoProtocol()
229
    {
230
        $data = [
231
            'aimeos_controller' => 'testcntl',
232
            'aimeos_sitecode' => 'testsite',
233
            'aimeos_sender_email' => 'sender@test',
234
            'aimeos_content_baseurl' => 'localhost',
235
        ];
236
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

236
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
237
238
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
239
    }
240
241
242
    /**
243
     * @test
244
     */
245
    public function validateAdditionalFieldsInvalidBaseurlNoDomain()
246
    {
247
        $data = [
248
            'aimeos_controller' => 'testcntl',
249
            'aimeos_sitecode' => 'testsite',
250
            'aimeos_sender_email' => 'sender@test',
251
            'aimeos_content_baseurl' => 'https:///',
252
        ];
253
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

253
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
254
255
        $this->assertFalse($this->object->validateAdditionalFields($data, $module));
256
    }
257
258
259
    /**
260
     * @test
261
     */
262
    public function validateAdditionalFields()
263
    {
264
        $data = [
265
            'aimeos_sitecode' => 'default',
266
            'aimeos_controller' => 'index/optimize',
267
            'aimeos_sender_email' => 'sender@test',
268
            'aimeos_pageid_detail' => '123',
269
            'aimeos_pageid_download' => '456',
270
            'aimeos_site_baseurl' => 'https://www.aimeos.org:80/',
271
            'aimeos_content_baseurl' => 'https://www.aimeos.org:80/up/tx_/',
272
            'aimeos_template_baseurl' => 'https://www.aimeos.org:80/fa/elegance',
273
        ];
274
        $module = new SchedulerModuleController();
0 ignored issues
show
The call to TYPO3\CMS\Scheduler\Cont...ntroller::__construct() has too few arguments starting with scheduler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

274
        $module = /** @scrutinizer ignore-call */ new SchedulerModuleController();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
275
276
        $this->assertTrue($this->object->validateAdditionalFields($data, $module));
277
    }
278
}
279