Completed
Push — master ( d8776d...afe412 )
by Robbie
46s queued 25s
created

tests/php/Forms/DatalessFieldTest.php (2 issues)

1
<?php
2
3
namespace SilverStripe\Forms;
4
5
use PHPUnit_Framework_MockObject_MockObject;
0 ignored issues
show
The type PHPUnit_Framework_MockObject_MockObject was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\Dev\SapphireTest;
7
8
class DatalessFieldTest extends SapphireTest
9
{
10
    public function testGetAttributes()
11
    {
12
        $field = new DatalessField('Name');
13
        $result = $field->getAttributes();
14
        $this->assertSame('hidden', $result['type']);
15
    }
16
17
    public function testFieldHolderAndSmallFieldHolderReturnField()
18
    {
19
        /** @var DatalessField|PHPUnit_Framework_MockObject_MockObject $mock */
20
        $mock = $this->getMockBuilder(DatalessField::class)
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\MockOb...ckBuilder::setMethods() has been deprecated: https://github.com/sebastianbergmann/phpunit/pull/3687 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
        $mock = /** @scrutinizer ignore-deprecated */ $this->getMockBuilder(DatalessField::class)

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
21
            ->disableOriginalConstructor()
22
            ->setMethods(['Field'])
23
            ->getMock();
24
25
        $properties = [
26
            'foo' => 'bar',
27
        ];
28
29
        $mock->expects($this->exactly(2))->method('Field')->with($properties)->willReturn('boo!');
30
31
        $fieldHolder = $mock->FieldHolder($properties);
32
        $smallFieldHolder = $mock->SmallFieldHolder($properties);
33
34
        $this->assertSame('boo!', $fieldHolder);
35
        $this->assertSame('boo!', $smallFieldHolder);
36
    }
37
38
    public function testPerformReadonlyTransformation()
39
    {
40
        $field = new DatalessField('Test');
41
        $result = $field->performReadonlyTransformation();
42
        $this->assertInstanceOf(DatalessField::class, $result);
43
        $this->assertTrue($result->isReadonly());
44
    }
45
}
46