Issues (153)

Tests/Unit/Scheduler/Provider/Typo6Test.php (11 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
10
11
class Typo6Test 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...
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
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

34
        $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...
35
        $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

35
        $module->/** @scrutinizer ignore-call */ 
36
                 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...
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 ignore-call  annotation

52
        $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...
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);
0 ignored issues
show
The property aimeos_sitecode does not seem to exist on Aimeos\Aimeos\Scheduler\Task\Typo6.
Loading history...
82
        $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...
83
        $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...
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 ignore-call  annotation

93
        $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...
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 ignore-call  annotation

107
        $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...
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 ignore-call  annotation

123
        $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...
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 ignore-call  annotation

138
        $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...
139
140
        $this->assertTrue($this->object->validateAdditionalFields($data, $module));
141
    }
142
}
143