Skip to content
Snippets Groups Projects
Verified Commit 5637aff4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3432867 by catch, Satane, quietone: Removed deprecated code in core/tests/Drupal/KernelTests

parent 98b21533
No related branches found
No related tags found
26 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #149350 passed with warnings
Pipeline: drupal

#149353

    ......@@ -9,6 +9,8 @@
    use Symfony\Component\HttpFoundation\File\UploadedFile;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\RequestStack;
    use Symfony\Component\HttpFoundation\Session\Session;
    use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
    /**
    * Tests file_save_upload().
    ......@@ -45,7 +47,7 @@ protected function setUp(): void {
    test: TRUE
    ),
    ]);
    $request->setSession(new Session(new MockArraySessionStorage()));
    $requestStack = new RequestStack();
    $requestStack->push($request);
    ......
    <?php
    declare(strict_types=1);
    namespace Drupal\KernelTests\Core\Entity;
    /**
    * Tests the deprecations for the \Drupal\KernelTests\Core\Entity namespace.
    *
    * @group Entity
    * @group legacy
    */
    class EntityDeprecationTest extends EntityKernelTestBase {
    /**
    * Tests deprecation of \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::createUser().
    */
    public function testCreateUserDeprecation(): void {
    $this->expectDeprecation('Calling createUser() with $values as the first parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762');
    $this->createUser(['uid' => 2]);
    $this->expectDeprecation('Calling createUser() with $permissions as the second parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762');
    $this->createUser([], ['administer entity_test content']);
    }
    }
    ......@@ -109,27 +109,6 @@ protected function setUp(): void {
    * The created user entity.
    */
    protected function createUser(array $permissions = [], $name = NULL, bool $admin = FALSE, array $values = []) {
    // Allow for the old signature of this method:
    // createUser($values = [], $permissions = [])
    if (!array_is_list($permissions)) {
    // An array with keys is assumed to be entity values rather than
    // permissions, since there is no point in an array of permissions having
    // keys.
    @trigger_error('Calling createUser() with $values as the first parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762', E_USER_DEPRECATED);
    $values = $permissions;
    $permissions = [];
    }
    if (is_array($name)) {
    // If $name is an array rather than a string, then the caller is intending
    // to pass in $permissions.
    @trigger_error('Calling createUser() with $permissions as the second parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762', E_USER_DEPRECATED);
    $permissions = $name;
    $name = NULL;
    }
    return $this->drupalCreateUser($permissions, $name, $admin, $values);
    }
    ......
    <?php
    declare(strict_types=1);
    namespace Drupal\KernelTests\Core\Test;
    use Drupal\Core\Test\TestSetupTrait;
    use Drupal\KernelTests\KernelTestBase;
    /**
    * Tests the TestSetupTrait trait.
    *
    * @coversDefaultClass \Drupal\Core\Test\TestSetupTrait
    * @group Testing
    *
    * Run in a separate process as this test involves Database statics and
    * environment variables.
    * @runTestsInSeparateProcesses
    * @preserveGlobalState disabled
    */
    class TestSetupTraitTest extends KernelTestBase {
    use TestSetupTrait;
    /**
    * @covers ::getDatabaseConnection
    * @group legacy
    */
    public function testGetDatabaseConnection(): void {
    $this->expectDeprecation('Drupal\Core\Test\TestSetupTrait::getDatabaseConnection is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3176816');
    $this->assertNotNull($this->getDatabaseConnection());
    }
    }
    ......@@ -39,7 +39,6 @@
    use Symfony\Component\Routing\Route;
    use Symfony\Component\VarDumper\VarDumper;
    use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
    use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
    /**
    * Base class for functional integration tests.
    ......@@ -270,17 +269,6 @@ protected function setUp(): void {
    $this->bootKernel();
    }
    /**
    * {@inheritdoc}
    */
    public function __get(string $name) {
    if ($name === 'randomGenerator') {
    @trigger_error('Accessing the randomGenerator property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getRandomGenerator() instead. See https://www.drupal.org/node/3358445', E_USER_DEPRECATED);
    return $this->getRandomGenerator();
    }
    }
    /**
    * Bootstraps a basic test environment.
    *
    ......@@ -687,15 +675,10 @@ protected function assertPostConditions(): void {
    protected function tearDown(): void {
    if ($this->container) {
    // Clean up mock session started in DrupalKernel::preHandle().
    try {
    /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
    $session = $this->container->get('request_stack')->getSession();
    $session->clear();
    $session->save();
    }
    catch (SessionNotFoundException) {
    @trigger_error('Pushing requests without a session onto the request_stack is deprecated in drupal:10.3.0 and an error will be thrown from drupal:11.0.0. See https://www.drupal.org/node/3337193', E_USER_DEPRECATED);
    }
    /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
    $session = $this->container->get('request_stack')->getSession();
    $session->clear();
    $session->save();
    }
    // Destroy the testing kernel.
    ......
    ......@@ -5,14 +5,12 @@
    namespace Drupal\KernelTests;
    use Drupal\Component\FileCache\FileCacheFactory;
    use Drupal\Component\Utility\Random;
    use Drupal\Core\Database\Database;
    use Drupal\Tests\StreamCapturer;
    use Drupal\user\Entity\Role;
    use org\bovigo\vfs\vfsStream;
    use org\bovigo\vfs\visitor\vfsStreamStructureVisitor;
    use Psr\Http\Client\ClientExceptionInterface;
    use Symfony\Component\HttpFoundation\Request;
    /**
    * @coversDefaultClass \Drupal\KernelTests\KernelTestBase
    ......@@ -254,18 +252,6 @@ public function testSessionOnRequest(): void {
    $this->assertEquals('do-cleanup', $session->remove('some-other-val'));
    }
    /**
    * Tests deprecation of modified request stack lacking a session.
    *
    * @covers ::tearDown
    *
    * @group legacy
    */
    public function testDeprecatedSessionMissing(): void {
    $this->expectDeprecation('Pushing requests without a session onto the request_stack is deprecated in drupal:10.3.0 and an error will be thrown from drupal:11.0.0. See https://www.drupal.org/node/3337193');
    $this->container->get('request_stack')->push(Request::create('/'));
    }
    /**
    * Tests the assumption that local time is in 'Australia/Sydney'.
    */
    ......@@ -341,17 +327,4 @@ public function testDatabaseDriverModuleEnabled() {
    $this->assertSame(1, \Drupal::service('extension.list.module')->get($module)->status);
    }
    /**
    * Tests the deprecation of accessing the randomGenerator property directly.
    *
    * @group legacy
    */
    public function testGetRandomGeneratorPropertyDeprecation() {
    $this->expectDeprecation('Accessing the randomGenerator property is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use getRandomGenerator() instead. See https://www.drupal.org/node/3358445');
    // We purposely test accessing an undefined property here. We need to tell
    // PHPStan to ignore that.
    // @phpstan-ignore-next-line
    $this->assertInstanceOf(Random::class, $this->randomGenerator);
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment