Merge branch '4.4' into 5.2
* 4.4: Specify that we run CI on Ubuntu-20.04 zero parts can be omitted in date interval input
This commit is contained in:
commit
5985199754
|
@ -15,7 +15,7 @@ defaults:
|
|||
jobs:
|
||||
tests:
|
||||
name: Tests (intl-data)
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: Ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -15,7 +15,7 @@ defaults:
|
|||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: Ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
|
|
@ -11,7 +11,7 @@ defaults:
|
|||
jobs:
|
||||
integration:
|
||||
name: Integration
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: Ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
|
|
|
@ -96,7 +96,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa
|
|||
$dateIntervalFormat = substr($dateIntervalFormat, 2);
|
||||
break;
|
||||
}
|
||||
$valuePattern = '/^'.$signPattern.preg_replace('/%([yYmMdDhHiIsSwW])(\w)/', '(?P<$1>\d+)$2', $dateIntervalFormat).'$/';
|
||||
$valuePattern = '/^'.$signPattern.preg_replace('/%([yYmMdDhHiIsSwW])(\w)/', '(?:(?P<$1>\d+)$2)?', preg_replace('/(T.*)$/', '($1)?', $dateIntervalFormat)).'$/';
|
||||
if (!preg_match($valuePattern, $data)) {
|
||||
throw new UnexpectedValueException(sprintf('Value "%s" contains intervals not accepted by format "%s".', $data, $dateIntervalFormat));
|
||||
}
|
||||
|
|
|
@ -104,6 +104,14 @@ class DateIntervalNormalizerTest extends TestCase
|
|||
$this->assertDateIntervalEquals($this->getInterval($output), $normalizer->denormalize($input, \DateInterval::class));
|
||||
}
|
||||
|
||||
public function testDenormalizeIntervalsWithOmittedPartsBeingZero()
|
||||
{
|
||||
$normalizer = new DateIntervalNormalizer();
|
||||
|
||||
$this->assertDateIntervalEquals($this->getInterval('P3Y2M4DT0H0M0S'), $normalizer->denormalize('P3Y2M4D', \DateInterval::class));
|
||||
$this->assertDateIntervalEquals($this->getInterval('P0Y0M0DT12H34M0S'), $normalizer->denormalize('PT12H34M', \DateInterval::class));
|
||||
}
|
||||
|
||||
public function testDenormalizeExpectsString()
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
|
Reference in New Issue