Completed
Pull Request — master (#12)
by Simon
01:15
created

PasswordFormTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Firesphere\PartialUserforms\Tests;
5
6
use Firesphere\PartialUserforms\Forms\PasswordForm;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Forms\FieldList;
9
use SilverStripe\Forms\Form;
10
use SilverStripe\Forms\PasswordField;
11
use SilverStripe\UserForms\Control\UserDefinedFormController;
12
use SilverStripe\UserForms\Model\UserDefinedForm;
13
14
class PasswordFormTest extends SapphireTest
15
{
16
    public function testConstruct()
17
    {
18
        $page = new UserDefinedForm();
19
        $controller = new UserDefinedFormController($page);
20
        $form = new PasswordForm($controller, 'PasswordForm');
0 ignored issues
show
Documentation introduced by
$controller is of type object<SilverStripe\User...rDefinedFormController>, but the function expects a null|object<Firesphere\P...erFormVerifyController>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
22
        $this->assertInstanceOf(Form::class, $form);
23
        $this->assertInstanceOf(PasswordField::class, $form->Fields()->dataFieldByName('Password'));
24
        $this->assertInstanceOf(FieldList::class, $form->Actions());
25
    }
26
}
27