Completed
Pull Request — master (#536)
by
unknown
34:29
created

UserDefinedFormTest   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 453
Duplicated Lines 11.48 %

Coupling/Cohesion

Components 1
Dependencies 13

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 13
dl 52
loc 453
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
B testRollbackToVersion() 27 28 1
A testGetCMSFields() 0 12 1
B testEmailRecipientPopup() 0 36 1
A testGetEmailBodyContent() 0 21 1
A testGetEmailTemplateDropdownValues() 0 8 1
A testEmailTemplateExists() 0 16 1
A testCanEditAndDeleteRecipient() 0 19 3
A testPublishing() 0 71 1
A testUnpublishing() 0 20 1
B testDoRevertToLive() 25 26 1
B testDuplicatingForm() 0 36 1
A testFormOptions() 0 12 1
B testEmailRecipientFilters() 0 93 1
A testIndex() 0 16 1
A testEmailAddressValidation() 0 19 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * @package userforms
5
 */
6
class UserDefinedFormTest extends FunctionalTest
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...
7
{
8
9
    public static $fixture_file = 'UserDefinedFormTest.yml';
10
11 View Code Duplication
    public function testRollbackToVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
    {
13
        $this->markTestSkipped(
0 ignored issues
show
Bug introduced by
The method markTestSkipped() does not seem to exist on object<UserDefinedFormTest>.

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
            'UserDefinedForm::rollback() has not been implemented completely'
15
        );
16
17
        // @todo
18
        $this->logInWithPermission('ADMIN');
19
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
20
21
        $form->SubmitButtonText = 'Button Text';
22
        $form->write();
23
        $form->doPublish();
24
        $origVersion = $form->Version;
25
26
        $form->SubmitButtonText = 'Updated Button Text';
27
        $form->write();
28
        $form->doPublish();
29
30
        // check published site
31
        $updated = Versioned::get_one_by_stage("UserDefinedForm", "Stage", "\"UserDefinedForm\".\"ID\" = $form->ID");
32
        $this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
33
34
        $form->doRollbackTo($origVersion);
35
36
        $orignal = Versioned::get_one_by_stage("UserDefinedForm", "Stage", "\"UserDefinedForm\".\"ID\" = $form->ID");
37
        $this->assertEquals($orignal->SubmitButtonText, 'Button Text');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
38
    }
39
40
    public function testGetCMSFields()
41
    {
42
        $this->logInWithPermission('ADMIN');
43
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
44
45
        $fields = $form->getCMSFields();
46
47
        $this->assertTrue($fields->dataFieldByName('Fields') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
48
        $this->assertTrue($fields->dataFieldByName('EmailRecipients') != null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
49
        $this->assertTrue($fields->dataFieldByName('Submissions') != null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
50
        $this->assertTrue($fields->dataFieldByName('OnCompleteMessage') != null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
51
    }
52
53
    public function testEmailRecipientPopup()
54
    {
55
        $this->logInWithPermission('ADMIN');
56
57
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
58
59
        $popup = new UserDefinedForm_EmailRecipient();
60
        $popup->FormID = $form->ID;
0 ignored issues
show
Documentation introduced by
The property FormID does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
61
62
        $fields = $popup->getCMSFields();
63
64
        $this->assertTrue($fields->dataFieldByName('EmailSubject') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
65
        $this->assertTrue($fields->dataFieldByName('EmailFrom') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
66
        $this->assertTrue($fields->dataFieldByName('EmailAddress') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
67
        $this->assertTrue($fields->dataFieldByName('HideFormData') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
68
        $this->assertTrue($fields->dataFieldByName('SendPlain') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
69
        $this->assertTrue($fields->dataFieldByName('EmailBody') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
70
71
        // add an email field, it should now add a or from X address picker
72
        $email = $this->objFromFixture('EditableEmailField', 'email-field');
73
        $form->Fields()->add($email);
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
74
75
        $popup->write();
76
77
        $fields = $popup->getCMSFields();
78
        $this->assertThat($fields->dataFieldByName('SendEmailToFieldID'), $this->isInstanceOf('DropdownField'));
0 ignored issues
show
Bug introduced by
The method isInstanceOf() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method assertThat() does not seem to exist on object<UserDefinedFormTest>.

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...
79
80
        // if the front end has checkboxs or dropdown they can select from that can also be used to send things
81
        $dropdown = $this->objFromFixture('EditableDropdown', 'department-dropdown');
82
        $form->Fields()->add($dropdown);
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
83
84
        $fields = $popup->getCMSFields();
85
        $this->assertTrue($fields->dataFieldByName('SendEmailToFieldID') !== null);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
86
87
        $popup->delete();
88
    }
89
90
    public function testGetEmailBodyContent()
91
    {
92
        $recipient = new UserDefinedForm_EmailRecipient();
93
94
        $emailBody = 'not html';
95
        $emailBodyHtml = '<p>html</p>';
96
97
        $recipient->EmailBody = $emailBody;
0 ignored issues
show
Documentation introduced by
The property EmailBody does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
98
        $recipient->EmailBodyHtml = $emailBodyHtml;
0 ignored issues
show
Documentation introduced by
The property EmailBodyHtml does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
99
        $recipient->write();
100
101
        $this->assertEquals($recipient->SendPlain, 0);
0 ignored issues
show
Documentation introduced by
The property SendPlain does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
102
        $this->assertEquals($recipient->getEmailBodyContent(), $emailBodyHtml);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
103
104
        $recipient->SendPlain = 1;
0 ignored issues
show
Documentation introduced by
The property SendPlain does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
105
        $recipient->write();
106
107
        $this->assertEquals($recipient->getEmailBodyContent(), $emailBody);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
108
109
        $recipient->delete();
110
    }
111
112
    public function testGetEmailTemplateDropdownValues()
113
    {
114
        $recipient = new UserDefinedForm_EmailRecipient();
115
116
        $defaultValues = array('SubmittedFormEmail' => 'SubmittedFormEmail');
117
118
        $this->assertEquals($recipient->getEmailTemplateDropdownValues(), $defaultValues);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
119
    }
120
121
    public function testEmailTemplateExists()
122
    {
123
        $recipient = new UserDefinedForm_EmailRecipient();
124
125
        // Set the default template
126
        $recipient->EmailTemplate = current(array_keys($recipient->getEmailTemplateDropdownValues()));
0 ignored issues
show
Documentation introduced by
The property EmailTemplate does not exist on object<UserDefinedForm_EmailRecipient>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
127
        $recipient->write();
128
129
        // The default template exists
130
        $this->assertTrue($recipient->emailTemplateExists());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
131
132
        // A made up template doesn't exists
133
        $this->assertFalse($recipient->emailTemplateExists('MyTemplateThatsNotThere'));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
134
135
        $recipient->delete();
136
    }
137
138
    public function testCanEditAndDeleteRecipient()
139
    {
140
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
141
142
        $this->logInWithPermission('ADMIN');
143
        foreach ($form->EmailRecipients() as $recipient) {
144
            $this->assertTrue($recipient->canEdit());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
145
            $this->assertTrue($recipient->canDelete());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
146
        }
147
148
        $member = Member::currentUser();
149
        $member->logOut();
150
151
        $this->logInWithPermission('SITETREE_VIEW_ALL');
152
        foreach ($form->EmailRecipients() as $recipient) {
153
            $this->assertFalse($recipient->canEdit());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
154
            $this->assertFalse($recipient->canDelete());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
155
        }
156
    }
157
158
    public function testPublishing()
159
    {
160
        $this->logInWithPermission('ADMIN');
161
162
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
163
        $form->write();
164
165
        $form->doPublish();
166
167
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
168
169
        $this->assertNotNull($live);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<UserDefinedFormTest>.

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...
170
        $this->assertEquals(2, $live->Fields()->Count()); // one page and one field
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
171
172
        $dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
173
        $form->Fields()->add($dropdown);
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
174
175
        $stage = Versioned::get_one_by_stage("UserDefinedForm", "Stage", "\"UserDefinedForm\".\"ID\" = $form->ID");
176
        $this->assertEquals(3, $stage->Fields()->Count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
177
178
        // should not have published the dropdown
179
        $liveDropdown = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $dropdown->ID");
180
        $this->assertNull($liveDropdown);
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<UserDefinedFormTest>.

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...
181
182
        // when publishing it should have added it
183
        $form->doPublish();
184
185
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
186
        $this->assertEquals(3, $live->Fields()->Count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
187
188
        // edit the title
189
        $text = $form->Fields()->limit(1, 1)->First();
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
190
        $text->Title = 'Edited title';
191
        $text->write();
192
193
        $liveText = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $text->ID");
194
        $this->assertFalse($liveText->Title == $text->Title);
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
195
196
        $form->doPublish();
197
198
        $liveText = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $text->ID");
199
        $this->assertTrue($liveText->Title == $text->Title);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
200
201
        // Add a display rule to the dropdown
202
        $displayRule = new EditableCustomRule();
203
        $displayRule->ParentID = $dropdown->ID;
0 ignored issues
show
Documentation introduced by
The property ParentID does not exist on object<EditableCustomRule>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
204
        $displayRule->ConditionFieldID = $text->ID;
0 ignored issues
show
Documentation introduced by
The property ConditionFieldID does not exist on object<EditableCustomRule>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
205
        $displayRule->write();
206
        $ruleID = $displayRule->ID;
207
208
        // Not live
209
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
210
        $this->assertEmpty($liveRule);
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<UserDefinedFormTest>.

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...
211
212
        // Publish form, it's now live
213
        $form->doPublish();
214
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
215
        $this->assertNotEmpty($liveRule);
0 ignored issues
show
Bug introduced by
The method assertNotEmpty() does not seem to exist on object<UserDefinedFormTest>.

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...
216
217
        // Remove rule
218
        $displayRule->delete();
219
220
        // Live rule still exists
221
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
222
        $this->assertNotEmpty($liveRule);
0 ignored issues
show
Bug introduced by
The method assertNotEmpty() does not seem to exist on object<UserDefinedFormTest>.

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...
223
224
        // Publish form, it should remove this rule
225
        $form->doPublish();
226
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
227
        $this->assertEmpty($liveRule);
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<UserDefinedFormTest>.

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...
228
    }
229
230
    public function testUnpublishing()
231
    {
232
        $this->logInWithPermission('ADMIN');
233
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
234
        $form->write();
235
        $this->assertEquals(0, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
236
        $form->doPublish();
237
238
        // assert that it exists and has a field
239
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
240
241
        $this->assertTrue(isset($live));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
242
        $this->assertEquals(2, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
243
244
        // unpublish
245
        $form->doUnpublish();
246
247
        $this->assertNull(Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID"));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<UserDefinedFormTest>.

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...
248
        $this->assertEquals(0, DB::query("SELECT COUNT(*) FROM \"EditableFormField_Live\"")->value());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
249
    }
250
251 View Code Duplication
    public function testDoRevertToLive()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
252
    {
253
        $this->logInWithPermission('ADMIN');
254
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
255
        $field = $form->Fields()->First();
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
256
257
        $field->Title = 'Title';
258
        $field->write();
259
260
        $form->doPublish();
261
262
        $field->Title = 'Edited title';
263
        $field->write();
264
265
        // check that the published version is not updated
266
        $live = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $field->ID");
267
        $this->assertEquals('Title', $live->Title);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
268
269
        // revert back to the live data
270
        $form->doRevertToLive();
271
        $form->flushCache();
272
273
        $check = Versioned::get_one_by_stage("EditableFormField", "Stage", "\"EditableFormField\".\"ID\" = $field->ID");
274
275
        $this->assertEquals('Title', $check->Title);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
276
    }
277
278
    public function testDuplicatingForm()
279
    {
280
        $this->logInWithPermission('ADMIN');
281
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
282
283
        $duplicate = $form->duplicate();
284
285
        $this->assertEquals($form->Fields()->Count(), $duplicate->Fields()->Count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
286
        $this->assertEquals($form->EmailRecipients()->Count(), $form->EmailRecipients()->Count());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
287
288
        // can't compare object since the dates/ids change
289
        $this->assertEquals($form->Fields()->First()->Title, $duplicate->Fields()->First()->Title);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
290
291
        // Test duplicate with group
292
        $form2 = $this->objFromFixture('UserDefinedForm', 'page-with-group');
293
        $form2Validator = new UserFormValidator();
294
        $form2Validator->setForm(new Form(new Controller(), 'Form', new FieldList(), new FieldList()));
295
        $this->assertTrue($form2Validator->php($form2->toMap()));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
296
297
        // Check field groups exist
298
        $form2GroupStart = $form2->Fields()->filter('ClassName', 'EditableFieldGroup')->first();
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
299
        $form2GroupEnd = $form2->Fields()->filter('ClassName', 'EditableFieldGroupEnd')->first();
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on DataObject. Did you maybe mean beforeUpdateCMSFields()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
300
        $this->assertEquals($form2GroupEnd->ID, $form2GroupStart->EndID);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
301
302
        // Duplicate this
303
        $form3 = $form2->duplicate();
304
        $form3Validator = new UserFormValidator();
305
        $form3Validator->setForm(new Form(new Controller(), 'Form', new FieldList(), new FieldList()));
306
        $this->assertTrue($form3Validator->php($form3->toMap()));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
307
308
        // Check field groups exist
309
        $form3GroupStart = $form3->Fields()->filter('ClassName', 'EditableFieldGroup')->first();
310
        $form3GroupEnd = $form3->Fields()->filter('ClassName', 'EditableFieldGroupEnd')->first();
311
        $this->assertEquals($form3GroupEnd->ID, $form3GroupStart->EndID);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
312
        $this->assertNotEquals($form2GroupEnd->ID, $form3GroupStart->EndID);
0 ignored issues
show
Bug introduced by
The method assertNotEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
313
    }
314
315
    public function testFormOptions()
316
    {
317
        $this->logInWithPermission('ADMIN');
318
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
319
320
        $fields = $form->getFormOptions();
321
        $submit = $fields->fieldByName('SubmitButtonText');
322
        $reset = $fields->fieldByName('ShowClearButton');
323
324
        $this->assertEquals($submit->Title(), 'Text on submit button:');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
325
        $this->assertEquals($reset->Title(), 'Show Clear Form Button');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
326
    }
327
328
    public function testEmailRecipientFilters()
329
    {
330
        $form = $this->objFromFixture('UserDefinedForm', 'filtered-form-page');
331
332
        // Check unfiltered recipients
333
        $result0 = $form
334
            ->EmailRecipients()
335
            ->sort('EmailAddress')
336
            ->column('EmailAddress');
337
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
338
            array(
339
                '[email protected]',
340
                '[email protected]',
341
                '[email protected]'
342
            ),
343
            $result0
344
        );
345
346
        // check filters based on given data
347
        $result1 = $form->FilteredEmailRecipients(
348
            array(
349
                'your-name' => 'Value',
350
                'address' => '',
351
                'street' => 'Anything',
352
                'city' => 'Matches Not Equals',
353
                'colours' => array('Red') // matches 2
354
            ), null
355
        )
356
            ->sort('EmailAddress')
357
            ->column('EmailAddress');
358
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
359
            array(
360
                '[email protected]',
361
                '[email protected]'
362
            ),
363
            $result1
364
        );
365
366
        // Check all positive matches
367
        $result2 = $form->FilteredEmailRecipients(
368
            array(
369
                'your-name' => '',
370
                'address' => 'Anything',
371
                'street' => 'Matches Equals',
372
                'city' => 'Anything',
373
                'colours' => array('Red', 'Blue') // matches 2
374
            ), null
375
        )
376
            ->sort('EmailAddress')
377
            ->column('EmailAddress');
378
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
379
            array(
380
                '[email protected]',
381
                '[email protected]',
382
                '[email protected]'
383
            ),
384
            $result2
385
        );
386
387
388
        $result3 = $form->FilteredEmailRecipients(
389
            array(
390
                'your-name' => 'Should be blank but is not',
391
                'address' => 'Anything',
392
                'street' => 'Matches Equals',
393
                'city' => 'Anything',
394
                'colours' => array('Blue')
395
            ), null
396
        )->column('EmailAddress');
397
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
398
            array(
399
                '[email protected]'
400
            ),
401
            $result3
402
        );
403
404
405
        $result4 = $form->FilteredEmailRecipients(
406
            array(
407
                'your-name' => '',
408
                'address' => 'Anything',
409
                'street' => 'Wrong value for this field',
410
                'city' => '',
411
                'colours' => array('Blue', 'Green')
412
            ), null
413
        )->column('EmailAddress');
414
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<UserDefinedFormTest>.

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...
415
            array(
416
                '[email protected]'
417
            ),
418
            $result4
419
        );
420
    }
421
422
    public function testIndex()
423
    {
424
        // Test that the $UserDefinedForm is stripped out
425
        $page = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
426
        $page->publish('Stage', 'Live');
427
428
        $result = $this->get($page->Link());
429
        $body = Convert::nl2os($result->getBody(), ''); // strip out newlines
430
        $this->assertFalse($result->isError());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
431
        $this->assertContains('<p>Here is my form</p><form', $body);
432
        $this->assertContains('</form><p>Thank you for filling it out</p>', $body);
433
434
        $this->assertNotContains('<p>$UserDefinedForm</p>', $body);
435
        $this->assertNotContains('<p></p>', $body);
436
        $this->assertNotContains('</p><p>Thank you for filling it out</p>', $body);
437
    }
438
439
    public function testEmailAddressValidation()
440
    {
441
        $this->logInWithPermission('ADMIN');
442
443
        // test invalid email addresses fail validation
444
        $recipient = $this->objFromFixture('UserDefinedForm_EmailRecipient',
445
            'invalid-recipient-list');
446
        $result = $recipient->validate();
447
        $this->assertFalse($result->valid());
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<UserDefinedFormTest>.

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...
448
        $this->assertContains('filtered.example.com', $result->message());
449
        $this->assertNotContains('[email protected]', $result->message());
450
451
        // test valid email addresses pass validation
452
        $recipient = $this->objFromFixture('UserDefinedForm_EmailRecipient',
453
            'valid-recipient-list');
454
        $result = $recipient->validate();
455
        $this->assertTrue($result->valid());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<UserDefinedFormTest>.

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...
456
        $this->assertEmpty($result->message());
0 ignored issues
show
Bug introduced by
The method assertEmpty() does not seem to exist on object<UserDefinedFormTest>.

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...
457
    }
458
}
459