0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-01-11 03:48:10 +00:00
kevinpapst_kimai2/tests/Form/Extension/DocumentationLinkExtensionTest.php
2024-02-07 23:47:25 +01:00

46 lines
1.5 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\Extension;
use App\Form\Extension\DocumentationLinkExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @covers \App\Form\Extension\DocumentationLinkExtension
*/
class DocumentationLinkExtensionTest extends TestCase
{
public function testExtendedTypes(): void
{
self::assertEquals([FormType::class], DocumentationLinkExtension::getExtendedTypes());
}
public function testConfigureOptions(): void
{
$resolver = new OptionsResolver();
$sut = new DocumentationLinkExtension();
$sut->configureOptions($resolver);
self::assertEquals(['docu_chapter'], $resolver->getDefinedOptions());
self::assertTrue($resolver->hasDefault('docu_chapter'));
self::assertFalse($resolver->isRequired('docu_chapter'));
$result = $resolver->resolve(['docu_chapter' => 'foo']);
self::assertEquals(['docu_chapter' => 'foo'], $result);
$result = $resolver->resolve([]);
self::assertEquals(['docu_chapter' => ''], $result);
$this->expectException(InvalidOptionsException::class);
$resolver->resolve(['docu_chapter' => true]);
}
}