165 lines
6.2 KiB
YAML
165 lines
6.2 KiB
YAML
name: DateTimeNormalizerTest
|
|
class_comment: "# * @author K\xE9vin Dunglas <dunglas@gmail.com>"
|
|
dependencies:
|
|
- name: TestCase
|
|
type: class
|
|
source: PHPUnit\Framework\TestCase
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: Symfony\Component\Serializer\Exception\InvalidArgumentException
|
|
- name: UnexpectedValueException
|
|
type: class
|
|
source: Symfony\Component\Serializer\Exception\UnexpectedValueException
|
|
- name: DateTimeNormalizer
|
|
type: class
|
|
source: Symfony\Component\Serializer\Normalizer\DateTimeNormalizer
|
|
properties: []
|
|
methods:
|
|
- name: testNormalizeUsingTimeZonePassedInContext
|
|
visibility: public
|
|
parameters:
|
|
- name: expected
|
|
- name: input
|
|
- name: timezone
|
|
comment: "# * @author K\xE9vin Dunglas <dunglas@gmail.com>\n# */\n# class DateTimeNormalizerTest\
|
|
\ extends TestCase\n# {\n# private DateTimeNormalizer $normalizer;\n# \n# protected\
|
|
\ function setUp(): void\n# {\n# $this->normalizer = new DateTimeNormalizer();\n\
|
|
# }\n# \n# public function testSupportsNormalization()\n# {\n# $this->assertTrue($this->normalizer->supportsNormalization(new\
|
|
\ \\DateTime()));\n# $this->assertTrue($this->normalizer->supportsNormalization(new\
|
|
\ \\DateTimeImmutable()));\n# $this->assertFalse($this->normalizer->supportsNormalization(new\
|
|
\ \\stdClass()));\n# }\n# \n# public function testNormalize()\n# {\n# $this->assertEquals('2016-01-01T00:00:00+00:00',\
|
|
\ $this->normalizer->normalize(new \\DateTime('2016/01/01', new \\DateTimeZone('UTC'))));\n\
|
|
# $this->assertEquals('2016-01-01T00:00:00+00:00', $this->normalizer->normalize(new\
|
|
\ \\DateTimeImmutable('2016/01/01', new \\DateTimeZone('UTC'))));\n# }\n# \n#\
|
|
\ public function testNormalizeUsingFormatPassedInContext()\n# {\n# $this->assertEquals('2016',\
|
|
\ $this->normalizer->normalize(new \\DateTimeImmutable('2016/01/01'), null, [DateTimeNormalizer::FORMAT_KEY\
|
|
\ => 'Y']));\n# }\n# \n# public function testNormalizeUsingFormatPassedInConstructor()\n\
|
|
# {\n# $normalizer = new DateTimeNormalizer([DateTimeNormalizer::FORMAT_KEY =>\
|
|
\ 'y']);\n# $this->assertEquals('16', $normalizer->normalize(new \\DateTimeImmutable('2016/01/01',\
|
|
\ new \\DateTimeZone('UTC'))));\n# }\n# \n# public function testNormalizeUsingTimeZonePassedInConstructor()\n\
|
|
# {\n# $normalizer = new DateTimeNormalizer([DateTimeNormalizer::TIMEZONE_KEY\
|
|
\ => new \\DateTimeZone('Japan')]);\n# \n# $this->assertSame('2016-12-01T00:00:00+09:00',\
|
|
\ $normalizer->normalize(new \\DateTimeImmutable('2016/12/01', new \\DateTimeZone('Japan'))));\n\
|
|
# $this->assertSame('2016-12-01T09:00:00+09:00', $normalizer->normalize(new \\\
|
|
DateTimeImmutable('2016/12/01', new \\DateTimeZone('UTC'))));\n# }\n# \n# /**\n\
|
|
# * @dataProvider normalizeUsingTimeZonePassedInContextProvider"
|
|
- name: normalizeUsingTimeZonePassedInContextProvider
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testNormalizeUsingTimeZonePassedInContextAndFormattedWithMicroseconds
|
|
visibility: public
|
|
parameters:
|
|
- name: expected
|
|
- name: expectedFormat
|
|
- name: input
|
|
- name: timezone
|
|
comment: '# * @dataProvider normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider'
|
|
- name: normalizeUsingTimeZonePassedInContextAndExpectedFormatWithMicrosecondsProvider
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testNormalizeUsingCastPassedInConstructor
|
|
visibility: public
|
|
parameters:
|
|
- name: value
|
|
- name: format
|
|
- name: cast
|
|
- name: expectedResult
|
|
comment: '# * @dataProvider provideNormalizeUsingCastCases'
|
|
- name: testNormalizeUsingCastPassedInContext
|
|
visibility: public
|
|
parameters:
|
|
- name: value
|
|
- name: format
|
|
- name: cast
|
|
- name: expectedResult
|
|
comment: '# * @dataProvider provideNormalizeUsingCastCases'
|
|
- name: provideNormalizeUsingCastCases
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * @return iterable<array{0: \DateTimeImmutable, 1: non-empty-string,
|
|
2: ''int''|''float''|null, 3: ''int''|''float''|''string''}>'
|
|
- name: testNormalizeInvalidObjectThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testSupportsDenormalization
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalize
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeUsingTimezonePassedInConstructor
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeUsingFormatPassedInContext
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeUsingTimezonePassedInContext
|
|
visibility: public
|
|
parameters:
|
|
- name: input
|
|
- name: expected
|
|
- name: timezone
|
|
- name: format
|
|
default: 'null'
|
|
comment: '# * @dataProvider denormalizeUsingTimezonePassedInContextProvider'
|
|
- name: denormalizeUsingTimezonePassedInContextProvider
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeInvalidDataThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeWrongTypeThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeNullThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeEmptyStringThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeStringWithSpacesOnlyThrowsAnException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeDateTimeStringWithSpacesUsingFormatPassedInContextThrowsAnException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeTimestampWithFormatInContext
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeTimestampWithFormatInDefaultContext
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeDateTimeStringWithDefaultContextFormat
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeDateTimeStringWithDefaultContextAllowsErrorFormat
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: testDenormalizeFormatMismatchThrowsException
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
traits:
|
|
- PHPUnit\Framework\TestCase
|
|
- Symfony\Component\Serializer\Exception\InvalidArgumentException
|
|
- Symfony\Component\Serializer\Exception\UnexpectedValueException
|
|
- Symfony\Component\Serializer\Normalizer\DateTimeNormalizer
|
|
interfaces: []
|