Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c84cc8

Browse files
Merge branch '5.2' into 5.3
* 5.2: [Form] Use !isset for checks cause this doesn't falsely include 0 [Mailer] Fix typo in README sync ./phpunit in all branches
2 parents acac5bb + 4114326 commit 6c84cc8

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

phpunit

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#!/usr/bin/env php
22
<?php
33

4-
// Cache-Id: 2021-05-10 15:20 UTC
4+
// Cache-Id: 2021-05-27 20:30 UTC
5+
// For caching to work properly on appveyor, this file
6+
// must be exactly the same in all maintained branches
57

68
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
79
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
810
exit(1);
911
}
1012
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
11-
if (\PHP_VERSION_ID < 70300) {
13+
if (\PHP_VERSION_ID < 70200) {
14+
putenv('SYMFONY_PHPUNIT_VERSION=7.5');
15+
} elseif (\PHP_VERSION_ID < 70300) {
1216
putenv('SYMFONY_PHPUNIT_VERSION=8.5');
1317
} else {
1418
putenv('SYMFONY_PHPUNIT_VERSION=9.5');

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ public function reverseTransform($value)
170170
empty($value['year']) ? $this->referenceDate->format('Y') : $value['year'],
171171
empty($value['month']) ? $this->referenceDate->format('m') : $value['month'],
172172
empty($value['day']) ? $this->referenceDate->format('d') : $value['day'],
173-
empty($value['hour']) ? $this->referenceDate->format('H') : $value['hour'],
174-
empty($value['minute']) ? $this->referenceDate->format('i') : $value['minute'],
175-
empty($value['second']) ? $this->referenceDate->format('s') : $value['second']
173+
$value['hour'] ?? $this->referenceDate->format('H'),
174+
$value['minute'] ?? $this->referenceDate->format('i'),
175+
$value['second'] ?? $this->referenceDate->format('s')
176176
),
177177
new \DateTimeZone($this->outputTimezone)
178178
);

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,32 @@ public function testSubmitFromSingleTextRaw()
204204
$this->assertEquals('02.06.2010', $form->getViewData());
205205
}
206206

207+
public function testArrayDateWithReferenceDoesUseReferenceTimeOnZero()
208+
{
209+
// we test against "de_DE", so we need the full implementation
210+
IntlTestHelper::requireFullIntl($this, false);
211+
212+
\Locale::setDefault('de_DE');
213+
214+
$input = [
215+
'day' => '0',
216+
'month' => '0',
217+
'year' => '0',
218+
];
219+
220+
$form = $this->factory->create(static::TESTED_TYPE, $input, [
221+
'format' => \IntlDateFormatter::MEDIUM,
222+
'html5' => false,
223+
'model_timezone' => 'UTC',
224+
'view_timezone' => 'Europe/Berlin',
225+
'input' => 'array',
226+
'widget' => 'single_text',
227+
]);
228+
229+
$this->assertSame($input, $form->getData());
230+
$this->assertEquals('01.01.1970', $form->getViewData());
231+
}
232+
207233
public function testSubmitFromText()
208234
{
209235
$form = $this->factory->create(static::TESTED_TYPE, null, [

src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,28 @@ public function testSubmitNullUsesDefaultEmptyData($emptyData = [], $expectedDat
978978
$this->assertSame($expectedData, $form->getData());
979979
}
980980

981+
public function testArrayTimeWithReferenceDoesNotUseReferenceTimeOnZero()
982+
{
983+
$form = $this->factory->create(static::TESTED_TYPE, null, [
984+
'model_timezone' => 'UTC',
985+
'view_timezone' => 'Europe/Berlin',
986+
'reference_date' => new \DateTimeImmutable('01-01-2021 12:34:56', new \DateTimeZone('UTC')),
987+
'input' => 'array',
988+
]);
989+
990+
$input = [
991+
'hour' => '0',
992+
'minute' => '0',
993+
];
994+
$form->submit($input);
995+
996+
$this->assertEquals([
997+
'hour' => '23',
998+
'minute' => '0',
999+
], $form->getData());
1000+
$this->assertSame($input, $form->getViewData());
1001+
}
1002+
9811003
/**
9821004
* @dataProvider provideEmptyData
9831005
*/

src/Symfony/Component/Mailer/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,20 @@ set up the `BodyRenderer`:
3636

3737
```php
3838
use Symfony\Bridge\Twig\Mime\BodyRenderer;
39+
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
3940
use Symfony\Component\EventDispatcher\EventDispatcher;
4041
use Symfony\Component\Mailer\EventListener\MessageListener;
42+
use Symfony\Component\Mailer\Mailer;
43+
use Symfony\Component\Mailer\Transport;
4144
use Twig\Environment as TwigEnvironment;
4245

4346
$twig = new TwigEnvironment(...);
44-
$messageListener = new MessageListener(new BodyRenderer($twig));
47+
$messageListener = new MessageListener(null, new BodyRenderer($twig));
4548

4649
$eventDispatcher = new EventDispatcher();
4750
$eventDispatcher->addSubscriber($messageListener);
4851

52+
$transport = Transport::fromDsn('smtp://localhost', $eventDispatcher);
4953
$mailer = new Mailer($transport, null, $eventDispatcher);
5054

5155
$email = (new TemplatedEmail())
@@ -56,7 +60,7 @@ $email = (new TemplatedEmail())
5660
'username' => 'foo',
5761
])
5862
;
59-
$mailer->mail($email);
63+
$mailer->send($email);
6064
```
6165

6266
Resources

0 commit comments

Comments
 (0)