Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ jobs:
fail-fast: false
matrix:
php-version: [ '8.1', '8.2', '8.3', '8.4' ]
symfony-version: [ '6.4.*', '7.3.*' ]
symfony-version: [ '6.4.*', '7.4.*' ]
exclude:
- php-version: '8.1'
symfony-version: '7.3.*'
symfony-version: '7.4.*'
include:
- php-version: '8.2'
symfony-version: '7.4.0-RC3'
minimum-stability: 'RC'
- php-version: '8.4'
symfony-version: '8.0.0-RC3'
minimum-stability: 'RC'
symfony-version: '8.0.*'

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 0 additions & 2 deletions tests/FormLayout/TextLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Symfony\Component\Form\Extension\Core\Type\SearchType;
use Symfony\Component\Form\Extension\Core\Type\TelType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormError;
use TalesFromADev\FlowbiteBundle\Tests\AbstractFlowbiteLayoutTestCase;

Expand Down Expand Up @@ -96,7 +95,6 @@ public static function inputProvider(): \Generator
yield NumberType::class => [NumberType::class, 1234.56, 'text'];
yield PasswordType::class => [PasswordType::class, null, 'password'];
yield SearchType::class => [SearchType::class, '1', 'search'];
yield UrlType::class => [UrlType::class, 'https://example.com', 'text'];
yield TelType::class => [TelType::class, '0123456789', 'tel'];
yield ColorType::class => [ColorType::class, '#ffffff', 'color'];
}
Expand Down
84 changes: 84 additions & 0 deletions tests/FormLayout/UrlLayoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

declare(strict_types=1);

namespace FormLayout;

use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormError;
use TalesFromADev\FlowbiteBundle\Tests\AbstractFlowbiteLayoutTestCase;

final class UrlLayoutTest extends AbstractFlowbiteLayoutTestCase
{
public function testInputWithDefaultProtocol()
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';

$form = $this->factory->createNamed('name', UrlType::class, $url, ['default_protocol' => 'http']);

$this->assertWidgetMatchesXpath($form->createView(), [],
'/input
[@type="text"]
[@name="name"]
[@id="name"]
[@class="bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base block w-full px-3 py-2.5 shadow-xs focus:ring-brand focus:border-brand placeholder:text-body"]
[@value="http://www.example.com?foo1=bar1&foo2=bar2"]
[@inputmode="url"]
'
);
}

public function testInputWithoutDefaultProtocol()
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';

$form = $this->factory->createNamed('name', UrlType::class, $url, ['default_protocol' => null]);

$this->assertWidgetMatchesXpath($form->createView(), [],
'/input
[@type="url"]
[@name="name"]
[@id="name"]
[@class="bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base block w-full px-3 py-2.5 shadow-xs focus:ring-brand focus:border-brand placeholder:text-body"]
[@value="http://www.example.com?foo1=bar1&foo2=bar2"]
'
);
}

public function testInputError(): void
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';

$form = $this->factory->createNamed('name', UrlType::class, $url, ['default_protocol' => null]);
$form->addError(new FormError('[trans]Error message[/trans]'));
$form->submit([]);

$this->assertWidgetMatchesXpath($form->createView(), [],
'/input
[@type="url"]
[@name="name"]
[@id="name"]
[@class="border text-sm rounded-base block w-full px-3 py-2.5 shadow-xs bg-danger-soft border-danger-subtle text-fg-danger-strong focus:ring-danger focus:border-danger placeholder:text-fg-danger-strong"]
'
);
}

public function testInputDisabled(): void
{
$url = 'http://www.example.com?foo1=bar1&foo2=bar2';

$form = $this->factory->createNamed('name', UrlType::class, $url, ['default_protocol' => null, 'disabled' => true]);
$form->submit([]);

$this->assertWidgetMatchesXpath($form->createView(), [],
'/input
[@type="url"]
[@name="name"]
[@id="name"]
[@disabled="disabled"]
[@class="bg-neutral-secondary-medium border border-default-medium text-heading text-sm rounded-base block w-full px-3 py-2.5 shadow-xs focus:ring-brand focus:border-brand placeholder:text-body disabled:text-fg-disabled disabled:cursor-not-allowed"]
[@value="http://www.example.com?foo1=bar1&foo2=bar2"]
'
);
}
}