Completed
Pull Request — master (#647)
by Robbie
05:30 queued 03:19
created

UserFormTest::testEmptyPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\UserForms\Tests\Form;
4
5
use SilverStripe\CMS\Controllers\ModelAsController;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\UserForms\Model\UserDefinedForm;
8
use SilverStripe\UserForms\Form\UserForm;
9
10
class UserFormTest extends SapphireTest
11
{
12
    protected static $fixture_file = '../Model/UserDefinedFormTest.yml';
13
14
    /**
15
     * Tests that a form will not generate empty pages
16
     */
17
    public function testEmptyPages()
18
    {
19
        $page = $this->objFromFixture(UserDefinedForm::class, 'empty-page');
20
        $this->assertEquals(5, $page->Fields()->count());
0 ignored issues
show
Bug introduced by
The method Fields() does not exist on SilverStripe\ORM\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...
21
        $controller = ModelAsController::controller_for($page);
0 ignored issues
show
Documentation introduced by
$page is of type object<SilverStripe\ORM\DataObject>|null, but the function expects a object<SilverStripe\CMS\Model\SiteTree>.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
22
        $form = new UserForm($controller);
23
        $this->assertEquals(2, $form->getSteps()->count());
24
    }
25
}
26