8000 renamed Client to Browser · symfony/symfony@dbe4f86 · GitHub
[go: up one dir, main page]

Skip to content

Commit dbe4f86

Browse files
committed
renamed Client to Browser
1 parent 0e2ea87 commit dbe4f86

File tree

20 files changed

+1201
-1131
lines changed
  • Component
  • 20 files changed

    +1201
    -1131
    lines changed

    UPGRADE-4.3.md

    Lines changed: 6 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,6 +4,7 @@ UPGRADE FROM 4.2 to 4.3
    44
    BrowserKit
    55
    ----------
    66

    7+
    * Renamed `Client` to `AbstractBrowser`
    78
    * Marked `Response` final.
    89
    * Deprecated `Response::buildHeader()`
    910
    * Deprecated `Response::getStatus()`, use `Response::getStatusCode()` instead
    @@ -51,6 +52,11 @@ HttpFoundation
    5152
    * The `FileinfoMimeTypeGuesser` class has been deprecated,
    5253
    use `Symfony\Component\Mime\FileinfoMimeTypeGuesser` instead.
    5354

    55+
    HttpKernel
    56+
    ----------
    57+
    58+
    * renamed `Client` to `HttpKernelBrowser`
    59+
    5460
    Messenger
    5561
    ---------
    5662

    UPGRADE-5.0.md

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,6 +4,7 @@ UPGRADE FROM 4.x to 5.0
    44
    BrowserKit
    55
    ----------
    66

    7+
    * Removed `Client`, use `AbstractBrowser` instead
    78
    * Removed the possibility to extend `Response` by making it final.
    89
    * Removed `Response::buildHeader()`
    910
    * Removed `Response::getStatus()`, use `Response::getStatusCode()` instead
    @@ -199,6 +200,7 @@ HttpFoundation
    199200
    HttpKernel
    200201
    ----------
    201202

    203+
    * Removed `Client`, use `HttpKernelBrowser` instead
    202204
    * The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
    203205
    * The `KernelInterface::getName()` and the `kernel.name` parameter have been removed
    204206
    * Removed the first and second constructor argument of `ConfigDataCollector`

    src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -4,6 +4,7 @@ CHANGELOG
    44
    4.3.0
    55
    -----
    66

    7+
    * renamed `Client` to `KernelBrowser`
    78
    * Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
    89
    be mandatory in 5.0.
    910
    * Deprecated the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead

    src/Symfony/Bundle/FrameworkBundle/Client.php

    Lines changed: 2 additions & 190 deletions
    Original file line numberDiff line numberDiff line change
    @@ -11,196 +11,8 @@
    1111

    1212
    namespace Symfony\Bundle\FrameworkBundle;
    1313

    14-
    use Symfony\Component\BrowserKit\CookieJar;
    15-
    use Symfony\Component\BrowserKit\History;
    16-
    use Symfony\Component\DependencyInjection\ContainerInterface;
    17-
    use Symfony\Component\HttpFoundation\Request;
    18-
    use Symfony\Component\HttpFoundation\Response;
    19-
    use Symfony\Component\HttpKernel\Client as BaseClient;
    20-
    use Symfony\Component\HttpKernel\KernelInterface;
    21-
    use Symfony\Component\HttpKernel\Profiler\Profile as HttpProfile;
    14+
    @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.3, use "%s" instead.', Client::class, KernelBrowser::class), E_USER_DEPRECATED);
    2215

    23-
    /**
    24-
    * Client simulates a browser and makes requests to a Kernel object.
    25-
    *
    26-
    * @author Fabien Potencier <fabien@symfony.com>
    27-
    */
    28-
    class Client extends BaseClient
    16+
    class Client extends KernelBrowser
    2917
    {
    30-
    private $hasPerformedRequest = false;
    31-
    private $profiler = false;
    32-
    private $reboot = true;
    33-
    34-
    /**
    35-
    * {@inheritdoc}
    36-
    */
    37-
    public function __construct(KernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null)
    38-
    {
    39-
    parent::__construct($kernel, $server, $history, $cookieJar);
    40-
    }
    41-
    42-
    /**
    43-
    * Returns the container.
    44-
    *
    45-
    * @return ContainerInterface|null Returns null when the Kernel has been shutdown or not started yet
    46-
    */
    47-
    public function getContainer()
    48-
    {
    49-
    return $this->kernel->getContainer();
    50-
    }
    51-
    52-
    /**
    53-
    * Returns the kernel.
    54-
    *
    55-
    * @return KernelInterface
    56-
    */
    57-
    public function getKernel()
    58-
    {
    59-
    return $this->kernel;
    60-
    }
    61-
    62-
    /**
    63-
    * Gets the profile associated with the current Response.
    64-
    *
    65-
    * @return HttpProfile|false A Profile instance
    66-
    */
    67-
    public function getProfile()
    68-
    {
    69-
    if (!$this->kernel->getContainer()->has('profiler')) {
    70-
    return false;
    71-
    }
    72-
    73-
    return $this->kernel->getContainer()->get('profiler')->loadProfileFromResponse($this->response);
    74-
    }
    75-
    76-
    /**
    77-
    * Enables the profiler for the very next request.
    78-
    *
    79-
    * If the profiler is not enabled, the call to this method does nothing.
    80-
    */
    81-
    public function enableProfiler()
    82-
    {
    83-
    if ($this->kernel->getContainer()->has('profiler')) {
    84-
    $this->profiler = true;
    85-
    }
    86-
    }
    87-
    88-
    /**
    89-
    * Disables kernel reboot between requests.
    90-
    *
    91-
    * By default, the Client reboots the Kernel for each request. This method
    92-
    * allows to keep the same kernel across requests.
    93-
    */
    94-
    public function disableReboot()
    95-
    {
    96-
    $this->reboot = false;
    97-
    }
    98-
    99-
    /**
    100-
    * Enables kernel reboot between requests.
    101-
    */
    102-
    public function enableReboot()
    103-
    {
    104-
    $this->reboot = true;
    105-
    }
    106-
    107-
    /**
    108-
    * {@inheritdoc}
    109-
    *
    110-
    * @param Request $request A Request instance
    111-
    *
    112-
    * @return Response A Response instance
    113-
    */
    114-
    protected function doRequest($request)
    115-
    {
    116-
    // avoid shutting down the Kernel if no request has been performed yet
    117-
    // WebTestCase::createClient() boots the Kernel but do not handle a request
    118-
    if ($this->hasPerformedRequest && $this->reboot) {
    119-
    $this->kernel->shutdown();
    120-
    } else {
    121-
    $this->hasPerformedRequest = true;
    122-
    }
    123-
    124-
    if ($this->profiler) {
    125-
    $this->profiler = false;
    126-
    127-
    $this->kernel->boot();
    128-
    $this->kernel->getContainer()->get('profiler')->enable();
    129-
    }
    130-
    131-
    return parent::doRequest($request);
    132-
    }
    133-
    134-
    /**
    135-
    * {@inheritdoc}
    136-
    *
    137-
    * @param Request $request A Request instance
    138-
    *
    139-
    * @return Response A Response instance
    140-
    */
    141-
    protected function doRequestInProcess($request)
    142-
    {
    143-
    $response = parent::doRequestInProcess($request);
    144-
    145-
    $this->profiler = false;
    146-
    147-
    return $response;
    148-
    }
    149-
    150-
    /**
    151-
    * Returns the script to execute when the request must be insulated.
    152-
    *
    153-
    * It assumes that the autoloader is named 'autoload.php' and that it is
    154-
    * stored in the same directory as the kernel (this is the case for the
    155-
    * Symfony Standard Edition). If this is not your case, create your own
    156-
    * client and override this method.
    157-
    *
    158-
    * @param Request $request A Request instance
    159-
    *
    160-
    * @return string The script content
    161-
    */
    162-
    protected function getScript($request)
    163-
    {
    164-
    $kernel = var_export(serialize($this->kernel), true);
    165-
    $request = var_export(serialize($request), true);
    166-
    $errorReporting = error_reporting();
    167-
    168-
    $requires = '';
    169-
    foreach (get_declared_classes() as $class) {
    170-
    if (0 === strpos($class, 'ComposerAutoloaderInit')) {
    171-
    $r = new \ReflectionClass($class);
    172-
    $file = \dirname(\dirname($r->getFileName())).'/autoload.php';
    173-
    if (file_exists($file)) {
    174-
    $requires .= 'require_once '.var_export($file, true).";\n";
    175-
    }
    176-
    }
    177-
    }
    178-
    179-
    if (!$requires) {
    180-
    throw new \RuntimeException('Composer autoloader not found.');
    181-
    }
    182-
    183-
    $requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n";
    184-
    185-
    $profilerCode = '';
    186-
    if ($this->profiler) {
    187-
    $profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();';
    188-
    }
    189-
    190-
    $code = <<<EOF
    191-
    <?php
    192-
    193-
    error_reporting($errorReporting);
    194-
    195-
    $requires
    196-
    197-
    \$kernel = unserialize($kernel);
    198-
    \$kernel->boot();
    199-
    $profilerCode
    200-
    201-
    \$request = unserialize($request);
    202-
    EOF;
    203-
    204-
    return $code.$this->getHandleScript();
    205-
    }
    20618
    }

    src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,7 +22,7 @@
    2222
    use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
    2323
    use Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher;
    2424
    use Symfony\Bundle\FullStack;
    25-
    use Symfony\Component\BrowserKit\Client;
    25+
    use Symfony\Component\BrowserKit\AbstractBrowser;
    2626
    use Symfony\Component\Cache\Adapter\AbstractAdapter;
    2727
    use Symfony\Component\Cache\Adapter\AdapterInterface;
    2828
    use Symfony\Component\Cache\Adapter\ArrayAdapter;
    @@ -207,7 +207,7 @@ public function load(array $configs, ContainerBuilder $container)
    207207
    if (!empty($config['test'])) {
    208208
    $loader->load('test.xml');
    209209

    210-
    if (!class_exists(Client::class)) {
    210+
    if (!class_exists(AbstractBrowser::class)) {
    211211
    $container->removeDefinition('test.client');
    212212
    }
    213213
    }

    0 commit comments

    Comments
     (0)
    0