Completed
Push — master ( a51be7...c74983 )
by Antony
02:19
created

testKnockoutConfirmedPasswordField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 55
rs 9.7692
cc 1
eloc 40
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * KnockoutConfirmedPasswordFieldTest
4
 */
5
class KnockoutConfirmedPasswordFieldTest extends SapphireTest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
7
	public function testKnockoutConfirmedPasswordField() {
8
    	$field = KnockoutConfirmedPasswordField::create("MyField", "My Field");
9
        $fields = $field->children;
10
        $password_field = $fields->fieldByName('MyField[_Password]');
11
        $password_confirmed_field = $fields->fieldByName('MyField[_ConfirmPassword]');
12
13
        $this->assertNotNull(
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
14
                $password_field,
15
                "password field is not null"
16
        );
17
        $this->assertNotNull(
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
18
                $password_confirmed_field,
19
                "password confirmed field is not null"
20
        );
21
    	$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
22
            "password",
23
            $password_field->getObservable(),
24
            "observable is set to password by default in the Password field"
25
        );
26
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
27
            "confirmedPassword",
28
            $password_confirmed_field->getObservable(),
29
            "observable is set to confirmedPassword by default in the Confirmed Password field"
30
        );
31
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
32
            ['password', 'confirmedPassword'],
33
            $field->getObservables(),
34
            "The function getObservables returns an array of the observables set on the child fields"
35
        );
36
37
38
	
39
        $field2 = KnockoutConfirmedPasswordField::create("MyField2", "My Field2")
40
                ->setObservables(['password2', 'confirmedPassword2']);
41
        $fields2 = $field2->children;
42
43
        $password_field2 = $fields2->fieldByName('MyField2[_Password]');
44
        $password_confirmed_field2 = $fields2->fieldByName('MyField2[_ConfirmPassword]');
45
46
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
47
            "password2",
48
            $password_field2->getObservable(),
49
            "observable is set to password2 through the setObservables method"
50
        );
51
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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...
52
            "confirmedPassword2",
53
            $password_confirmed_field2->getObservable(),
54
            "observable is set to confirmedPassword2 through the setObservables method"
55
        );
56
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<KnockoutConfirmedPasswordFieldTest>.

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
            ['password2', 'confirmedPassword2'],
58
            $field2->getObservables(),
59
            "The function getObservables returns an array of the observables set on the child fields"
60
        );
61
    }
62
}
63
64