Completed
Push — master ( 61a703...b068bf )
by Daniel
34:25
created

UserDefinedFormTest::testEmailAddressValidation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
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
	
54
    public function testGetCMSFieldsShowInSummary() 
55
    {
56
        $this->logInWithPermission('ADMIN');
57
        $form = $this->objFromFixture('UserDefinedForm', 'summary-rules-form');
58
59
        $fields = $form->getCMSFields();
60
61
        $this->assertInstanceOf('GridField', $fields->dataFieldByName('Submissions'));
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() 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...
62
63
        $submissionsgrid = $fields->dataFieldByName('Submissions');
64
        $gridFieldDataColumns = $submissionsgrid->getConfig()->getComponentByType('GridFieldDataColumns');
65
66
        $summaryFields = $gridFieldDataColumns->getDisplayFields($submissionsgrid);
67
68
        $this->assertContains('SummaryShow', array_keys($summaryFields), 'Summary field not showing displayed field');
69
        $this->assertNotContains('SummaryHide', array_keys($summaryFields), 'Summary field showing displayed field');
70
    }
71
72
	
73
    public function testEmailRecipientPopup()
74
    {
75
        $this->logInWithPermission('ADMIN');
76
77
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
78
79
        $popup = new UserDefinedForm_EmailRecipient();
80
        $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...
81
82
        $fields = $popup->getCMSFields();
83
84
        $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...
85
        $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...
86
        $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...
87
        $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...
88
        $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...
89
        $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...
90
91
        // add an email field, it should now add a or from X address picker
92
        $email = $this->objFromFixture('EditableEmailField', 'email-field');
93
        $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...
94
95
        $popup->write();
96
97
        $fields = $popup->getCMSFields();
98
        $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...
99
100
        // if the front end has checkboxs or dropdown they can select from that can also be used to send things
101
        $dropdown = $this->objFromFixture('EditableDropdown', 'department-dropdown');
102
        $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...
103
104
        $fields = $popup->getCMSFields();
105
        $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...
106
107
        $popup->delete();
108
    }
109
110
    public function testGetEmailBodyContent()
111
    {
112
        $recipient = new UserDefinedForm_EmailRecipient();
113
114
        $emailBody = 'not html';
115
        $emailBodyHtml = '<p>html</p>';
116
117
        $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...
118
        $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...
119
        $recipient->write();
120
121
        $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...
122
        $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...
123
124
        $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...
125
        $recipient->write();
126
127
        $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...
128
129
        $recipient->delete();
130
    }
131
132
    public function testGetEmailTemplateDropdownValues()
133
    {
134
        $recipient = new UserDefinedForm_EmailRecipient();
135
136
        $defaultValues = array('SubmittedFormEmail' => 'SubmittedFormEmail');
137
138
        $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...
139
    }
140
141
    public function testEmailTemplateExists()
142
    {
143
        $recipient = new UserDefinedForm_EmailRecipient();
144
145
        // Set the default template
146
        $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...
147
        $recipient->write();
148
149
        // The default template exists
150
        $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...
151
152
        // A made up template doesn't exists
153
        $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...
154
155
        $recipient->delete();
156
    }
157
158
    public function testCanEditAndDeleteRecipient()
159
    {
160
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
161
162
        $this->logInWithPermission('ADMIN');
163
        foreach ($form->EmailRecipients() as $recipient) {
164
            $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...
165
            $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...
166
        }
167
168
        $member = Member::currentUser();
169
        $member->logOut();
170
171
        $this->logInWithPermission('SITETREE_VIEW_ALL');
172
        foreach ($form->EmailRecipients() as $recipient) {
173
            $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...
174
            $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...
175
        }
176
    }
177
178
    public function testPublishing()
179
    {
180
        $this->logInWithPermission('ADMIN');
181
182
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
183
        $form->write();
184
185
        $form->doPublish();
186
187
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
188
189
        $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...
190
        $this->assertEquals(2, $live->Fields()->Count()); // one page and one field
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...
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...
191
192
        $dropdown = $this->objFromFixture('EditableDropdown', 'basic-dropdown');
193
        $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...
194
195
        $stage = Versioned::get_one_by_stage("UserDefinedForm", "Stage", "\"UserDefinedForm\".\"ID\" = $form->ID");
196
        $this->assertEquals(3, $stage->Fields()->Count());
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...
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...
197
198
        // should not have published the dropdown
199
        $liveDropdown = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $dropdown->ID");
200
        $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...
201
202
        // when publishing it should have added it
203
        $form->doPublish();
204
205
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
206
        $this->assertEquals(3, $live->Fields()->Count());
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...
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...
207
208
        // edit the title
209
        $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...
210
        $text->Title = 'Edited title';
211
        $text->write();
212
213
        $liveText = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $text->ID");
214
        $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...
215
216
        $form->doPublish();
217
218
        $liveText = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $text->ID");
219
        $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...
220
221
        // Add a display rule to the dropdown
222
        $displayRule = new EditableCustomRule();
223
        $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...
224
        $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...
225
        $displayRule->write();
226
        $ruleID = $displayRule->ID;
227
228
        // Not live
229
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
230
        $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...
231
232
        // Publish form, it's now live
233
        $form->doPublish();
234
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
235
        $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...
236
237
        // Remove rule
238
        $displayRule->delete();
239
240
        // Live rule still exists
241
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
242
        $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...
243
244
        // Publish form, it should remove this rule
245
        $form->doPublish();
246
        $liveRule = Versioned::get_one_by_stage("EditableCustomRule", "Live", "\"EditableCustomRule_Live\".\"ID\" = $ruleID");
247
        $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...
248
    }
249
250
    public function testUnpublishing()
251
    {
252
        $this->logInWithPermission('ADMIN');
253
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
254
        $form->write();
255
        $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...
256
        $form->doPublish();
257
258
        // assert that it exists and has a field
259
        $live = Versioned::get_one_by_stage("UserDefinedForm", "Live", "\"UserDefinedForm_Live\".\"ID\" = $form->ID");
260
261
        $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...
262
        $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...
263
264
        // unpublish
265
        $form->doUnpublish();
266
267
        $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...
268
        $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...
269
    }
270
271 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...
272
    {
273
        $this->logInWithPermission('ADMIN');
274
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
275
        $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...
276
277
        $field->Title = 'Title';
278
        $field->write();
279
280
        $form->doPublish();
281
282
        $field->Title = 'Edited title';
283
        $field->write();
284
285
        // check that the published version is not updated
286
        $live = Versioned::get_one_by_stage("EditableFormField", "Live", "\"EditableFormField_Live\".\"ID\" = $field->ID");
287
        $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...
288
289
        // revert back to the live data
290
        $form->doRevertToLive();
291
        $form->flushCache();
292
293
        $check = Versioned::get_one_by_stage("EditableFormField", "Stage", "\"EditableFormField\".\"ID\" = $field->ID");
294
295
        $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...
296
    }
297
298
    public function testDuplicatingForm()
299
    {
300
        $this->logInWithPermission('ADMIN');
301
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
302
303
        $duplicate = $form->duplicate();
304
305
        $this->assertEquals($form->Fields()->Count(), $duplicate->Fields()->Count());
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...
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...
306
        $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...
307
308
        // can't compare object since the dates/ids change
309
        $this->assertEquals($form->Fields()->First()->Title, $duplicate->Fields()->First()->Title);
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...
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...
310
311
        // Test duplicate with group
312
        $form2 = $this->objFromFixture('UserDefinedForm', 'page-with-group');
313
        $form2Validator = new UserFormValidator();
314
        $form2Validator->setForm(new Form(new Controller(), 'Form', new FieldList(), new FieldList()));
315
        $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...
316
317
        // Check field groups exist
318
        $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...
319
        $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...
320
        $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...
321
322
        // Duplicate this
323
        $form3 = $form2->duplicate();
324
        $form3Validator = new UserFormValidator();
325
        $form3Validator->setForm(new Form(new Controller(), 'Form', new FieldList(), new FieldList()));
326
        $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...
327
328
        // Check field groups exist
329
        $form3GroupStart = $form3->Fields()->filter('ClassName', 'EditableFieldGroup')->first();
330
        $form3GroupEnd = $form3->Fields()->filter('ClassName', 'EditableFieldGroupEnd')->first();
331
        $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...
332
        $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...
333
    }
334
335
    public function testFormOptions()
336
    {
337
        $this->logInWithPermission('ADMIN');
338
        $form = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
339
340
        $fields = $form->getFormOptions();
341
        $submit = $fields->fieldByName('SubmitButtonText');
342
        $reset = $fields->fieldByName('ShowClearButton');
343
344
        $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...
345
        $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...
346
    }
347
348
    public function testEmailRecipientFilters()
349
    {
350
        /** @var UserDefinedForm $form */
351
        $form = $this->objFromFixture('UserDefinedForm', 'filtered-form-page');
352
353
        // Check unfiltered recipients
354
        $result0 = $form
355
            ->EmailRecipients()
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
                '[email protected]'
363
            ),
364
            $result0
365
        );
366
367
        // check filters based on given data
368
        $result1 = $form->FilteredEmailRecipients(
369
            array(
370
                'your-name' => 'Value',
371
                'address' => '',
372
                'street' => 'Anything',
373
                'city' => 'Matches Not Equals',
374
                'colours' => array('Red') // matches 2
375
            ), null
376
        )
377
            ->sort('EmailAddress')
378
            ->column('EmailAddress');
379
        $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...
380
            array(
381
                '[email protected]',
382
                '[email protected]'
383
            ),
384
            $result1
385
        );
386
387
        // Check all positive matches
388
        $result2 = $form->FilteredEmailRecipients(
389
            array(
390
                'your-name' => '',
391
                'address' => 'Anything',
392
                'street' => 'Matches Equals',
393
                'city' => 'Anything',
394
                'colours' => array('Red', 'Blue') // matches 2
395
            ), null
396
        )
397
            ->sort('EmailAddress')
398
            ->column('EmailAddress');
399
        $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...
400
            array(
401
                '[email protected]',
402
                '[email protected]',
403
                '[email protected]'
404
            ),
405
            $result2
406
        );
407
408
        $result3 = $form->FilteredEmailRecipients(
409
            array(
410
                'your-name' => 'Should be blank but is not',
411
                'address' => 'Anything',
412
                'street' => 'Matches Equals',
413
                'city' => 'Anything',
414
                'colours' => array('Blue')
415
            ), null
416
        )->column('EmailAddress');
417
        $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...
418
            array(
419
                '[email protected]'
420
            ),
421
            $result3
422
        );
423
424
425
        $result4 = $form->FilteredEmailRecipients(
426
            array(
427
                'your-name' => '',
428
                'address' => 'Anything',
429
                'street' => 'Wrong value for this field',
430
                'city' => '',
431
                'colours' => array('Blue', 'Green')
432
            ), null
433
        )->column('EmailAddress');
434
        $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...
435
            array(
436
                '[email protected]'
437
            ),
438
            $result4
439
        );
440
    }
441
442
    public function testIndex()
443
    {
444
        // Test that the $UserDefinedForm is stripped out
445
        $page = $this->objFromFixture('UserDefinedForm', 'basic-form-page');
446
        $page->publish('Stage', 'Live');
447
448
        $result = $this->get($page->Link());
449
        $body = Convert::nl2os($result->getBody(), ''); // strip out newlines
450
        $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...
451
        $this->assertContains('<p>Here is my form</p><form', $body);
452
        $this->assertContains('</form><p>Thank you for filling it out</p>', $body);
453
454
        $this->assertNotContains('<p>$UserDefinedForm</p>', $body);
455
        $this->assertNotContains('<p></p>', $body);
456
        $this->assertNotContains('</p><p>Thank you for filling it out</p>', $body);
457
    }
458
459
    public function testEmailAddressValidation()
460
    {
461
        $this->logInWithPermission('ADMIN');
462
463
        // test invalid email addresses fail validation
464
        $recipient = $this->objFromFixture('UserDefinedForm_EmailRecipient',
465
            'invalid-recipient-list');
466
        $result = $recipient->validate();
467
        $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...
468
        $this->assertContains('filtered.example.com', $result->message());
469
        $this->assertNotContains('[email protected]', $result->message());
470
471
        // test valid email addresses pass validation
472
        $recipient = $this->objFromFixture('UserDefinedForm_EmailRecipient',
473
            'valid-recipient-list');
474
        $result = $recipient->validate();
475
        $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...
476
        $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...
477
    }
478
}
479