Fix more bad tests
This commit is contained in:
parent
592aacff6f
commit
cc3e3d54ea
27
src/Symfony/Bridge/Monolog/Tests/ClassThatInheritLogger.php
Normal file
27
src/Symfony/Bridge/Monolog/Tests/ClassThatInheritLogger.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?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\Bridge\Monolog\Tests;
|
||||
|
||||
use Symfony\Bridge\Monolog\Logger;
|
||||
|
||||
class ClassThatInheritLogger extends Logger
|
||||
{
|
||||
public function getLogs(): array
|
||||
{
|
||||
return parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors(): int
|
||||
{
|
||||
return parent::countErrors();
|
||||
}
|
||||
}
|
@ -128,33 +128,12 @@ class LoggerTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function testInheritedClassCallGetLogsWithoutArgument()
|
||||
public function testInheritedClassWithoutArgument()
|
||||
{
|
||||
$loggerChild = new ClassThatInheritLogger('test');
|
||||
$loggerChild->getLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Logger::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function testInheritedClassCallCountErrorsWithoutArgument()
|
||||
{
|
||||
$loggerChild = new ClassThatInheritLogger('test');
|
||||
$loggerChild->countErrors();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatInheritLogger extends Logger
|
||||
{
|
||||
public function getLogs()
|
||||
{
|
||||
parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors()
|
||||
{
|
||||
parent::countErrors();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?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\Bridge\Monolog\Tests\Processor;
|
||||
|
||||
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
|
||||
|
||||
class ClassThatInheritDebugProcessor extends DebugProcessor
|
||||
{
|
||||
public function getLogs(): array
|
||||
{
|
||||
return parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors(): int
|
||||
{
|
||||
return parent::countErrors();
|
||||
}
|
||||
}
|
@ -66,20 +66,12 @@ class DebugProcessorTest extends TestCase
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Processor\DebugProcessor::getLogs()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Processor\DebugProcessor::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function testInheritedClassCallGetLogsWithoutArgument()
|
||||
public function testInheritedClassWithoutArgument()
|
||||
{
|
||||
$debugProcessorChild = new ClassThatInheritDebugProcessor();
|
||||
$debugProcessorChild->getLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The "Symfony\Bridge\Monolog\Processor\DebugProcessor::countErrors()" method will have a new "Request $request = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
|
||||
*/
|
||||
public function testInheritedClassCallCountErrorsWithoutArgument()
|
||||
{
|
||||
$debugProcessorChild = new ClassThatInheritDebugProcessor();
|
||||
$debugProcessorChild->countErrors();
|
||||
}
|
||||
|
||||
@ -96,16 +88,3 @@ class DebugProcessorTest extends TestCase
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatInheritDebugProcessor extends DebugProcessor
|
||||
{
|
||||
public function getLogs()
|
||||
{
|
||||
parent::getLogs();
|
||||
}
|
||||
|
||||
public function countErrors()
|
||||
{
|
||||
parent::countErrors();
|
||||
}
|
||||
}
|
||||
|
@ -81,8 +81,6 @@ class AbstractControllerTest extends ControllerTraitTest
|
||||
|
||||
class TestAbstractController extends AbstractController
|
||||
{
|
||||
use TestControllerTrait;
|
||||
|
||||
private $throwOnUnexpectedService;
|
||||
|
||||
public function __construct($throwOnUnexpectedService = true)
|
||||
@ -90,6 +88,11 @@ class TestAbstractController extends AbstractController
|
||||
$this->throwOnUnexpectedService = $throwOnUnexpectedService;
|
||||
}
|
||||
|
||||
public function __call(string $method, array $arguments)
|
||||
{
|
||||
return $this->$method(...$arguments);
|
||||
}
|
||||
|
||||
public function setContainer(ContainerInterface $container)
|
||||
{
|
||||
if (!$this->throwOnUnexpectedService) {
|
||||
@ -114,11 +117,6 @@ class TestAbstractController extends AbstractController
|
||||
return parent::setContainer($container);
|
||||
}
|
||||
|
||||
public function getParameter(string $name)
|
||||
{
|
||||
return parent::getParameter($name);
|
||||
}
|
||||
|
||||
public function fooAction()
|
||||
{
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||
|
||||
use Fig\Link\Link;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Form\Form;
|
||||
@ -550,29 +549,3 @@ abstract class ControllerTraitTest extends TestCase
|
||||
$this->assertContains($link2, $links);
|
||||
}
|
||||
}
|
||||
|
||||
trait TestControllerTrait
|
||||
{
|
||||
use ControllerTrait {
|
||||
generateUrl as public;
|
||||
redirect as public;
|
||||
forward as public;
|
||||
getUser as public;
|
||||
json as public;
|
||||
file as public;
|
||||
isGranted as public;
|
||||
denyAccessUnlessGranted as public;
|
||||
redirectToRoute as public;
|
||||
addFlash as public;
|
||||
isCsrfTokenValid as public;
|
||||
renderView as public;
|
||||
render as public;
|
||||
stream as public;
|
||||
createNotFoundException as public;
|
||||
createAccessDeniedException as public;
|
||||
createForm as public;
|
||||
createFormBuilder as public;
|
||||
getDoctrine as public;
|
||||
addLink as public;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,30 @@
|
||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait;
|
||||
|
||||
class TestController extends Controller
|
||||
{
|
||||
use TestControllerTrait;
|
||||
use ControllerTrait {
|
||||
generateUrl as public;
|
||||
redirect as public;
|
||||
forward as public;
|
||||
getUser as public;
|
||||
json as public;
|
||||
file as public;
|
||||
isGranted as public;
|
||||
denyAccessUnlessGranted as public;
|
||||
redirectToRoute as public;
|
||||
addFlash as public;
|
||||
isCsrfTokenValid as public;
|
||||
renderView as public;
|
||||
render as public;
|
||||
stream as public;
|
||||
createNotFoundException as public;
|
||||
createAccessDeniedException as public;
|
||||
createForm as public;
|
||||
createFormBuilder as public;
|
||||
getDoctrine as public;
|
||||
addLink as public;
|
||||
}
|
||||
}
|
||||
|
@ -19,61 +19,6 @@ use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
use Symfony\Component\DomCrawler\Form as DomCrawlerForm;
|
||||
|
||||
class SpecialResponse extends Response
|
||||
{
|
||||
}
|
||||
|
||||
class TestClient extends AbstractBrowser
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
protected $nextScript = null;
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
public function setNextScript($script)
|
||||
{
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
}
|
||||
|
||||
$response = $this->nextResponse;
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function filterResponse($response)
|
||||
{
|
||||
if ($response instanceof SpecialResponse) {
|
||||
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getScript($request)
|
||||
{
|
||||
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
|
||||
$path = $r->getFileName();
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
require_once('$path');
|
||||
|
||||
echo serialize($this->nextScript);
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
class AbstractBrowserTest extends TestCase
|
||||
{
|
||||
public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null)
|
||||
@ -159,17 +104,6 @@ class AbstractBrowserTest extends TestCase
|
||||
$this->assertNull($client->getResponse());
|
||||
}
|
||||
|
||||
public function testGetInternalResponse()
|
||||
{
|
||||
$client = $this->getBrowser();
|
||||
$client->setNextResponse(new SpecialResponse('foo'));
|
||||
$client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse());
|
||||
$this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse());
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation Calling the "Symfony\Component\BrowserKit\Tests\%s::getInternalResponse()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.
|
||||
|
@ -0,0 +1,44 @@
|
||||
<?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\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\AbstractBrowser;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\DomCrawler\Form as DomCrawlerForm;
|
||||
|
||||
class ClassThatInheritClient extends AbstractBrowser
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
}
|
||||
|
||||
$response = $this->nextResponse;
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function submit(DomCrawlerForm $form, array $values = []): Crawler
|
||||
{
|
||||
return parent::submit($form, $values);
|
||||
}
|
||||
}
|
@ -14,89 +14,9 @@ namespace Symfony\Component\BrowserKit\Tests;
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\HttpBrowser;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Symfony\Contracts\HttpClient\ResponseInterface;
|
||||
|
||||
class SpecialHttpResponse extends Response
|
||||
{
|
||||
}
|
||||
|
||||
class TestHttpClient extends HttpBrowser
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
protected $nextScript = null;
|
||||
|
||||
public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null)
|
||||
{
|
||||
$client = new MockHttpClient(function (string $method, string $url, array $options) {
|
||||
if (null === $this->nextResponse) {
|
||||
return new MockResponse();
|
||||
}
|
||||
|
||||
return new MockResponse($this->nextResponse->getContent(), [
|
||||
'http_code' => $this->nextResponse->getStatusCode(),
|
||||
'response_headers' => $this->nextResponse->getHeaders(),
|
||||
]);
|
||||
});
|
||||
parent::__construct($client);
|
||||
|
||||
$this->setServerParameters($server);
|
||||
$this->history = $history ?? new History();
|
||||
$this->cookieJar = $cookieJar ?? new CookieJar();
|
||||
}
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
public function setNextScript($script)
|
||||
{
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function filterResponse($response)
|
||||
{
|
||||
if ($response instanceof SpecialHttpResponse) {
|
||||
return new Response($response->getContent(), $response->getStatusCode(), $response->getHeaders());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function doRequest($request)
|
||||
{
|
||||
$response = parent::doRequest($request);
|
||||
|
||||
if (null === $this->nextResponse) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$class = \get_class($this->nextResponse);
|
||||
$response = new $class($response->getContent(), $response->getStatusCode(), $response->getHeaders());
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getScript($request)
|
||||
{
|
||||
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
|
||||
$path = $r->getFileName();
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
require_once('$path');
|
||||
|
||||
echo serialize($this->nextScript);
|
||||
EOF;
|
||||
}
|
||||
}
|
||||
|
||||
class HttpBrowserTest extends AbstractBrowserTest
|
||||
{
|
||||
public function getBrowser(array $server = [], History $history = null, CookieJar $cookieJar = null)
|
||||
@ -104,17 +24,6 @@ class HttpBrowserTest extends AbstractBrowserTest
|
||||
return new TestHttpClient($server, $history, $cookieJar);
|
||||
}
|
||||
|
||||
public function testGetInternalResponse()
|
||||
{
|
||||
$client = $this->getBrowser();
|
||||
$client->setNextResponse(new SpecialHttpResponse('foo'));
|
||||
$client->request('GET', 'http://example.com/');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse());
|
||||
$this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialHttpResponse', $client->getInternalResponse());
|
||||
$this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialHttpResponse', $client->getResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validContentTypes
|
||||
*/
|
||||
|
57
src/Symfony/Component/BrowserKit/Tests/TestClient.php
Normal file
57
src/Symfony/Component/BrowserKit/Tests/TestClient.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?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\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\AbstractBrowser;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
|
||||
class TestClient extends AbstractBrowser
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
protected $nextScript = null;
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
public function setNextScript($script)
|
||||
{
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return new Response();
|
||||
}
|
||||
|
||||
$response = $this->nextResponse;
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getScript($request)
|
||||
{
|
||||
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
|
||||
$path = $r->getFileName();
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
require_once('$path');
|
||||
|
||||
echo serialize($this->nextScript);
|
||||
EOF;
|
||||
}
|
||||
}
|
80
src/Symfony/Component/BrowserKit/Tests/TestHttpClient.php
Normal file
80
src/Symfony/Component/BrowserKit/Tests/TestHttpClient.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?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\BrowserKit\Tests;
|
||||
|
||||
use Symfony\Component\BrowserKit\CookieJar;
|
||||
use Symfony\Component\BrowserKit\History;
|
||||
use Symfony\Component\BrowserKit\HttpBrowser;
|
||||
use Symfony\Component\BrowserKit\Response;
|
||||
use Symfony\Component\HttpClient\MockHttpClient;
|
||||
use Symfony\Component\HttpClient\Response\MockResponse;
|
||||
|
||||
class TestHttpClient extends HttpBrowser
|
||||
{
|
||||
protected $nextResponse = null;
|
||||
protected $nextScript = null;
|
||||
|
||||
public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null)
|
||||
{
|
||||
$client = new MockHttpClient(function (string $method, string $url, array $options) {
|
||||
if (null === $this->nextResponse) {
|
||||
return new MockResponse();
|
||||
}
|
||||
|
||||
return new MockResponse($this->nextResponse->getContent(), [
|
||||
'http_code' => $this->nextResponse->getStatusCode(),
|
||||
'response_headers' => $this->nextResponse->getHeaders(),
|
||||
]);
|
||||
});
|
||||
parent::__construct($client);
|
||||
|
||||
$this->setServerParameters($server);
|
||||
$this->history = $history ?? new History();
|
||||
$this->cookieJar = $cookieJar ?? new CookieJar();
|
||||
}
|
||||
|
||||
public function setNextResponse(Response $response)
|
||||
{
|
||||
$this->nextResponse = $response;
|
||||
}
|
||||
|
||||
public function setNextScript($script)
|
||||
{
|
||||
$this->nextScript = $script;
|
||||
}
|
||||
|
||||
protected function doRequest($request): Response
|
||||
{
|
||||
if (null === $this->nextResponse) {
|
||||
return parent::doRequest($request);
|
||||
}
|
||||
|
||||
$response = $this->nextResponse;
|
||||
$this->nextResponse = null;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function getScript($request)
|
||||
{
|
||||
$r = new \ReflectionClass('Symfony\Component\BrowserKit\Response');
|
||||
$path = $r->getFileName();
|
||||
|
||||
return <<<EOF
|
||||
<?php
|
||||
|
||||
require_once('$path');
|
||||
|
||||
echo serialize($this->nextScript);
|
||||
EOF;
|
||||
}
|
||||
}
|
@ -1238,11 +1238,3 @@ HTML;
|
||||
return $domxpath->query('//div');
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatInheritCrawler extends Crawler
|
||||
{
|
||||
public function children()
|
||||
{
|
||||
parent::children();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
<?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\DomCrawler\Tests;
|
||||
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class ClassThatInheritCrawler extends Crawler
|
||||
{
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return parent::children();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?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\Finder\Tests;
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
class ClassThatInheritFinder extends Finder
|
||||
{
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function sortByName()
|
||||
{
|
||||
parent::sortByName();
|
||||
}
|
||||
}
|
@ -873,6 +873,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
|
||||
$expected = [
|
||||
self::$tmpDir.\DIRECTORY_SEPARATOR.'test.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'ClassThatInheritFinder.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'GitignoreTest.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'FinderTest.php',
|
||||
__DIR__.\DIRECTORY_SEPARATOR.'GlobTest.php',
|
||||
@ -1435,11 +1436,3 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
||||
return Finder::create();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatInheritFinder extends Finder
|
||||
{
|
||||
public function sortByName()
|
||||
{
|
||||
parent::sortByName();
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,13 @@
|
||||
namespace Symfony\Component\Form\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
|
||||
class AbstractTypeExtensionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testImplementingNeitherGetExtendedTypeNorExtendsTypeThrowsException()
|
||||
{
|
||||
$this->expectException('Symfony\Component\Form\Exception\LogicException');
|
||||
@ -28,6 +29,7 @@ class AbstractTypeExtensionTest extends TestCase
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
* @expectedDeprecation The Symfony\Component\Form\Tests\MultipleTypesExtension::getExtendedType() method is deprecated since Symfony 4.2 and will be removed in 5.0. Use getExtendedTypes() instead.
|
||||
*/
|
||||
public function testGetExtendedTypeReturnsFirstConfiguredExtension()
|
||||
{
|
||||
@ -36,16 +38,3 @@ class AbstractTypeExtensionTest extends TestCase
|
||||
$this->assertSame(DateTimeType::class, $extension->getExtendedType());
|
||||
}
|
||||
}
|
||||
|
||||
class MultipleTypesExtension extends AbstractTypeExtension
|
||||
{
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
yield DateTimeType::class;
|
||||
yield DateType::class;
|
||||
}
|
||||
}
|
||||
|
||||
class TypeExtensionWithoutExtendedTypes extends AbstractTypeExtension
|
||||
{
|
||||
}
|
||||
|
25
src/Symfony/Component/Form/Tests/MultipleTypesExtension.php
Normal file
25
src/Symfony/Component/Form/Tests/MultipleTypesExtension.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?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\Tests;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
|
||||
class MultipleTypesExtension extends AbstractTypeExtension
|
||||
{
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
yield DateTimeType::class;
|
||||
yield DateType::class;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?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\Tests;
|
||||
|
||||
use Symfony\Component\Form\AbstractTypeExtension;
|
||||
|
||||
class TypeExtensionWithoutExtendedTypes extends AbstractTypeExtension
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user