Remove test dirs in lib

This commit is contained in:
Eric Espie
2025-04-18 10:14:47 +02:00
parent bc4d4431d8
commit 7558b7af08
9 changed files with 0 additions and 427 deletions

View File

@@ -1,18 +0,0 @@
<?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\Form\Test;
use Symfony\Component\Form\FormBuilderInterface as BaseFormBuilderInterface;
interface FormBuilderInterface extends \Iterator, BaseFormBuilderInterface
{
}

View File

@@ -1,54 +0,0 @@
<?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\Form\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\Forms;
/**
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class FormIntegrationTestCase extends TestCase
{
protected FormFactoryInterface $factory;
protected function setUp(): void
{
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
->addTypeExtensions($this->getTypeExtensions())
->addTypes($this->getTypes())
->addTypeGuessers($this->getTypeGuessers())
->getFormFactory();
}
protected function getExtensions()
{
return [];
}
protected function getTypeExtensions()
{
return [];
}
protected function getTypes()
{
return [];
}
protected function getTypeGuessers()
{
return [];
}
}

View File

@@ -1,18 +0,0 @@
<?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\Form\Test;
use Symfony\Component\Form\FormInterface as BaseFormInterface;
interface FormInterface extends \Iterator, BaseFormInterface
{
}

View File

@@ -1,64 +0,0 @@
<?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\Form\Test;
use Symfony\Component\Form\Test\Traits\RunTestTrait;
/**
* Base class for performance tests.
*
* Copied from Doctrine 2's OrmPerformanceTestCase.
*
* @author robo
* @author Bernhard Schussek <bschussek@gmail.com>
*/
abstract class FormPerformanceTestCase extends FormIntegrationTestCase
{
use RunTestTrait;
/**
* @var int
*/
protected $maxRunningTime = 0;
private function doRunTest(): mixed
{
$s = microtime(true);
$result = parent::runTest();
$time = microtime(true) - $s;
if (0 != $this->maxRunningTime && $time > $this->maxRunningTime) {
$this->fail(sprintf('expected running time: <= %s but was: %s', $this->maxRunningTime, $time));
}
$this->expectNotToPerformAssertions();
return $result;
}
/**
* @throws \InvalidArgumentException
*/
public function setMaxRunningTime(int $maxRunningTime)
{
if ($maxRunningTime < 0) {
throw new \InvalidArgumentException();
}
$this->maxRunningTime = $maxRunningTime;
}
public function getMaxRunningTime(): int
{
return $this->maxRunningTime;
}
}

View File

@@ -1,36 +0,0 @@
<?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\Form\Test\Traits;
use PHPUnit\Framework\TestCase;
if ((new \ReflectionMethod(TestCase::class, 'runTest'))->hasReturnType()) {
// PHPUnit 10
/** @internal */
trait RunTestTrait
{
protected function runTest(): mixed
{
return $this->doRunTest();
}
}
} else {
// PHPUnit 9
/** @internal */
trait RunTestTrait
{
protected function runTest()
{
return $this->doRunTest();
}
}
}

View File

@@ -1,44 +0,0 @@
<?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\Form\Test\Traits;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Validator\ValidatorInterface;
trait ValidatorExtensionTrait
{
/**
* @var ValidatorInterface|null
*/
protected $validator;
protected function getValidatorExtension(): ValidatorExtension
{
if (!interface_exists(ValidatorInterface::class)) {
throw new \Exception('In order to use the "ValidatorExtensionTrait", the symfony/validator component must be installed.');
}
if (!$this instanceof TypeTestCase) {
throw new \Exception(sprintf('The trait "ValidatorExtensionTrait" can only be added to a class that extends "%s".', TypeTestCase::class));
}
$this->validator = $this->createMock(ValidatorInterface::class);
$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock();
$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);
}
}

View File

@@ -1,58 +0,0 @@
<?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\Form\Test;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\Test\Traits\ValidatorExtensionTrait;
abstract class TypeTestCase extends FormIntegrationTestCase
{
/**
* @var FormBuilder
*/
protected $builder;
/**
* @var EventDispatcherInterface
*/
protected $dispatcher;
protected function setUp(): void
{
parent::setUp();
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->builder = new FormBuilder('', null, $this->dispatcher, $this->factory);
}
protected function getExtensions()
{
$extensions = [];
if (\in_array(ValidatorExtensionTrait::class, class_uses($this))) {
$extensions[] = $this->getValidatorExtension();
}
return $extensions;
}
public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual)
{
self::assertEquals($expected->format('c'), $actual->format('c'));
}
public static function assertDateIntervalEquals(\DateInterval $expected, \DateInterval $actual)
{
self::assertEquals($expected->format('%RP%yY%mM%dDT%hH%iM%sS'), $actual->format('%RP%yY%mM%dDT%hH%iM%sS'));
}
}

View File

@@ -1,65 +0,0 @@
<?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\PropertyInfo\PhpStan;
/**
* NameScope class adapted from PHPStan code.
*
* @copyright Copyright (c) 2016, PHPStan https://github.com/phpstan/phpstan-src
* @copyright Copyright (c) 2016, Ondřej Mirtes
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*
* @internal
*/
final class NameScope
{
private string $calledClassName;
private string $namespace;
/** @var array<string, string> alias(string) => fullName(string) */
private array $uses;
public function __construct(string $calledClassName, string $namespace, array $uses = [])
{
$this->calledClassName = $calledClassName;
$this->namespace = $namespace;
$this->uses = $uses;
}
public function resolveStringName(string $name): string
{
if (str_starts_with($name, '\\')) {
return ltrim($name, '\\');
}
$nameParts = explode('\\', $name);
$firstNamePart = $nameParts[0];
if (isset($this->uses[$firstNamePart])) {
if (1 === \count($nameParts)) {
return $this->uses[$firstNamePart];
}
array_shift($nameParts);
return sprintf('%s\\%s', $this->uses[$firstNamePart], implode('\\', $nameParts));
}
if (null !== $this->namespace) {
return sprintf('%s\\%s', $this->namespace, $name);
}
return $name;
}
public function resolveRootClass(): string
{
return $this->resolveStringName($this->calledClassName);
}
}

View File

@@ -1,70 +0,0 @@
<?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\PropertyInfo\PhpStan;
use phpDocumentor\Reflection\Types\ContextFactory;
/**
* @author Baptiste Leduc <baptiste.leduc@gmail.com>
*
* @internal
*/
final class NameScopeFactory
{
public function create(string $calledClassName, ?string $declaringClassName = null): NameScope
{
$declaringClassName ??= $calledClassName;
$path = explode('\\', $calledClassName);
$calledClassName = array_pop($path);
$declaringReflection = new \ReflectionClass($declaringClassName);
[$declaringNamespace, $declaringUses] = $this->extractFromFullClassName($declaringReflection);
$declaringUses = array_merge($declaringUses, $this->collectUses($declaringReflection));
return new NameScope($calledClassName, $declaringNamespace, $declaringUses);
}
private function collectUses(\ReflectionClass $reflection): array
{
$uses = [$this->extractFromFullClassName($reflection)[1]];
foreach ($reflection->getTraits() as $traitReflection) {
$uses[] = $this->extractFromFullClassName($traitReflection)[1];
}
if (false !== $parentClass = $reflection->getParentClass()) {
$uses[] = $this->collectUses($parentClass);
}
return $uses ? array_merge(...$uses) : [];
}
private function extractFromFullClassName(\ReflectionClass $reflection): array
{
$namespace = trim($reflection->getNamespaceName(), '\\');
$fileName = $reflection->getFileName();
if (\is_string($fileName) && is_file($fileName)) {
if (false === $contents = file_get_contents($fileName)) {
throw new \RuntimeException(sprintf('Unable to read file "%s".', $fileName));
}
$factory = new ContextFactory();
$context = $factory->createForNamespace($namespace, $contents);
return [$namespace, $context->getNamespaceAliases()];
}
return [$namespace, []];
}
}