Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/german-vocational.cn/core/tests/Drupal/KernelTests/Core/Database/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html/german-vocational.cn/core/tests/Drupal/KernelTests/Core/Database/PrefixInfoTest.php

<?php

namespace Drupal\KernelTests\Core\Database;

use Drupal\Core\Database\Database;

/**
 * Tests that the prefix info for a database schema is correct.
 *
 * @group Database
 */
class PrefixInfoTest extends DatabaseTestBase {

  /**
   * Tests that DatabaseSchema::getPrefixInfo() returns the right database.
   *
   * We are testing if the return array of the method
   * \Drupal\Core\Database\Driver\mysql\Schema::getPrefixInfo(). This return
   * array is a keyed array with info about amongst other things the database.
   * The other two by Drupal core supported databases do not have this variable
   * set in the return array.
   */
  public function testGetPrefixInfo() {
    $connection_info = Database::getConnectionInfo('default');
    if ($connection_info['default']['driver'] == 'mysql') {
      // Copy the default connection info to the 'extra' key.
      Database::addConnectionInfo('extra', 'default', $connection_info['default']);

      $db1_connection = Database::getConnection('default', 'default');
      $db1_schema = $db1_connection->schema();
      $db2_connection = Database::getConnection('default', 'extra');

      // Get the prefix info for the first database.
      $method = new \ReflectionMethod($db1_schema, 'getPrefixInfo');
      $method->setAccessible(TRUE);
      $db1_info = $method->invoke($db1_schema);

      // We change the database after opening the connection, so as to prevent
      // connecting to a non-existent database.
      $reflection = new \ReflectionObject($db2_connection);
      $property = $reflection->getProperty('connectionOptions');
      $property->setAccessible(TRUE);
      $connection_info['default']['database'] = 'foobar';
      $property->setValue($db2_connection, $connection_info['default']);

      // For testing purposes, we also change the database info.
      $reflection_class = new \ReflectionClass('Drupal\Core\Database\Database');
      $property = $reflection_class->getProperty('databaseInfo');
      $property->setAccessible(TRUE);
      $info = $property->getValue();
      $info['extra']['default']['database'] = 'foobar';
      $property->setValue(NULL, $info);

      $extra_info = Database::getConnectionInfo('extra');
      $this->assertSame($extra_info['default']['database'], 'foobar');
      $db2_schema = $db2_connection->schema();
      $db2_info = $method->invoke($db2_schema);

      $this->assertNotSame($db2_info['database'], $db1_info['database'], 'Each target connection has a different database.');
      $this->assertSame($db2_info['database'], 'foobar', 'The new profile has a different database.');

      Database::removeConnection('extra');
    }
  }

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net