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 | |||||
10 | |||||
11 | class Typo6Test extends \TYPO3\CMS\Core\Tests\UnitTestCase |
||||
12 | { |
||||
13 | private $object; |
||||
14 | |||||
15 | |||||
16 | public function setUp() |
||||
17 | { |
||||
18 | $this->object = new \Aimeos\Aimeos\Scheduler\Provider\Typo6(); |
||||
19 | } |
||||
20 | |||||
21 | |||||
22 | public function tearDown() |
||||
23 | { |
||||
24 | unset($this->object); |
||||
25 | } |
||||
26 | |||||
27 | |||||
28 | /** |
||||
29 | * @test |
||||
30 | */ |
||||
31 | public function getAdditionalFields() |
||||
32 | { |
||||
33 | $taskInfo = []; |
||||
34 | $module = new SchedulerModuleController(); |
||||
0 ignored issues
–
show
|
|||||
35 | $module->setCurrentAction(new Action('EDIT')); |
||||
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 | } |
||||
44 | |||||
45 | |||||
46 | /** |
||||
47 | * @test |
||||
48 | */ |
||||
49 | public function getAdditionalFieldsException() |
||||
50 | { |
||||
51 | $taskInfo = []; |
||||
52 | $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
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...
|
|||||
53 | $module->setCurrentAction(new Action('EDIT')); |
||||
54 | |||||
55 | $mock = $this->getMockBuilder('\Aimeos\Aimeos\Scheduler\Provider\Typo6') |
||||
56 | ->setMethods(['getFields'])->getMock(); |
||||
57 | |||||
58 | $mock->expects($this->once())->method('getFields') |
||||
59 | ->will($this->throwException(new \RuntimeException())); |
||||
60 | |||||
61 | $result = $mock->getAdditionalFields($taskInfo, $mock, $module); |
||||
62 | |||||
63 | $this->assertEquals([], $result); |
||||
64 | } |
||||
65 | |||||
66 | |||||
67 | /** |
||||
68 | * @test |
||||
69 | */ |
||||
70 | public function saveAdditionalFields() |
||||
71 | { |
||||
72 | $data = [ |
||||
73 | 'aimeos_sitecode' => 'testsite', |
||||
74 | 'aimeos_controller' => 'testcntl', |
||||
75 | 'aimeos_config' => 'testconf', |
||||
76 | ]; |
||||
77 | $task = new \Aimeos\Aimeos\Scheduler\Task\Typo6(); |
||||
78 | |||||
79 | $this->object->saveAdditionalFields($data, $task); |
||||
80 | |||||
81 | $this->assertEquals('testsite', $task->aimeos_sitecode); |
||||
82 | $this->assertEquals('testcntl', $task->aimeos_controller); |
||||
83 | $this->assertEquals('testconf', $task->aimeos_config); |
||||
84 | } |
||||
85 | |||||
86 | |||||
87 | /** |
||||
88 | * @test |
||||
89 | */ |
||||
90 | public function validateAdditionalFieldsNoController() |
||||
91 | { |
||||
92 | $data = []; |
||||
93 | $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
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...
|
|||||
94 | |||||
95 | $this->assertFalse($this->object->validateAdditionalFields($data, $module)); |
||||
96 | } |
||||
97 | |||||
98 | |||||
99 | /** |
||||
100 | * @test |
||||
101 | */ |
||||
102 | public function validateAdditionalFieldsNoSite() |
||||
103 | { |
||||
104 | $data = [ |
||||
105 | 'aimeos_controller' => 'testcntl', |
||||
106 | ]; |
||||
107 | $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
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...
|
|||||
108 | |||||
109 | $this->assertFalse($this->object->validateAdditionalFields($data, $module)); |
||||
110 | } |
||||
111 | |||||
112 | |||||
113 | /** |
||||
114 | * @test |
||||
115 | */ |
||||
116 | public function validateAdditionalFieldsNoSiteFound() |
||||
117 | { |
||||
118 | $data = [ |
||||
119 | 'aimeos_controller' => 'testcntl', |
||||
120 | 'aimeos_sitecode' => 'testsite', |
||||
121 | 'aimeos_config' => 'testconf', |
||||
122 | ]; |
||||
123 | $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
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...
|
|||||
124 | |||||
125 | $this->assertFalse($this->object->validateAdditionalFields($data, $module)); |
||||
126 | } |
||||
127 | |||||
128 | |||||
129 | /** |
||||
130 | * @test |
||||
131 | */ |
||||
132 | public function validateAdditionalFields() |
||||
133 | { |
||||
134 | $data = [ |
||||
135 | 'aimeos_sitecode' => 'default', |
||||
136 | 'aimeos_controller' => 'index/optimize', |
||||
137 | ]; |
||||
138 | $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
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...
|
|||||
139 | |||||
140 | $this->assertTrue($this->object->validateAdditionalFields($data, $module)); |
||||
141 | } |
||||
142 | } |
||||
143 |
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.