2018-10-20 17:59:55 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms;
|
|
|
|
|
2021-10-27 04:39:47 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-10-20 17:59:55 +02:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
|
|
|
class DatalessFieldTest extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testGetAttributes()
|
|
|
|
{
|
|
|
|
$field = new DatalessField('Name');
|
|
|
|
$result = $field->getAttributes();
|
|
|
|
$this->assertSame('hidden', $result['type']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFieldHolderAndSmallFieldHolderReturnField()
|
|
|
|
{
|
2021-10-27 04:39:47 +02:00
|
|
|
/** @var DatalessField|MockObject $mock */
|
2018-10-20 17:59:55 +02:00
|
|
|
$mock = $this->getMockBuilder(DatalessField::class)
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->setMethods(['Field'])
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$properties = [
|
|
|
|
'foo' => 'bar',
|
|
|
|
];
|
|
|
|
|
|
|
|
$mock->expects($this->exactly(2))->method('Field')->with($properties)->willReturn('boo!');
|
|
|
|
|
|
|
|
$fieldHolder = $mock->FieldHolder($properties);
|
|
|
|
$smallFieldHolder = $mock->SmallFieldHolder($properties);
|
|
|
|
|
|
|
|
$this->assertSame('boo!', $fieldHolder);
|
|
|
|
$this->assertSame('boo!', $smallFieldHolder);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPerformReadonlyTransformation()
|
|
|
|
{
|
|
|
|
$field = new DatalessField('Test');
|
|
|
|
$result = $field->performReadonlyTransformation();
|
|
|
|
$this->assertInstanceOf(DatalessField::class, $result);
|
|
|
|
$this->assertTrue($result->isReadonly());
|
|
|
|
}
|
|
|
|
}
|