mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
49 lines
1.1 KiB
PHP
Executable File
49 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
use SilverStripe\ORM\FieldType\DBYear;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
|
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class DBYearTest extends SapphireTest {
|
|
|
|
/**
|
|
* Test that the scaffolding form field works
|
|
*/
|
|
public function testScaffoldFormFieldFirst() {
|
|
$year = new DBYear();
|
|
$field = $year->scaffoldFormField("YearTest");
|
|
$this->assertEquals("SilverStripe\\Forms\\DropdownField", get_class($field));
|
|
|
|
//This should be a list of years from the current one, counting down to 1900
|
|
$source = $field->getSource();
|
|
|
|
$lastValue = end($source);
|
|
$lastKey = key($source);
|
|
|
|
//Keys and values should be the same - and the last one should be 1900
|
|
$this->assertEquals(1900, $lastValue);
|
|
$this->assertEquals(1900, $lastKey);
|
|
}
|
|
|
|
public function testScaffoldFormFieldLast() {
|
|
$year = new DBYear();
|
|
$field = $year->scaffoldFormField("YearTest");
|
|
$source = $field->getSource();
|
|
|
|
//The first one should be the current year
|
|
$currentYear = (int)date('Y');
|
|
$firstValue = reset($source);
|
|
$firstKey = key($source);
|
|
|
|
$this->assertEquals($currentYear, $firstValue);
|
|
$this->assertEquals($currentYear, $firstKey);
|
|
|
|
}
|
|
}
|