class QueueSerializationTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php \Drupal\KernelTests\Core\Queue\QueueSerializationTest
- 10 core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php \Drupal\KernelTests\Core\Queue\QueueSerializationTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Queue/QueueSerializationTest.php \Drupal\KernelTests\Core\Queue\QueueSerializationTest
Tests serializing a form with an injected DatabaseQueue instance.
@group Queue
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Queue\QueueSerializationTest implements \Drupal\Core\Form\FormInterface uses \Drupal\Core\DependencyInjection\DependencySerializationTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of QueueSerializationTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Queue/ QueueSerializationTest.php, line 17
Namespace
Drupal\KernelTests\Core\QueueView source
class QueueSerializationTest extends KernelTestBase implements FormInterface {
use DependencySerializationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'system',
'user',
];
/**
* @var \Drupal\Core\Queue\DatabaseQueue
*/
protected $queue;
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'queue_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() : void {
parent::setUp();
$this->installSchema('system', [
'sequences',
]);
$this->installEntitySchema('user');
// We only need a valid \Drupal\Core\Queue\DatabaseQueue object here, not
// an actual valid queue.
$this->queue = \Drupal::service('queue.database')->get('fake_a_queue');
$test_user = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
]);
$test_user->save();
\Drupal::service('current_user')->setAccount($test_user);
}
/**
* Tests queue injection serialization.
*/
public function testQueueSerialization() {
$form_state = new FormState();
$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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.