prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Component\Validator\Constraints\NoSuspiciousCharacters; use Symfony\Component\Validator\Constraints\NoSuspiciousCh...
#[DataProvider('provideNonSuspiciousStrings')] public function testNonSuspiciousStrings(string $string, array $options = []) { $this->validate($string, new NoSuspiciousCharacters(...$options)); $this->assertNoViolation(); }
ntl')] class NoSuspiciousCharactersValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): NoSuspiciousCharactersValidator { return new NoSuspiciousCharactersValidator(); }
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/NoSuspiciousCharactersValidatorTest.php", "language": "php", "file_size": 7423, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator...
hrowsOnInvalidStringDatesTestTrait; use ValidComparisonToValueTrait; protected function createValidator(): NotEqualToValidator { return new NotEqualToValidator(); } protected static function createConstraint(?array $options =
ielholmes.org> */ class NotEqualToValidatorTest extends AbstractComparisonValidatorTestCase { use CompareWithNullValueAtPropertyAtTestTrait; use IcuCompatibilityTrait; use InvalidComparisonToValueTestTrait; use T
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/NotEqualToValidatorTest.php", "language": "php", "file_size": 2805, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; use Symfony\Compo...
a)); [$aConstraint] = $metadata->getPropertyMetadata('a')[0]->getConstraints(); self::assertSame(2, $aConstraint->value); self::assertNull($aConstraint->propertyPath); [$bConstraint] = $metadata->getPropertyMetadata('b')[0
tends TestCase { public function testAttributes() { $metadata = new ClassMetadata(LessThanOrEqualDummy::class); $loader = new AttributeLoader(); self::assertTrue($loader->loadClassMetadata($metadat
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/LessThanOrEqualTest.php", "language": "php", "file_size": 1807, "cut_index": 537, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; use ...
straint] = $metadata->getPropertyMetadata('b')[0]->getConstraints(); self::assertSame('myMessage', $bConstraint->message); self::assertSame(['Default', 'LuhnDummy'], $bConstraint->groups); [$cConstraint] = $metadata->getPropertyMet
tCase { public function testAttributes() { $metadata = new ClassMetadata(LuhnDummy::class); $loader = new AttributeLoader(); self::assertTrue($loader->loadClassMetadata($metadata)); [$bCon
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/LuhnTest.php", "language": "php", "file_size": 1365, "cut_index": 524, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Validator\Constraints\Issn; use Symfony\Component\Validat...
erCasedIssn() { return [ ['2162-321x'], ['2160-200x'], ['1537-453x'], ['1937-710x'], ['0002-922x'], ['1553-345x'], ['1553-619x'], ]; } public s
pedia.org/wiki/Issn */ class IssnValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): IssnValidator { return new IssnValidator(); } public static function getValidLow
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/IssnValidatorTest.php", "language": "php", "file_size": 4800, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Val...
$this->assertNoViolation(); } public static function getValidValues() { return [ ['foobar'], [0], [0.0], ['0'], [1234], ]; } public function testNull
n createValidator(): NotBlankValidator { return new NotBlankValidator(); } #[DataProvider('getValidValues')] public function testValidValues($value) { $this->validate($value, new NotBlank());
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/NotBlankValidatorTest.php", "language": "php", "file_size": 3683, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Week; use Symfony\Component\Validator\Exception\Co...
010-W01', max: '2010-W02'); $this->assertSame('2010-W01', $week->min); $this->assertSame('2010-W02', $week->max); } public function testMinYearIsAfterMaxYear() { $this->expectException(ConstraintDefinitionException::cl
c function testWithoutArgument() { $week = new Week(); $this->assertNull($week->min); $this->assertNull($week->max); } public function testConstructor() { $week = new Week(min: '2
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WeekTest.php", "language": "php", "file_size": 3283, "cut_index": 614, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Test; use PHPUnit\Framework\ExpectationFailedException; use Sy...
rn new TestCustomValidator(); } public function testAssertingContextualValidatorRemainingExpectationsThrow() { $this->expectValidateValueAt(0, 'k1', 'ccc', [ new NotNull(), ]); $this->expectValidateValueAt(1
ator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; class ConstraintValidatorTestCaseTest extends ConstraintValidatorTestCase { protected function createValidator(): TestCustomValidator { retu
{ "filepath": "src/Symfony/Component/Validator/Tests/Test/ConstraintValidatorTestCaseTest.php", "language": "php", "file_size": 2012, "cut_index": 537, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\DependencyInjection; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjecti...
ntainerBuilder(); (new AddAutoMappingConfigurationPass())->process($container); $this->assertCount(1, $container->getDefinitions()); } public function testNoValidatorBuilder() { $container = new ContainerBuilder();
omponent\Validator\ValidatorBuilder; /** * @author Kévin Dunglas <dunglas@gmail.com> */ class AddAutoMappingConfigurationPassTest extends TestCase { public function testNoConfigParameter() { $container = new Co
{ "filepath": "src/Symfony/Component/Validator/Tests/DependencyInjection/AddAutoMappingConfigurationPassTest.php", "language": "php", "file_size": 3484, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony...
) { $container = new ContainerBuilder(); $validatorFactory = $container->register('validator.validator_factory') ->addArgument([]); $container->register('my_constraint_validator_service1', Validator1::class)
ction\ServiceLocator; use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass; class AddConstraintValidatorsPassTest extends TestCase { public function testThatConstraintValidatorServicesAreProcessed(
{ "filepath": "src/Symfony/Component/Validator/Tests/DependencyInjection/AddConstraintValidatorsPassTest.php", "language": "php", "file_size": 3484, "cut_index": 614, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\DependencyInjection; use PHPUnit\Framework\TestCa...
('validator.initializer') ; $container ->register('initializer2') ->addTag('validator.initializer') ; $container ->register('validator.builder') ->addArgument([]) ;
sPass; class AddValidatorInitializersPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $container ->register('initializer1') ->addTag
{ "filepath": "src/Symfony/Component/Validator/Tests/DependencyInjection/AddValidatorInitializersPassTest.php", "language": "php", "file_size": 1307, "cut_index": 524, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Vali...
} public function testProcessWithValidatorBuilderButNoTaggedServices() { $container = new ContainerBuilder(); $container->register('validator.builder'); $pass = new AttributeMetadataPass(); $pass->process($contai
WithNoValidatorBuilder() { $container = new ContainerBuilder(); // Should not throw any exception (new AttributeMetadataPass())->process($container); $this->expectNotToPerformAssertions();
{ "filepath": "src/Symfony/Component/Validator/Tests/DependencyInjection/AttributeMetadataPassTest.php", "language": "php", "file_size": 4198, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Test; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; use Symfony\Component\Translation\IdentityTranslator; use...
tor\Validator\ValidatorInterface; /** * A test case to ease testing Compound Constraints. * * @author Alexandre Daubois <alex.daubois@gmail.com> * * @template T of Compound */ abstract class CompoundConstraintTestCase extends TestCase { protecte
nstraintViolationListInterface; use Symfony\Component\Validator\Context\ExecutionContext; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Validation; use Symfony\Component\Valida
{ "filepath": "src/Symfony/Component/Validator/Test/CompoundConstraintTestCase.php", "language": "php", "file_size": 4252, "cut_index": 614, "middle_length": 229 }
intValidator; use Symfony\Component\Validator\ConstraintValidatorInterface; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\ConstraintViolationInterface; use Symfony\Component\Validator\ConstraintViolationList; use Symfony\Component\Validator\ConstraintViolationListInterface; use Sy...
ce; use Symfony\Contracts\Translation\TranslatorInterface; /** * A test case to ease testing Constraint Validators. * * @author Bernhard Schussek <bschussek@gmail.com> * * @template T of ConstraintValidatorInterface */ abstract class ConstraintValid
ent\Validator\Mapping\MetadataInterface; use Symfony\Component\Validator\Mapping\PropertyMetadata; use Symfony\Component\Validator\Validator\ContextualValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterfa
{ "filepath": "src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php", "language": "php", "file_size": 20525, "cut_index": 1331, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\DependencyInjection; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;...
{ if (!$container->hasParameter('validator.auto_mapping') || !$container->hasDefinition('validator.builder')) { return; } $config = $container->getParameter('validator.auto_mapping'); $globalNamespaces = []
ed with the "validator.auto_mapper" tag. * * @author Kévin Dunglas <dunglas@gmail.com> */ class AddAutoMappingConfigurationPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void
{ "filepath": "src/Symfony/Component/Validator/DependencyInjection/AddAutoMappingConfigurationPass.php", "language": "php", "file_size": 2703, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\DependencyInjection; use Symfony\Component\DependencyInjection\Compi...
s(ContainerBuilder $container): void { if (!$container->hasDefinition('validator.validator_factory')) { return; } $validators = []; foreach ($container->findTaggedServiceIds('validator.constraint_validator',
yInjection\Reference; /** * @author Johannes M. Schmitt <schmittjoh@gmail.com> * @author Robin Chalas <robin.chalas@gmail.com> */ class AddConstraintValidatorsPass implements CompilerPassInterface { public function proces
{ "filepath": "src/Symfony/Component/Validator/DependencyInjection/AddConstraintValidatorsPass.php", "language": "php", "file_size": 1522, "cut_index": 537, "middle_length": 229 }
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\DependencyInjection; use Symfony\Component\Depend...
ntainer->hasDefinition('validator.builder')) { return; } $initializers = []; foreach ($container->findTaggedServiceIds('validator.initializer', true) as $id => $attributes) { $initializers[] = new Reference(
<fabien@symfony.com> * @author Robin Chalas <robin.chalas@gmail.com> */ class AddValidatorInitializersPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void { if (!$co
{ "filepath": "src/Symfony/Component/Validator/DependencyInjection/AddValidatorInitializersPass.php", "language": "php", "file_size": 1141, "cut_index": 518, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\DependencyInjection; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;...
= $container->getParameterBag()->resolveValue(...); $mappedClasses = []; foreach ($container->getDefinitions() as $id => $definition) { if (!$definition->hasTag('validator.attribute_metadata')) { continue;
eMetadataPass implements CompilerPassInterface { public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('validator.builder')) { return; } $resolve
{ "filepath": "src/Symfony/Component/Validator/DependencyInjection/AttributeMetadataPass.php", "language": "php", "file_size": 2667, "cut_index": 563, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; use Psr\Clock\ClockInterface as PsrClockInterface; /** * A global clock. * * @author Nicolas ...
eTrait when possible instead of using this method. */ public static function get(): ClockInterface { return self::$globalClock ??= new NativeClock(); } public static function set(PsrClockInterface $clock): void { s
erface $clock = null, private ?\DateTimeZone $timezone = null, ) { } /** * Returns the current global clock. * * Note that you should prefer injecting a ClockInterface or using * ClockAwar
{ "filepath": "src/Symfony/Component/Clock/Clock.php", "language": "php", "file_size": 2076, "cut_index": 563, "middle_length": 229 }
* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; use Psr\Clock\ClockInterface; use Symfony\Contracts\Se...
lockInterface $clock): void { $this->clock = $clock; } protected function now(): DatePoint { $now = ($this->clock ??= new Clock())->now(); return $now instanceof DatePoint ? $now : DatePoint::createFromInterface($n
ock; #[Required] public function setClock(C
{ "filepath": "src/Symfony/Component/Clock/ClockAwareTrait.php", "language": "php", "file_size": 841, "cut_index": 520, "middle_length": 52 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; /** * An immmutable DateTime with stricter error handling and return types than the native one. * * @author Nicolas Grekas <p@tchwork.com> */ fi...
reateFromInterface($now); } $builtInDate = new parent($datetime, $timezone ?? $now->getTimezone()); $timezone = $builtInDate->getTimezone(); $now = $now->setTimezone($timezone)->modify($datetime);
, ?\DateTimeZone $timezone = null, ?parent $reference = null) { $now = $reference ?? Clock::get()->now(); if ('now' !== $datetime) { if (!$now instanceof static) { $now = static::c
{ "filepath": "src/Symfony/Component/Clock/DatePoint.php", "language": "php", "file_size": 3865, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; /** * A clock that always returns the same date, suitable for testing time-sensitive logic. * ...
able|string $now = 'now', \DateTimeZone|string|null $timezone = null) { if (\is_string($timezone)) { $timezone = new \DateTimeZone($timezone); } if (\is_string($now)) { $now = new DatePoint($now, $timezo
private DatePoint $now; /** * @throws \DateMalformedStringException When $now is invalid * @throws \DateInvalidTimeZoneException When $timezone is invalid */ public function __construct(\DateTimeImmut
{ "filepath": "src/Symfony/Component/Clock/MockClock.php", "language": "php", "file_size": 2393, "cut_index": 563, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; /** * A monotonic clock suitable for performance profiling. * * @author Nicolas Grekas <p@tchw...
returned false: the runtime environment does not provide access to a monotonic timer.'); } $time = explode(' ', microtime(), 2); $this->sOffset = $time[1] - $offset[0]; $this->usOffset = (int) ($time[0] * 1000000) - (int)
idTimeZoneException When $timezone is invalid */ public function __construct(\DateTimeZone|string|null $timezone = null) { if (false === $offset = hrtime()) { throw new \RuntimeException('hrtime()
{ "filepath": "src/Symfony/Component/Clock/MonotonicClock.php", "language": "php", "file_size": 2383, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock; /** * A clock that relies the system time. * * @author Nicolas Greka...
} public function now(): DatePoint { return DatePoint::createFromInterface(new \DateTimeImmutable('now', $this->timezone)); } public function sleep(float|int $seconds): void { if (0 < $s = (int) $seconds) {
*/ public function __construct(\DateTimeZone|string|null $timezone = null) { $this->timezone = \is_string($timezone ??= date_default_timezone_get()) ? $this->withTimeZone($timezone)->timezone : $timezone;
{ "filepath": "src/Symfony/Component/Clock/NativeClock.php", "language": "php", "file_size": 1508, "cut_index": 537, "middle_length": 229 }
hp /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\TestCase; use Symfony...
w()->getTimestamp(); $this->assertEquals($clock->now(), $sut->now()); $clock->sleep(1); $this->assertEquals($clock->now(), $sut->now()); $this->assertSame(1.0, round($sut->now()->getTimestamp() - $ts, 1)); } } class Clo
{ $sut = new ClockAwareTestImplem(); $this->assertInstanceOf(DatePoint::class, $sut->now()); $clock = new MockClock(); $sut = new $sut(); $sut->setClock($clock); $ts = $sut->no
{ "filepath": "src/Symfony/Component/Clock/Tests/ClockAwareTraitTest.php", "language": "php", "file_size": 1077, "cut_index": 515, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\TestCase; use Psr\Clock\ClockInterface; use...
ction tearDownAfterClass(): void { self::$clock = null; } public function testMockClock() { $this->assertInstanceOf(MockClock::class, self::$clock); $this->assertInstanceOf(NativeClock::class, Clock::get());
t extends TestCase { use ClockSensitiveTrait; private static ?ClockInterface $clock = null; public static function setUpBeforeClass(): void { self::$clock = self::mockTime(); } public static fun
{ "filepath": "src/Symfony/Component/Clock/Tests/ClockBeforeClassTest.php", "language": "php", "file_size": 1639, "cut_index": 537, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\TestCase; use Psr\Clock\ClockInterface; use Symfony\Component\Clock\C...
mockTime(); $this->assertInstanceOf(MockClock::class, Clock::get()); $this->assertSame(Clock::get(), $clock); } public function testNativeClock() { $this->assertInstanceOf(DatePoint::class, now()); $this->assert
Symfony\Component\Clock\now; class ClockTest extends TestCase { use ClockSensitiveTrait; public function testMockClock() { $this->assertInstanceOf(NativeClock::class, Clock::get()); $clock = self::
{ "filepath": "src/Symfony/Component/Clock/Tests/ClockTest.php", "language": "php", "file_size": 2910, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Componen...
his->assertSame('2010-01-29 16:00:00 Europe/Paris', $date->format('Y-m-d H:i:s e')); $date = new DatePoint('2022-01-28 15:00:00 Europe/Paris'); $this->assertSame('2022-01-28 15:00:00 Europe/Paris', $date->format('Y-m-d H:i:s e')); }
self::mockTime('2010-01-28 15:00:00 UTC'); $date = new DatePoint(); $this->assertSame('2010-01-28 15:00:00 UTC', $date->format('Y-m-d H:i:s e')); $date = new DatePoint('+1 day Europe/Paris'); $t
{ "filepath": "src/Symfony/Component/Clock/Tests/DatePointTest.php", "language": "php", "file_size": 5029, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\MockClock; class MockClockTest ext...
()); $clock = new MockClock('now', new \DateTimeZone($tz)); $this->assertSame($tz, $clock->now()->getTimezone()->getName()); $now = new \DateTimeImmutable(); $clock = new MockClock($now); $this->assertEquals($now,
ris'; $clock = new MockClock($tz); $this->assertSame($tz, $clock->now()->getTimezone()->getName()); $clock = new MockClock('now', $tz); $this->assertSame($tz, $clock->now()->getTimezone()->getName
{ "filepath": "src/Symfony/Component/Clock/Tests/MockClockTest.php", "language": "php", "file_size": 4164, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use Symfony\Compone...
$clock = new MonotonicClock(new \DateTimeZone($tz)); $this->assertSame($tz, $clock->now()->getTimezone()->getName()); } public function testNow() { $clock = new MonotonicClock(); $before = microtime(true); usl
this->assertSame('UTC', $clock->now()->getTimezone()->getName()); $tz = date_default_timezone_get(); $clock = new MonotonicClock(); $this->assertSame($tz, $clock->now()->getTimezone()->getName());
{ "filepath": "src/Symfony/Component/Clock/Tests/MonotonicClockTest.php", "language": "php", "file_size": 2106, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\Clock\Nativ...
$this->assertSame($tz, $clock->now()->getTimezone()->getName()); } public function testNow() { $clock = new NativeClock(); $before = new \DateTimeImmutable(); usleep(10); $now = $clock->now(); usl
()->getName()); $tz = date_default_timezone_get(); $clock = new NativeClock(); $this->assertSame($tz, $clock->now()->getTimezone()->getName()); $clock = new NativeClock(new \DateTimeZone($tz));
{ "filepath": "src/Symfony/Component/Clock/Tests/NativeClockTest.php", "language": "php", "file_size": 1930, "cut_index": 537, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Clock\Test; use PHPUnit\Framework\Attributes\After; use PHPUnit\Framework\Attr...
kTime() accepts either a string (eg '+1 days' or '2022-12-22'), * a DateTimeImmutable, or a boolean (to freeze/restore the global clock). * * @author Nicolas Grekas <p@tchwork.com> */ trait ClockSensitiveTrait { public static function mockTime(stri
Symfony\Component\Clock\now; /** * Helps with mocking the time in your test cases. * * This trait provides one self::mockTime() method that freezes the time. * It restores the global clock after each test case. * self::moc
{ "filepath": "src/Symfony/Component/Clock/Test/ClockSensitiveTrait.php", "language": "php", "file_size": 2004, "cut_index": 537, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient; use Amp\CancelledException; use Amp\Http\Client\DelegateHttpClient; use Amp\Http\Client\InterceptedHttpClient; use Amp\Http\Client\PooledHttpClient; use Amp\Http\Client\Request; use Amp\Http\Tunnel\Http1TunnelConnector; use Psr\Log\LoggerAwareIn...
treamInterface; use Symfony\Contracts\Service\ResetInterface; if (!interface_exists(DelegateHttpClient::class)) { throw new \LogicException('You cannot use "Symfony\Component\HttpClient\AmpHttpClient" as the "amphp/http-client" package is not installe
\Response\AmpResponse; use Symfony\Component\HttpClient\Response\ResponseStream; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseS
{ "filepath": "src/Symfony/Component/HttpClient/AmpHttpClient.php", "language": "php", "file_size": 6919, "cut_index": 716, "middle_length": 229 }
/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient; use Symfony\Component\HttpClient\Response\Async...
st(string $method, string $url, array $options = []): ResponseInterface; public function stream(ResponseInterface|iterable $responses, ?float $timeout = null): ResponseStreamInterface { if ($responses instanceof AsyncResponse) {
with processing responses while streaming them. * * @author Nicolas Grekas <p@tchwork.com> */ trait AsyncDecoratorTrait { use DecoratorTrait; /** * @return AsyncResponse */ abstract public function reque
{ "filepath": "src/Symfony/Component/HttpClient/AsyncDecoratorTrait.php", "language": "php", "file_size": 1146, "cut_index": 518, "middle_length": 229 }
111 */ class CachingHttpClient implements HttpClientInterface, LoggerAwareInterface, ResetInterface { use AsyncDecoratorTrait { stream as asyncStream; AsyncDecoratorTrait::withOptions insteadof HttpClientTrait; } use HttpClientTrait; /** * The status codes that are cacheable by de...
influence the response and may affect caching behavior. */ private const RESPONSE_INFLUENCING_HEADERS = [ 'accept' => true, 'accept-charset' => true, 'accept-encoding' => true, 'accept-language' => true, 'a
private const CACHEABLE_METHODS = ['GET', 'HEAD']; /** * The HTTP methods that are considered safe per RFC 9110. */ private const SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS', 'TRACE']; /** * Headers that
{ "filepath": "src/Symfony/Component/HttpClient/CachingHttpClient.php", "language": "php", "file_size": 45885, "cut_index": 2151, "middle_length": 229 }
ony\Contracts\HttpClient\ResponseStreamInterface; use Symfony\Contracts\Service\ResetInterface; /** * A performant implementation of the HttpClientInterface contracts based on the curl extension. * * This provides fully concurrent HTTP requests, with transparent * HTTP/2 push when a curl version that supports it i...
ng - an array containing the username as first value, and optionally the // password as the second one; or string like username:password - enabling NTLM auth 'auth_ntlm' => null, 'extra' => [ 'use_persistent_connections
blic const OPTIONS_DEFAULTS = HttpClientInterface::OPTIONS_DEFAULTS + [ 'crypto_method' => \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, ]; private array $defaultOptions = self::OPTIONS_DEFAULTS + [ // array|stri
{ "filepath": "src/Symfony/Component/HttpClient/CurlHttpClient.php", "language": "php", "file_size": 25824, "cut_index": 1331, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient; use Symfony\Contracts\HttpClient\HttpClientInterface;...
ttpClient::create(); } public function request(string $method, string $url, array $options = []): ResponseInterface { return $this->client->request($method, $url, $options); } public function stream(ResponseInterface|iterable
rs. * * @author Nicolas Grekas <p@tchwork.com> */ trait DecoratorTrait { private HttpClientInterface $client; public function __construct(?HttpClientInterface $client = null) { $this->client = $client ?? H
{ "filepath": "src/Symfony/Component/HttpClient/DecoratorTrait.php", "language": "php", "file_size": 1478, "cut_index": 524, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient; use Symfony\Component\HttpClient\Internal\FollowRedirectsTrait; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\Htt...
ts own DNS resolution. When it returns null, the transport's default * DNS resolution is used. Hosts that are already in the "resolve" option or that are IP addresses are * not passed to it. * * Note that using this decorator opts out of the asynchrono
er is called for the requested host and for the host of every followed redirect. When it * returns an IP address, the result is injected into the "resolve" option so that the transport connects * to that IP without performing i
{ "filepath": "src/Symfony/Component/HttpClient/DnsResolvingHttpClient.php", "language": "php", "file_size": 3377, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient; use Symfony\Component\HttpClient\Chunk\DataChunk; use Symfony\Component\HttpClient\Chunk\ServerSentEvent; use Symfony\Component\HttpClient\Exception\EventSourceException; use Symfony\Component\HttpClient\Response\AsyncContext; use Symfony\Compon...
EventSourceHttpClient implements HttpClientInterface, ResetInterface { use AsyncDecoratorTrait, HttpClientTrait { AsyncDecoratorTrait::withOptions insteadof HttpClientTrait; } public function __construct( ?HttpClientInterface $
\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\Service\ResetInterface; /** * @author Antoine Bluchet <soyuka@gmail.com> * @author Nicolas Grekas <p@tchwork.com> */ final class
{ "filepath": "src/Symfony/Component/HttpClient/EventSourceHttpClient.php", "language": "php", "file_size": 5935, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\RequiresPhp; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\...
\Fixtures\WhenTestWithAttributes; use Symfony\Component\Validator\Tests\Constraints\Fixtures\WhenTestWithClosure; final class WhenTest extends TestCase { public function testMissingConstraints() { $this->expectException(MissingOptionsExcep
mfony\Component\Validator\Exception\MissingOptionsException; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; use Symfony\Component\Validator\Tests\Constraints
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WhenTest.php", "language": "php", "file_size": 6230, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use Symfony\Component\Validator\Constraints\Blank; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NegativeOrZero; use Symfony...
s ConstraintValidatorTestCase { public function testConstraintsAreExecuted() { $constraints = [ new NotNull(), new NotBlank(), ]; $this->expectValidateValue(0, 'Foo', $constraints); $this->v
traints\When; use Symfony\Component\Validator\Constraints\WhenValidator; use Symfony\Component\Validator\ConstraintViolation; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; final class WhenValidatorTest extend
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WhenValidatorTest.php", "language": "php", "file_size": 8325, "cut_index": 716, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Component\Va...
nction createValidator(): WordCountValidator { return new WordCountValidator(); } #[DataProvider('provideValidValues')] public function testValidWordCount(string|\Stringable|null $value, int $expectedWordCount) { $this-
or\Test\ConstraintValidatorTestCase; use Symfony\Component\Validator\Tests\Constraints\Fixtures\StringableValue; #[RequiresPhpExtension('intl')] class WordCountValidatorTest extends ConstraintValidatorTestCase { protected fu
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WordCountValidatorTest.php", "language": "php", "file_size": 3148, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Symfony\Component\Validator\Constraints\Xml; use Symfony\Component\Validator\Constraints\XmlValidator; use Symfony\Compone...
teValidator(): XmlValidator { return new XmlValidator(); } #[DataProvider('getValidXmlFormatValues')] public function testValidXmlFormatValue($value) { $this->validate($value, new Xml()); $this->assertNoViolatio
Symfony\Component\Validator\Tests\Constraints\Fixtures\StringableValue; #[RequiresPhpExtension('simplexml')] #[RequiresPhpExtension('dom')] class XmlValidatorTest extends ConstraintValidatorTestCase { protected function crea
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/XmlValidatorTest.php", "language": "php", "file_size": 5274, "cut_index": 716, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\TestCase; use Symfony\Compo...
oader(); self::assertTrue($loader->loadClassMetadata($metadata)); [$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstraints(); self::assertSame('myMessage', $bConstraint->message); self::assertSame(['Default',
arser; /** * @author Kev <https://github.com/symfonyaml> */ class YamlTest extends TestCase { public function testAttributes() { $metadata = new ClassMetadata(YamlDummy::class); $loader = new AttributeL
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/YamlTest.php", "language": "php", "file_size": 1754, "cut_index": 537, "middle_length": 229 }
* This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints\Fixtures; use Symfony\Component\Val...
static function () { return true; }, constraints: new Callback('isValid') )] class WhenTestWithClosure { #[When(expression: static function () { return true; }, constraints: [ new NotNull(), new NotBlank(), ]
n(expression:
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/Fixtures/WhenTestWithClosure.php", "language": "php", "file_size": 815, "cut_index": 522, "middle_length": 14 }
ts\Cascade; use Symfony\Component\Validator\Constraints\Composite; use Symfony\Component\Validator\Constraints\GroupSequence; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\Exception\GroupDefinitionException; us...
s\Fixtures\ConstraintA; use Symfony\Component\Validator\Tests\Fixtures\ConstraintB; use Symfony\Component\Validator\Tests\Fixtures\GroupSequenceProviderChildEntity; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity; use Symfony\Componen
onent\Validator\Tests\Fixtures\CascadingEntityIntersection; use Symfony\Component\Validator\Tests\Fixtures\CascadingEntityUnion; use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint; use Symfony\Component\Validator\Test
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/ClassMetadataTest.php", "language": "php", "file_size": 14560, "cut_index": 921, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapp...
LASSNAME = Entity::class; private const CLASSNAME_74 = 'Symfony\Component\Validator\Tests\Fixtures\Entity_74'; private const CLASSNAME_74_PROXY = 'Symfony\Component\Validator\Tests\Fixtures\Entity_74_Proxy'; private const PARENTCLASS = EntityPa
ntityWithHook; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\EntityParent; class PropertyMetadataTest extends TestCase { private const C
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/PropertyMetadataTest.php", "language": "php", "file_size": 4148, "cut_index": 614, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use PHPUnit\Framework\TestCase; use Symfony\Co...
$loader = $this->getFilesLoader(new StaticMethodLoader()); $this->assertEquals(4, $loader->getTimesCalled()); } public function testCallsActualFileLoaderForMetadata() { $fileLoader = $this->createMock(LoaderInterface::class);
t\Validator\Tests\Fixtures\FilesLoader; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity; class FilesLoaderTest extends TestCase { public function testCallsGetFileLoaderInstanceForeachPath() {
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/FilesLoaderTest.php", "language": "php", "file_size": 1606, "cut_index": 537, "middle_length": 229 }
nfo\PropertyAccessExtractorInterface; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; use Symfony\Component\PropertyInfo\Type as LegacyType; use Symfony\Component\TypeInfo\Type; use Symfony\Component\Validator\Constraints\All; use Sym...
t\Validator\Mapping\PropertyMetadata; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity; use Symfony\Component\Validator\Tests\Fixtures\PropertyInfoLoaderEntity; use Symfony\Component\Validator\Tests\Fixtures\PropertyInfoLoaderNoAutoMap
s\Type as TypeConstraint; use Symfony\Component\Validator\Mapping\AutoMappingStrategy; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader; use Symfony\Componen
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/PropertyInfoLoaderTest.php", "language": "php", "file_size": 14402, "cut_index": 921, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapp...
cessful() { $loader = new StaticMethodLoader('loadMetadata'); $metadata = new ClassMetadata(StaticLoaderEntity::class); $this->assertTrue($loader->loadClassMetadata($metadata)); } public function testLoadClassMetadataR
setUp(): void { $this->errorLevel = error_reporting(); } protected function tearDown(): void { error_reporting($this->errorLevel); } public function testLoadClassMetadataReturnsTrueIfSuc
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/StaticMethodLoaderTest.php", "language": "php", "file_size": 3964, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints...
ts\Required; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; use Symfony\Component\Validator\Tests\Dummy\DummyGroupProvider; use Symfony\Component\Validator\Tests\Fixtures\Attribute\Grou
lidator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constrain
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php", "language": "php", "file_size": 7661, "cut_index": 716, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Factory; use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\NotBla...
tor\Tests\Fixtures\NestedAttribute\Entity; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\EntityParent; use Symfony\Component\Validator\Tests\Fixtures\PropertyGetter; use Symfony\Component\Validator\Tests\Fixtures\PropertyGetterInterface;
aFactory; use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Valida
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Factory/LazyLoadingMetadataFactoryTest.php", "language": "php", "file_size": 6626, "cut_index": 716, "middle_length": 229 }
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Contracts\Service\ServiceLocatorTrait; class RecursiveValidatorTest extends TestCase { private const ENTITY_CLASS = Entity::class; private const REFERENCE_CLASS = Reference::class; private FakeMetadataFactory $metadataFactory; ...
tadata); $this->metadataFactory->addMetadata($this->referenceMetadata); $this->metadataFactory->addMetadata(new ClassMetadata(LazyProperty::class)); $this->validator = $this->createValidator($this->metadataFactory); } prot
tory = new FakeMetadataFactory(); $this->metadata = new ClassMetadata(self::ENTITY_CLASS); $this->referenceMetadata = new ClassMetadata(self::REFERENCE_CLASS); $this->metadataFactory->addMetadata($this->me
{ "filepath": "src/Symfony/Component/Validator/Tests/Validator/RecursiveValidatorTest.php", "language": "php", "file_size": 97617, "cut_index": 3790, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Validator; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\ConstraintV...
tends TestCase { public function testValidate() { $originalValidator = $this->createMock(ValidatorInterface::class); $violations = new ConstraintViolationList([ $this->createStub(ConstraintViolation::class),
use Symfony\Component\Validator\Validator\ContextualValidatorInterface; use Symfony\Component\Validator\Validator\TraceableValidator; use Symfony\Component\Validator\Validator\ValidatorInterface; class TraceableValidatorTest ex
{ "filepath": "src/Symfony/Component/Validator/Tests/Validator/TraceableValidatorTest.php", "language": "php", "file_size": 4255, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Validator\Constraints\Week; use Symfony\Component\Validat...
vider('provideWeekNumber')] public function testWeekIsValidWeekNumber(string|\Stringable $value, bool $expectedViolation) { $constraint = new Week(); $this->validate($value, $constraint); if ($expectedViolation) {
tor\Tests\Constraints\Fixtures\StringableValue; class WeekValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): WeekValidator { return new WeekValidator(); } #[DataPro
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WeekValidatorTest.php", "language": "php", "file_size": 4142, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constra...
ount(min: 1, locale: 'en'); $this->assertSame('en', $wordCount->locale); } public function testOnlyMinIsSet() { $wordCount = new WordCount(1); $this->assertSame(1, $wordCount->min); $this->assertNull($wordCoun
ing\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; #[RequiresPhpExtension('intl')] class WordCountTest extends TestCase { public function testLocaleIsSet() { $wordCount = new WordC
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WordCountTest.php", "language": "php", "file_size": 4666, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Validator\Constraints\Yaml; use Symfony\Component\Validat...
on testYamlIsValid($value) { $this->validate($value, new Yaml()); $this->assertNoViolation(); } public function testYamlWithFlags() { $this->validate('date: 2023-01-01', new Yaml(flags: YamlParser::PARSE_DATETIME))
l> */ class YamlValidatorTest extends ConstraintValidatorTestCase { protected function createValidator(): YamlValidator { return new YamlValidator(); } #[DataProvider('getValidValues')] public functi
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/YamlValidatorTest.php", "language": "php", "file_size": 4407, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Exception\Valid...
ction testGetPropertyValueFromPublicGetter() { $entity = new Entity('foobar'); $metadata = new GetterMetadata(self::CLASSNAME, 'internal'); $this->assertEquals('foobar from getter', $metadata->getPropertyValue($entity)); }
rivate const CLASSNAME = Entity::class; public function testInvalidPropertyName() { $this->expectException(ValidatorException::class); new GetterMetadata(self::CLASSNAME, 'foobar'); } public fun
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/GetterMetadataTest.php", "language": "php", "file_size": 2187, "cut_index": 563, "middle_length": 229 }
mponent\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\AtLeastOneOf; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraints\Email; use Symfony\Co...
Symfony\Component\Validator\Constraints\Type; use Symfony\Component\Validator\Constraints\Valid; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; use Symfony\Component\Validator\Tests\D
NotNull; use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Required; use Symfony\Component\Validator\Constraints\Sequentially; use
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/AttributeLoaderTest.php", "language": "php", "file_size": 13748, "cut_index": 921, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\All; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\Choice; use Symfony\Component\Validator\Constr...
raints\Required; use Symfony\Component\Validator\Constraints\Traverse; use Symfony\Component\Validator\Exception\MappingException; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; use Symf
nent\Validator\Constraints\NotNull; use Symfony\Component\Validator\Constraints\Optional; use Symfony\Component\Validator\Constraints\Range; use Symfony\Component\Validator\Constraints\Regex; use Symfony\Component\Validator\Const
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php", "language": "php", "file_size": 7303, "cut_index": 716, "middle_length": 229 }
file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Factory; use PHPUnit\Framework\TestCase; use S...
{ $this->expectException(LogicException::class); (new BlackHoleMetadataFactory())->getMetadataFor('foo'); } public function testHasMetadataForReturnsFalse() { $this->assertFalse((new BlackHoleMetadataFactory())->has
function testGetMetadataForThrowsALogicException()
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Factory/BlackHoleMetadataFactoryTest.php", "language": "php", "file_size": 866, "cut_index": 529, "middle_length": 52 }
new LazyLoadingMetadataFactory(new AttributeLoader())); $tester = new CommandTester($command); $tester->execute(['class' => DummyClassOne::class], ['decorated' => false]); $this->assertSame(<<<TXT Symfony\Component\Validator\Tests\Dummy\DummyClassOne ------------------...
-----------------------------------+------------------------+------------------------------------------------------------+ | - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassOne | [
------------+ | Property | Name | Groups | Options | +---------------+-----------------
{ "filepath": "src/Symfony/Component/Validator/Tests/Command/DebugCommandTest.php", "language": "php", "file_size": 21651, "cut_index": 1331, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\RunTestsInSepara...
atic function setUpBeforeClass(): void { ClassExistsMock::register(When::class); ClassExistsMock::withMockedClasses([ ExpressionLanguage::class => false, ]); } public static function tearDownAfterClass(): vo
s\NotNull; use Symfony\Component\Validator\Constraints\When; use Symfony\Component\Validator\Exception\LogicException; #[RunTestsInSeparateProcesses] final class WhenWithoutExpressionLanguageTest extends TestCase { public st
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/WhenWithoutExpressionLanguageTest.php", "language": "php", "file_size": 1699, "cut_index": 537, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constra...
$metadata = new ClassMetadata(XmlDummy::class); $loader = new AttributeLoader(); self::assertTrue($loader->loadClassMetadata($metadata)); [$bConstraint] = $metadata->getPropertyMetadata('b')[0]->getConstraints(); self::as
lassMetadata; use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; #[RequiresPhpExtension('simplexml')] #[RequiresPhpExtension('dom')] class XmlTest extends TestCase { public function testAttributes() {
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/XmlTest.php", "language": "php", "file_size": 3103, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Mapping\...
etadata') ->with($this->equalTo($metadata)); $loader2 = $this->createMock(LoaderInterface::class); $loader2->expects($this->once()) ->method('loadClassMetadata') ->with($this->equalTo($metadata));
function testAllLoadersAreCalled() { $metadata = new ClassMetadata('\stdClass'); $loader1 = $this->createMock(LoaderInterface::class); $loader1->expects($this->once()) ->method('loadClassM
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/Loader/LoaderChainTest.php", "language": "php", "file_size": 2377, "cut_index": 563, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Resources; use PHPUnit\Framework\Attributes\DataProvider; use ...
0, $errors, \sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message')))); } #[DataProvider('provideTranslationFiles')] public function testTranslationFileIsValidWithoutEntityLoader($filePath) {
testTranslationFileIsValid($filePath) { $document = new \DOMDocument(); $document->loadXML(file_get_contents($filePath)); $errors = XliffUtils::validateSchema($document); $this->assertCount(
{ "filepath": "src/Symfony/Component/Validator/Tests/Resources/TranslationFilesTest.php", "language": "php", "file_size": 1908, "cut_index": 537, "middle_length": 229 }
This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Constraints\Fixtures; use Symfony\Component\Valid...
new NotBlank(), ])] private $foo; #[When(expression: 'false', constraints: [ new NotNull(), new NotBlank(), ], groups: ['foo'])] private $bar; #[When(expression: 'true', constraints: new NotNull(), groups: ['foo'])
mfony\Component\Validator\Constraints\When; #[When(expression: 'true', constraints: [ new Callback('callback'), ])] class WhenTestWithAttributes { #[When(expression: 'true', constraints: [ new NotNull(),
{ "filepath": "src/Symfony/Component/Validator/Tests/Constraints/Fixtures/WhenTestWithAttributes.php", "language": "php", "file_size": 1372, "cut_index": 524, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Violation; use PHPUnit\Framework\TestCase; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Validator\Constraint...
is invalid'; private ConstraintViolationBuilder $builder; protected function setUp(): void { $this->root = [ 'data' => [ 'foo' => 'bar', 'baz' => 'foobar', ], ];
Symfony\Contracts\Translation\TranslatorInterface; class ConstraintViolationBuilderTest extends TestCase { private array $root; private ConstraintViolationList $violations; private string $messageTemplate = '%value%
{ "filepath": "src/Symfony/Component/Validator/Tests/Violation/ConstraintViolationBuilderTest.php", "language": "php", "file_size": 4478, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Test; use PHPUnit\Framework\ExpectationFailedException; use Symfony\Component\Validator\...
Test extends CompoundConstraintTestCase { protected function createCompound(): Compound { return new DummyCompoundConstraint(); } public function testAssertNoViolation() { $this->validateValue('ab1'); $this->as
omponent\Validator\Test\CompoundConstraintTestCase; use Symfony\Component\Validator\Tests\Fixtures\DummyCompoundConstraint; /** * @extends CompoundConstraintTestCase<DummyCompoundConstraint> */ class CompoundConstraintTestCase
{ "filepath": "src/Symfony/Component/Validator/Tests/Test/CompoundConstraintTestCaseTest.php", "language": "php", "file_size": 2927, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Tests\Mapping; use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraints\Collection; use Symfony\Component\Validator\Constraint...
straintB; use Symfony\Component\Validator\Tests\Fixtures\NestedAttribute\Entity; use Symfony\Component\Validator\Tests\Fixtures\PropertyConstraint; class MemberMetadataTest extends TestCase { protected MemberMetadata $metadata; protected function
se Symfony\Component\Validator\Mapping\MemberMetadata; use Symfony\Component\Validator\Tests\Fixtures\ClassConstraint; use Symfony\Component\Validator\Tests\Fixtures\ConstraintA; use Symfony\Component\Validator\Tests\Fixtures\Con
{ "filepath": "src/Symfony/Component/Validator/Tests/Mapping/MemberMetadataTest.php", "language": "php", "file_size": 4230, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Exception; use Symfony\Contracts\HttpClient\ResponseInterface; /** * @author Nicolas Grekas...
'response_headers')) as $h) { if (str_starts_with($h, 'HTTP/')) { if ($httpCodeFound) { break; } $message = \sprintf('%s returned for "%s".', $h, $url); $httpC
ode'); $url = $response->getInfo('url'); $message = \sprintf('HTTP %d returned for "%s".', $code, $url); $httpCodeFound = false; $isJson = false; foreach (array_reverse($response->getInfo(
{ "filepath": "src/Symfony/Component/HttpClient/Exception/HttpExceptionTrait.php", "language": "php", "file_size": 2690, "cut_index": 563, "middle_length": 229 }
e Symfony\Component\HttpClient\Chunk\DataChunk; use Symfony\Component\HttpClient\Chunk\ErrorChunk; use Symfony\Component\HttpClient\Chunk\FirstChunk; use Symfony\Component\HttpClient\Chunk\LastChunk; use Symfony\Component\HttpClient\Chunk\ServerSentEvent; use Symfony\Component\HttpClient\EventSourceHttpClient; use Symf...
\r"])] #[TestWith(["\r\n"])] public function testGetServerSentEvents(string $sep) { $es = new EventSourceHttpClient(new MockHttpClient(function (string $method, string $url, array $options) use ($sep): MockResponse { $this->
nt\Response\ResponseStream; use Symfony\Contracts\HttpClient\HttpClientInterface; /** * @author Antoine Bluchet <soyuka@gmail.com> */ class EventSourceHttpClientTest extends TestCase { #[TestWith(["\n"])] #[TestWith(["
{ "filepath": "src/Symfony/Component/HttpClient/Tests/EventSourceHttpClientTest.php", "language": "php", "file_size": 9249, "cut_index": 921, "middle_length": 229 }
akeHandler(); $handler(new Request('GET', 'https://example.com/', ['X-Custom-Header' => 'my-value']), [])->wait(); // MockHttpClient normalises headers into normalized_headers as "Name: value" strings. $this->assertContains('X-Custom-Header: my-value', $spy->options['normalized_headers']['x-cu...
]['x-from-request'] ?? []); $this->assertContains('X-From-Options: opt', $spy->options['normalized_headers']['x-from-options'] ?? []); } public function testBodyIsForwarded() { [$handler, $spy] = $this->makeHandler();
uest('GET', 'https://example.com/', ['X-From-Request' => 'req']), ['headers' => ['X-From-Options' => 'opt']], )->wait(); $this->assertContains('X-From-Request: req', $spy->options['normalized_headers'
{ "filepath": "src/Symfony/Component/HttpClient/Tests/GuzzleHttpHandlerTest.php", "language": "php", "file_size": 34837, "cut_index": 2151, "middle_length": 229 }
ttpClient; use Symfony\Component\Process\Exception\ProcessFailedException; use Symfony\Component\Process\Process; use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\Test\HttpClientTestCase as BaseHttpClientTest...
/vulcain_0.1.3_Linux_x86_64.tar.gz - see https://github.com/dunglas/vulcain for source */ abstract class HttpClientTestCase extends BaseHttpClientTestCase { private static bool $vulcainStarted = false; public function testTimeoutOnDestruct()
wd):/app -v /path/to/vulcain:/usr/local/bin/vulcain -w /app php:7.3-alpine ./phpunit src/Symfony/Component/HttpClient --filter Push The vulcain binary can be found at https://github.com/symfony/binary-utils/releases/download/v0.1
{ "filepath": "src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php", "language": "php", "file_size": 27710, "cut_index": 1331, "middle_length": 229 }
iresPhpExtension; use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpClient\HttpClientTrait; use Symfony\Contracts\HttpClient\HttpClientInterface; class Ht...
self::prepareRequest(null, null, $defaults); [$url] = self::prepareRequest(null, $url, ['query' => $query], $defaults); $this->assertSame($expected, implode('', $url)); } public static function providePrepareRequestUrl(): iterable
repareRequestUrl(string $expected, string $url, array $query = []) { $defaults = [ 'base_uri' => 'http://example.com?c=c', 'query' => ['a' => 1, 'b' => 'b'], ]; [, $defaults] =
{ "filepath": "src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php", "language": "php", "file_size": 17181, "cut_index": 921, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\F...
der('provideSetAuthBasic')] public function testSetAuthBasic(string $expected, string $user, string $password = '') { $this->assertSame($expected, (new HttpOptions())->setAuthBasic($user, $password)->toArray()['auth_basic']); } pub
deSetAuthBasic(): iterable { yield ['user:password', 'user', 'password']; yield ['user:password', 'user:password']; yield ['user', 'user']; yield ['user:0', 'user', '0']; } #[DataProvi
{ "filepath": "src/Symfony/Component/HttpClient/Tests/HttpOptionsTest.php", "language": "php", "file_size": 1984, "cut_index": 537, "middle_length": 229 }
nt\Exception\RequestException; use Http\Promise\FulfilledPromise; use Http\Promise\Promise; use PHPUnit\Framework\Attributes\RequiresFunction; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpClient\HttplugCl...
tSendRequest() { $client = new HttplugClient(new NativeHttpClient()); $response = $client->sendRequest($client->createRequest('GET', 'http://localhost:8057')); $this->assertSame(200, $response->getStatusCode()); $this-
nt\Test\TestHttpServer; class HttplugClientTest extends TestCase { public static function setUpBeforeClass(): void { TestHttpServer::start(); } #[RequiresFunction('ob_gzhandler')] public function tes
{ "filepath": "src/Symfony/Component/HttpClient/Tests/HttplugClientTest.php", "language": "php", "file_size": 12929, "cut_index": 921, "middle_length": 229 }
nseStream; use Symfony\Contracts\HttpClient\ChunkInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; class MockHttpClientTest extends HttpClientTestCase { #[DataProvider('mockingProvider')] public function testMocking($factory, array $expectedResponses) { $client = new MockHttpClient($...
der(): iterable { yield 'callable' => [ static fn (string $method, string $url, array $options = []) => new MockResponse($method.': '.$url.' (body='.$options['body'].')'), [ 'POST: https://example.com/foo
$url, ['body' => 'payload']); $this->assertEquals($expectedResponses[$i], $response->getContent()); } $this->assertSame(2, $client->getRequestsCount()); } public static function mockingProvi
{ "filepath": "src/Symfony/Component/HttpClient/Tests/MockHttpClientTest.php", "language": "php", "file_size": 22599, "cut_index": 1331, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\Attributes\Group; use Symfony\Bridge\PhpUnit\DnsMock; use Symfon...
$this->markTestSkipped('NativeHttpClient doesn\'t support informational status codes.'); } public function testTimeoutOnInitialize() { $this->markTestSkipped('NativeHttpClient doesn\'t support opening concurrent requests.');
ClientTest extends HttpClientTestCase { protected function getHttpClient(string $testCase): HttpClientInterface { return new NativeHttpClient(); } public function testInformationalResponseStream() {
{ "filepath": "src/Symfony/Component/HttpClient/Tests/NativeHttpClientTest.php", "language": "php", "file_size": 2159, "cut_index": 563, "middle_length": 229 }
ymfony\Bridge\PhpUnit\DnsMock; use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\NoPrivateNetworkHttpClient; use Symfony\Component\HttpClient\Response\MockR...
['172.16.0.1', null, true], ['192.168.0.1', null, true], ['::1', null, true], ['::ffff:0:1', null, true], ['fe80::1', null, true],
null, true], ['169.254.0.1', null, true], ['127.0.0.1', null, true], ['240.0.0.1', null, true], ['10.0.0.1', null, true],
{ "filepath": "src/Symfony/Component/HttpClient/Tests/NoPrivateNetworkHttpClientTest.php", "language": "php", "file_size": 10087, "cut_index": 921, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient\Tests; use Nyholm\Psr7\Factory\Psr17Factory; use PHPUnit\Framework\Attributes\RequiresFunction; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\NativeHttpClient; use Symfony\Compon...
ndler')] public function testSendRequest() { $factory = new Psr17Factory(); $client = new Psr18Client(new NativeHttpClient(), $factory, $factory); $response = $client->sendRequest($factory->createRequest('GET', 'http://loca
se; use Symfony\Contracts\HttpClient\Test\TestHttpServer; class Psr18ClientTest extends TestCase { public static function setUpBeforeClass(): void { TestHttpServer::start(); } #[RequiresFunction('ob_gzha
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Psr18ClientTest.php", "language": "php", "file_size": 5781, "cut_index": 716, "middle_length": 229 }
Symfony\Component\HttpClient\Retry\RetryStrategyInterface; use Symfony\Component\HttpClient\RetryableHttpClient; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpCli...
se = $client->request('GET', 'http://example.com/foo-bar'); self::assertSame(200, $response->getStatusCode()); } public function testRetryRespectStrategy() { $client = new RetryableHttpClient( new MockHttpClient([
t([ new MockResponse('', ['http_code' => 500]), new MockResponse('', ['http_code' => 200]), ]), new GenericRetryStrategy([500], 0), 1 ); $respon
{ "filepath": "src/Symfony/Component/HttpClient/Tests/RetryableHttpClientTest.php", "language": "php", "file_size": 20550, "cut_index": 1331, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\...
tException::class); $client->request('GET', '/foo'); } public function testRelativeUrlWithDefaultRegexp() { $mockClient = new MockHttpClient(); $client = new ScopingHttpClient($mockClient, ['.*' => ['base_uri' => 'http:
ingHttpClientTest extends TestCase { public function testRelativeUrl() { $mockClient = new MockHttpClient(); $client = new ScopingHttpClient($mockClient, []); $this->expectException(InvalidArgumen
{ "filepath": "src/Symfony/Component/HttpClient/Tests/ScopingHttpClientTest.php", "language": "php", "file_size": 5155, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use S...
andler should\'t have been called, but it was called with %f.', $duration)); }; $pauseHandler = static fn (float $expectedDuration) => static function (float $duration) use ($expectedDuration) { self::assertEqualsWithDelta($exp
r\Storage\InMemoryStorage; class ThrottlingHttpClientTest extends TestCase { public function testThrottling() { $failPauseHandler = static function (float $duration) { self::fail(\sprintf('The pause h
{ "filepath": "src/Symfony/Component/HttpClient/Tests/ThrottlingHttpClientTest.php", "language": "php", "file_size": 2290, "cut_index": 563, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\ClientException; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\NativeHttpClient; use Symfony\Component\HttpClient\Response\MockR...
); } public function testItTracesRequest() { $httpClient = $this->createStub(HttpClientInterface::class); $httpClient ->method('request') ->willReturnCallback(function (string $method, string $url, array
acts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\Test\TestHttpServer; class TraceableHttpClientTest extends TestCase { public static function setUpBeforeClass(): void { TestHttpServer::start(
{ "filepath": "src/Symfony/Component/HttpClient/Tests/TraceableHttpClientTest.php", "language": "php", "file_size": 8842, "cut_index": 716, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\HttpClient\Response\MockResponse; ...
([ 'version' => 'v2', 'resource' => 'users', 'page' => 33, ], $vars); return 'https://foo.tld/v2/users?page=33'; }, [ 'vers
lateHttpClient( new MockHttpClient(), function (string $url, array $vars): string { $this->assertSame('https://foo.tld/{version}/{resource}{?page}', $url); $this->assertSame
{ "filepath": "src/Symfony/Component/HttpClient/Tests/UriTemplateHttpClientTest.php", "language": "php", "file_size": 4123, "cut_index": 614, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Chunk; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Chunk\ServerSentEvent; use Symfony\Component\HttpClient\Exception\...
'12', $sse->getId()); $this->assertSame('testEvent', $sse->getType()); } public function testParseValid() { $rawData = <<<STR event: testEvent data STR; $sse = new ServerSentEvent($
ata: test data:test id: 12 event: testEvent STR; $sse = new ServerSentEvent($rawData); $this->assertSame("test\ntest", $sse->getData()); $this->assertSame(
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Chunk/ServerSentEventTest.php", "language": "php", "file_size": 3175, "cut_index": 614, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Exception; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCas...
An error occurred Some details ERROR; yield ['application/ld+json', '{"hydra:title": "An error occurred", "hydra:description": "Some details"}', $errorWithMessage]; yield ['application/problem+json', '{"title
raitTest extends TestCase { public static function provideParseError(): iterable { $errorWithoutMessage = 'HTTP/1.1 400 Bad Request returned for "http://example.com".'; $errorWithMessage = <<<ERROR
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Exception/HttpExceptionTraitTest.php", "language": "php", "file_size": 2219, "cut_index": 563, "middle_length": 229 }
rver; class HttpClientDataCollectorTest extends TestCase { public static function setUpBeforeClass(): void { TestHttpServer::start(); } public function testItCollectsRequestCount() { $httpClient1 = $this->httpClientThatHasTracedRequests([ [ 'method' => '...
his->httpClientThatHasTracedRequests([]); $sut = new HttpClientDataCollector(); $sut->registerClient('http_client1', $httpClient1); $sut->registerClient('http_client2', $httpClient2); $sut->registerClient('http_client3', $ht
]); $httpClient2 = $this->httpClientThatHasTracedRequests([ [ 'method' => 'GET', 'url' => 'http://localhost:8057/404', ], ]); $httpClient3 = $t
{ "filepath": "src/Symfony/Component/HttpClient/Tests/DataCollector/HttpClientDataCollectorTest.php", "language": "php", "file_size": 18376, "cut_index": 1331, "middle_length": 229 }
part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Internal; use PHPUnit\Framework\Attributes\RequiresPhpExtensi...
.1', 8057)); self::assertSame('https://example.com:443', CurlClientState::originKey('https', 'example.com', 443)); self::assertSame('http://example.com:80', CurlClientState::originKey('http', 'example.com', 80)); self::assertSame('h
testOriginKeyFormat() { self::assertSame('http://127.0.0.1:8057', CurlClientState::originKey('http', '127.0.0.1', 8057)); self::assertSame('http://127.0.0.1:8057', CurlClientState::originKey('http:', '127.0.0
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Internal/CurlClientStateTest.php", "language": "php", "file_size": 1715, "cut_index": 537, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\Transp...
"{$this->fixtureDir}/symfony.com_archive.har"); $client = new MockHttpClient($factory, 'https://symfony.com'); $response = $client->request('GET', '/releases.json'); $this->assertSame(200, $response->getStatusCode()); $bo
ring $fixtureDir; protected function setUp(): void { $this->fixtureDir = \dirname(__DIR__).'/Fixtures/har'; } public function testResponseGeneration() { $factory = new HarFileResponseFactory(
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Test/HarFileResponseFactoryTest.php", "language": "php", "file_size": 2806, "cut_index": 563, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Messenger; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\C...
$client = new MockHttpClient([ function ($method, $url) { $this->assertSame('POST', $method); $this->assertSame('https://endpoint.com/key', $url); return new MockResponse('a response');
ient; use Symfony\Component\HttpClient\Response\MockResponse; /** * @author Kevin Bond <kevinbond@gmail.com> */ final class PingWebhookMessageHandlerTest extends TestCase { public function testSuccessfulPing() {
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Messenger/PingWebhookMessageHandlerTest.php", "language": "php", "file_size": 2750, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Retry; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\Transport...
houldRetry(string $method, int $code, ?TransportExceptionInterface $exception) { $strategy = new GenericRetryStrategy(); self::assertTrue($strategy->shouldRetry($this->getContext(0, $method, 'http://example.com/', $code), null, $except
t\HttpClient\Retry\GenericRetryStrategy; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; class GenericRetryStrategyTest extends TestCase { #[DataProvider('provideRetryable')] public function testS
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Retry/GenericRetryStrategyTest.php", "language": "php", "file_size": 4295, "cut_index": 614, "middle_length": 229 }
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Response; use GuzzleHttp\Promise\Pro...
return new HttplugPromise($guzzlePromise); }; $promise1 = $mkPromise('result'); $promise2 = $promise1->then($mkPromise); $promise3 = $promise2->then(static fn ($result) => $result); $this->assertSame('result',
$mkPromise = static function ($result): HttplugPromise { $guzzlePromise = new Promise(static function () use (&$guzzlePromise, $result) { $guzzlePromise->resolve($result); });
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Response/HttplugPromiseTest.php", "language": "php", "file_size": 1025, "cut_index": 512, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\Response; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\Invali...
>assertSame('application/json', $response->getHeaders()['content-type'][0]); } public function testInvalidBody() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('JSON encoding failed: Ma
function testDefaults() { $client = new MockHttpClient(new JsonMockResponse()); $response = $client->request('GET', 'https://symfony.com'); $this->assertSame([], $response->toArray()); $this-
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Response/JsonMockResponseTest.php", "language": "php", "file_size": 4128, "cut_index": 614, "middle_length": 229 }
buted with this source code. */ namespace Symfony\Component\HttpClient\Tests\Response; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\Exception\JsonException; use Symfony\Component\Ht...
s->assertNotNull($response->getInfo('total_time')); $this->assertGreaterThan(0.0, $response->getInfo('total_time')); } public function testTotalTimeShouldNotBeSimulatedWhenProvided() { $totalTime = 4.2; $response = new
ublic function testTotalTimeShouldBeSimulatedWhenNotProvided() { $response = new MockResponse('body'); $response = MockResponse::fromRequest('GET', 'https://example.com/file.txt', [], $response); $thi
{ "filepath": "src/Symfony/Component/HttpClient/Tests/Response/MockResponseTest.php", "language": "php", "file_size": 5169, "cut_index": 716, "middle_length": 229 }
ge. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyIn...
) { $container = $this->buildContainerBuilder('http_client'); $sut = new HttpClientPass(); $sut->process($container); $this->assertFalse($container->hasDefinition('.debug.http_client')); } public function testI
cyInjection\HttpClientPass; use Symfony\Component\HttpClient\TraceableHttpClient; use Symfony\Contracts\HttpClient\HttpClientInterface; class HttpClientPassTest extends TestCase { public function testItRequiresDataCollector(
{ "filepath": "src/Symfony/Component/HttpClient/Tests/DependencyInjection/HttpClientPassTest.php", "language": "php", "file_size": 2492, "cut_index": 563, "middle_length": 229 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Test; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpClient\Response\MockResponse; use Symfony\Contrac...
$method, string $url, array $options): ResponseInterface { if (!is_file($this->archiveFile)) { throw new \InvalidArgumentException(\sprintf('Invalid file path provided: "%s".', $this->archiveFile)); } $json = json_d
public function __construct(private string $archiveFile) { } public function setArchiveFile(string $archiveFile): void { $this->archiveFile = $archiveFile; } public function __invoke(string
{ "filepath": "src/Symfony/Component/HttpClient/Test/HarFileResponseFactory.php", "language": "php", "file_size": 3283, "cut_index": 614, "middle_length": 229 }
file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Messenger; use Symfony\Contracts\HttpClient\HttpClientInter...
} public function __invoke(PingWebhookMessage $message): ResponseInterface { $response = $this->httpClient->request($message->method, $message->url, $message->options); $response->getHeaders($message->throw); return $r
e readonly HttpClientInterface $httpClient, ) {
{ "filepath": "src/Symfony/Component/HttpClient/Messenger/PingWebhookMessageHandler.php", "language": "php", "file_size": 854, "cut_index": 529, "middle_length": 52 }
* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Retry; use Symfony\Component\HttpClient\Exception\InvalidArgumentException; use Symfony\Component\HttpClient\Response\AsyncContext; use Symfony\...
0 => self::IDEMPOTENT_METHODS, // for transport exceptions 423, 425, 429, 500 => self::IDEMPOTENT_METHODS, 502, 503, 504 => self::IDEMPOTENT_METHODS, 507 => self::IDEMPOTENT_METHODS,
derusse.com> */ class GenericRetryStrategy implements RetryStrategyInterface { public const IDEMPOTENT_METHODS = ['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE', 'QUERY']; public const DEFAULT_RETRY_STATUS_CODES = [
{ "filepath": "src/Symfony/Component/HttpClient/Retry/GenericRetryStrategy.php", "language": "php", "file_size": 3982, "cut_index": 614, "middle_length": 229 }