* do not close modal if form is dirty * deprecated TimesheetConfiguration * inject timezone in form types * cleanup usage of UserDateTimeFactory * allow to configure increment steps for minutes * use 15 minutes step for datetimepicker in project edit form * use rounding rules for increments in minute select for begin and end * allow duration in multi user and admin timesheet forms * make dropdown values configurable
55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Tests\Form;
|
|
|
|
use App\Form\FormTrait;
|
|
use App\Tests\Form\Type\TypeTestModel;
|
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
|
use Symfony\Component\Form\Test\TypeTestCase;
|
|
|
|
/**
|
|
* @covers \App\Form\FormTrait
|
|
*/
|
|
class FormTraitTest extends TypeTestCase
|
|
{
|
|
use FormTrait;
|
|
|
|
/**
|
|
* @expectedDeprecation FormTrait::addDescription() is deprecated and will be removed with 2.0, use DescriptionType instead
|
|
* @group legacy
|
|
*/
|
|
public function testAddDescription()
|
|
{
|
|
$data = ['description' => 'foo'];
|
|
$model = new TypeTestModel(['description' => 'bar']);
|
|
|
|
$form = $this->factory->createBuilder(FormType::class, $model);
|
|
$this->addDescription($form);
|
|
|
|
$desc = $form->get('description');
|
|
self::assertArrayHasKey('autofocus', $desc->getOption('attr'));
|
|
self::assertEquals('autofocus', $desc->getOption('attr')['autofocus']);
|
|
|
|
$form = $form->getForm();
|
|
|
|
$desc = $form->get('description');
|
|
self::assertFalse($desc->isRequired());
|
|
|
|
$expected = new TypeTestModel([
|
|
'description' => 'foo'
|
|
]);
|
|
|
|
$form->submit($data);
|
|
|
|
$this->assertTrue($form->isSynchronized());
|
|
$this->assertEquals($expected, $model);
|
|
}
|
|
}
|