for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SilverStripe\UserForms\Tests\Form;
use SilverStripe\CMS\Controllers\ModelAsController;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\UserForms\Form\UserForm;
class UserFormTest extends SapphireTest
{
protected static $fixture_file = '../Model/UserDefinedFormTest.yml';
/**
* Tests that a form will not generate empty pages
*/
public function testEmptyPages()
$page = $this->objFromFixture(UserDefinedForm::class, 'empty-page');
$this->assertEquals(5, $page->Fields()->count());
Fields()
SilverStripe\ORM\DataObject
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.
$controller = ModelAsController::controller_for($page);
$page
object<SilverStripe\ORM\DataObject>|null
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);
$form = new UserForm($controller);
$this->assertEquals(2, $form->getSteps()->count());
}
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.