mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Add tests for DatalessField
This commit is contained in:
parent
c06cf4820e
commit
0e2847e289
45
tests/php/Forms/DatalessFieldTest.php
Normal file
45
tests/php/Forms/DatalessFieldTest.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use PHPUnit_Framework_MockObject_MockObject;
|
||||
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()
|
||||
{
|
||||
/** @var DatalessField|PHPUnit_Framework_MockObject_MockObject $mock */
|
||||
$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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user