Skip to content

Commit d166d11

Browse files
committed
Update DurationType to exclude seconds by default
1 parent 62a7edb commit d166d11

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/Form/DurationType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function configureOptions(OptionsResolver $resolver): void
128128
'day' => false,
129129
'hour' => true,
130130
'minute' => true,
131-
'second' => true,
131+
'second' => false,
132132
]);
133133

134134
$resolver->setAllowedTypes('year', 'bool');

tests/Form/DurationTypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ public function testSubmitValidData(): void
1919
$form->submit([
2020
'hour' => '3',
2121
'minute' => '34',
22-
'second' => '12',
2322
]);
2423

2524
// Assert
2625
$this->assertTrue($form->isSynchronized());
27-
$this->assertEquals(new Second("12852"), $form->getData()->getValue());
26+
$this->assertEquals(new Second("12840"), $form->getData()->getValue());
2827
}
2928

3029
public function testConfigureAnotherUnit(): void
3130
{
3231
// Arrange
3332
$form = $this->factory->create(DurationType::class, null, [
3433
'month' => true,
34+
'second' => true,
3535
]);
3636

3737
// Act
@@ -63,7 +63,7 @@ public function testSubmitNull(): void
6363
public function testWithPreData(): void
6464
{
6565
// Arrange
66-
$form = $this->factory->create(DurationType::class, Duration::create(new Hour(3)));
66+
$form = $this->factory->create(DurationType::class, Duration::create(new Hour(3.2)));
6767

6868
// Act
6969
$view = $form->createView();
@@ -74,8 +74,8 @@ public function testWithPreData(): void
7474
'month' => null,
7575
'day' => null,
7676
'hour' => '3',
77-
'minute' => '0',
78-
'second' => '0',
77+
'minute' => '12',
78+
'second' => null,
7979
], $view->vars['value']);
8080
}
8181

0 commit comments

Comments
 (0)