As per the parent issue.

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Status: Active » Needs review
StatusFileSize
new14.36 KB
dawehner’s picture

Status: Needs review » Needs work

Thank you for your contribution @phenaproxima!

  1. diff --git a/core/modules/system/src/Tests/Database/DatabaseWebTestBase.php b/core/modules/system/tests/src/Functional/Database/DatabaseWebTestBase.php
    similarity index 58%
    
    similarity index 58%
    rename from core/modules/system/src/Tests/Database/DatabaseWebTestBase.php
    
    rename from core/modules/system/src/Tests/Database/DatabaseWebTestBase.php
    rename to core/modules/system/tests/src/Functional/Database/DatabaseWebTestBase.php
    
    rename to core/modules/system/tests/src/Functional/Database/DatabaseWebTestBase.php
    index 8fb369a376..3a23b5915d 100644
    

    You need to copy the existing base class ...and throw a @trigger_error in the old one.

  2. +++ b/core/modules/system/tests/src/Functional/Database/DatabaseWebTestBase.php
    @@ -1,22 +1,23 @@
       /**
    -   * Modules to enable.
    -   *
    -   * @var array
    +   * {@inheritdoc}
        */
       public static $modules = ['database_test'];
     
    +  /**
    +   * {@inheritdoc}
    +   */
       protected function setUp() {
    

    Please keep in mind to create a minimal conversion.

  3. +++ b/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php
    @@ -97,7 +98,7 @@ public function testInnerPagerQuery() {
    -    $this->assertEqual($ages, [25, 26, 27, 28], 'Inner pager query returned the correct ages.');
    +    $this->assertEquals([25, 26, 27, 28], $ages, 'Inner pager query returned the correct ages.');
    
    @@ -118,14 +119,13 @@ public function testHavingPagerQuery() {
    -    $this->assertEqual($ages, ['George', 'Ringo'], 'Pager query with having expression returned the correct ages.');
    +    $this->assertEquals(['George', 'Ringo'], $ages, 'Pager query with having expression returned the correct ages.');
    
    @@ -140,7 +140,7 @@ public function testElementNumbers() {
    -    $this->assertEqual($name, 'Paul', 'Pager query #1 with a specified element ID returned the correct results.');
    +    $this->assertEquals('Paul', $name, 'Pager query #1 with a specified element ID returned the correct results.');
    
    @@ -152,7 +152,7 @@ public function testElementNumbers() {
    -    $this->assertEqual($name, 'George', 'Pager query #2 with a specified element ID returned the correct results.');
    +    $this->assertEquals('George', $name, 'Pager query #2 with a specified element ID returned the correct results.');
    
    @@ -161,8 +161,7 @@ public function testElementNumbers() {
    -    $this->assertEqual($name, 'John', 'Pager query #3 with a generated element ID returned the correct results.');
    -
    +    $this->assertEquals('John', $name, 'Pager query #3 with a generated element ID returned the correct results.');
    

    These changes increase the size of the patch more than needed. Please revert them, it takes time to review them.

  4. +++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php
    index e55590e7ed..67f227d6df 100644
    --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
    
    --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
    +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
    
    +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php
    @@ -69,12 +69,11 @@ public function testQueryFetchArray() {
    -    $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => 'Drupal\system\Tests\Database\FakeRecord']);
    +    $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => FakeRecord::class]);
    

    This is a kernel test, I doubt we have to touch that :)

lendude’s picture

Title: Database: Convert system functional tests to PHPUnit » Database/DrupalKernel: Convert system functional tests to PHPUnit
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new7.38 KB
new14.06 KB

@phenaproxima++

#3.1 fixed, and renamed the new base class from DatabaseWebTestBase to DatabaseTestBase, otherwise the ancestry might get a little confusing
#3.2 fixed
#3.3 fixed
#3.4 well the kernel test uses the FakeRecord in the simpletest namespace, so that does need to be updated to the new namespace.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php
index 97a676b162..2904d31fa6 100644
--- a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php

--- a/core/modules/system/src/Tests/Database/SelectTableSortDefaultTest.php
+++ b/core/modules/system/tests/src/Functional/Database/SelectTableSortDefaultTest.php

One day we should have an issue to move this outside of the database tests :P

  • catch committed d5e48ef on 8.4.x
    Issue #2872151 by Lendude, phenaproxima, dawehner: Database/DrupalKernel...

  • catch committed e0aab13 on 8.3.x
    Issue #2872151 by Lendude, phenaproxima, dawehner: Database/DrupalKernel...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.