mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
✅ Remove test dirs in lib
This commit is contained in:
@@ -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
|
||||
{
|
||||
}
|
||||
@@ -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 [];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user