Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [Serializer] Improve exception message in UnwrappingDenormalizer
  [PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type
  Update security.nl.xlf
  [Validator] IBAN Check digits should always between 2 and 98
  [Security] Populate translations for trans-unit 20
  add missing plural translation messages
  filter out empty HTTP header parts
  [String] Fix folded in compat mode
  Remove calls to `getMockForAbstractClass()`
  [ErrorHandler] Do not call xdebug_get_function_stack() with xdebug >= 3.0 when not in develop mode
  [Serializer] Fix type for missing property
  add test for JSON response with null as content
  [Filesystem] Fix dumpFile `stat failed` error hitting custom handler
  Return false in isTtySupported() when open_basedir restrictions prevent access to /dev/tty.
  Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder`
  [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
  • Loading branch information
fabpot committed May 17, 2024
2 parents a492b5c + 41695c0 commit 89d535a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Test/Traits/ValidatorExtensionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ protected function getValidatorExtension(): ValidatorExtension

$this->validator = $this->createMock(ValidatorInterface::class);
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock();
$this->validator->expects($this->any())->method('getMetadataFor')->will($this->returnValue($metadata));
$this->validator->expects($this->any())->method('validate')->will($this->returnValue(new ConstraintViolationList()));
$this->validator->expects($this->any())->method('getMetadataFor')->willReturn($metadata);
$this->validator->expects($this->any())->method('validate')->willReturn(new ConstraintViolationList());

return new ValidatorExtension($this->validator, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTe
protected \DateTime $dateTimeWithoutSeconds;
private string $defaultLocale;

private $initialTestCaseUseException;
private $initialTestCaseErrorLevel;

protected function setUp(): void
{
parent::setUp();

// Normalize intl. configuration settings.
if (\extension_loaded('intl')) {
$this->iniSet('intl.use_exceptions', 0);
$this->iniSet('intl.error_level', 0);
$this->initialTestCaseUseException = ini_set('intl.use_exceptions', 0);
$this->initialTestCaseErrorLevel = ini_set('intl.error_level', 0);
}

// Since we test against "de_AT", we need the full implementation
Expand All @@ -48,6 +51,11 @@ protected function setUp(): void
protected function tearDown(): void
{
\Locale::setDefault($this->defaultLocale);

if (\extension_loaded('intl')) {
ini_set('intl.use_exceptions', $this->initialTestCaseUseException);
ini_set('intl.error_level', $this->initialTestCaseUseException);
}
}

public static function dataProvider()
Expand Down Expand Up @@ -337,11 +345,15 @@ public function testReverseTransformWrapsIntlErrorsWithErrorLevel()
$this->markTestSkipped('intl extension is not loaded');
}

$this->iniSet('intl.error_level', \E_WARNING);
$errorLevel = ini_set('intl.error_level', \E_WARNING);

$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
try {
$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
} finally {
ini_set('intl.error_level', $errorLevel);
}
}

public function testReverseTransformWrapsIntlErrorsWithExceptions()
Expand All @@ -350,11 +362,15 @@ public function testReverseTransformWrapsIntlErrorsWithExceptions()
$this->markTestSkipped('intl extension is not loaded');
}

$this->iniSet('intl.use_exceptions', 1);
$initialUseExceptions = ini_set('intl.use_exceptions', 1);

$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
try {
$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
} finally {
ini_set('intl.use_exceptions', $initialUseExceptions);
}
}

public function testReverseTransformWrapsIntlErrorsWithExceptionsAndErrorLevel()
Expand All @@ -363,12 +379,17 @@ public function testReverseTransformWrapsIntlErrorsWithExceptionsAndErrorLevel()
$this->markTestSkipped('intl extension is not loaded');
}

$this->iniSet('intl.use_exceptions', 1);
$this->iniSet('intl.error_level', \E_WARNING);
$initialUseExceptions = ini_set('intl.use_exceptions', 1);
$initialErrorLevel = ini_set('intl.error_level', \E_WARNING);

$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
try {
$this->expectException(TransformationFailedException::class);
$transformer = new DateTimeToLocalizedStringTransformer();
$transformer->reverseTransform('12345');
} finally {
ini_set('intl.use_exceptions', $initialUseExceptions);
ini_set('intl.error_level', $initialErrorLevel);
}
}

protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
Expand Down

0 comments on commit 89d535a

Please sign in to comment.