Completed
Push — master ( f3b14d...1fe4c3 )
by Damian
10s
created

TestWidgetController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Form() 0 15 1
A doAction() 0 8 1
1
<?php
2
3
namespace SilverStripe\Widgets\Tests\WidgetControllerTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\Form;
8
use SilverStripe\Forms\FormAction;
9
use SilverStripe\Forms\TextField;
10
use SilverStripe\Widgets\Controllers\WidgetController;
11
12
/**
13
 * @package widgets
14
 * @subpackage tests
15
 */
16
class TestWidgetController extends WidgetController implements TestOnly
17
{
18
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
Unused Code introduced by
The property $allowed_actions is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
        'Form'
20
    );
21
22
    public function Form()
23
    {
24
        $widgetform = new Form(
25
            $this,
26
            'Form',
27
            new FieldList(
28
                new TextField('TestValue')
29
            ),
30
            new FieldList(
31
                new FormAction('doAction')
32
            )
33
        );
34
35
        return $widgetform;
36
    }
37
38
    public function doAction($data, $form)
0 ignored issues
show
Unused Code introduced by
The parameter $form is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40
        return sprintf(
41
            'TestValue: %s\nWidget ID: %d',
42
            $data['TestValue'],
43
            $this->widget->ID
44
        );
45
    }
46
}
47