configurable csv/xlsx export templates (#5531)
This commit is contained in:
61
tests/Form/ExportTemplateSpreadsheetFormTest.php
Normal file
61
tests/Form/ExportTemplateSpreadsheetFormTest.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\Configuration\LocaleService;
|
||||
use App\Entity\ExportTemplate;
|
||||
use App\Form\ExportTemplateSpreadsheetForm;
|
||||
use App\Form\Type\ExportColumnsType;
|
||||
use App\Form\Type\LanguageType;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Form\FormTypeInterface;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\ExportTemplateSpreadsheetForm
|
||||
*/
|
||||
class ExportTemplateSpreadsheetFormTest extends TypeTestCase
|
||||
{
|
||||
/**
|
||||
* @return FormTypeInterface[]
|
||||
*/
|
||||
protected function getTypes(): array // @phpstan-ignore missingType.generics
|
||||
{
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
|
||||
return [
|
||||
new ExportColumnsType($dispatcher, $translator),
|
||||
new LanguageType(new LocaleService([]))
|
||||
];
|
||||
}
|
||||
|
||||
public function testWithGlobalNewActivity(): void
|
||||
{
|
||||
$model = new ExportTemplate();
|
||||
$form = $this->factory->createBuilder(ExportTemplateSpreadsheetForm::class, $model);
|
||||
|
||||
$attr = $form->getFormConfig()->getOption('attr');
|
||||
self::assertIsArray($attr);
|
||||
self::assertArrayHasKey('data-form-event', $attr);
|
||||
self::assertEquals('kimai.exportTemplate', $attr['data-form-event']);
|
||||
|
||||
self::assertTrue($form->has('title'));
|
||||
self::assertTrue($form->has('renderer'));
|
||||
self::assertTrue($form->has('language'));
|
||||
self::assertTrue($form->has('columns'));
|
||||
|
||||
self::assertTrue($form->get('title')->getRequired());
|
||||
self::assertTrue($form->get('renderer')->getRequired());
|
||||
self::assertFalse($form->get('language')->getRequired());
|
||||
self::assertTrue($form->get('columns')->getRequired());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user