class FiberPlaceholderTest
Same name in other branches
- 10 core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php \Drupal\Tests\big_pipe\Unit\Render\FiberPlaceholderTest
@coversDefaultClass \Drupal\big_pipe\Render\BigPipe @group big_pipe
Hierarchy
- class \Drupal\Tests\big_pipe\Unit\Render\FiberPlaceholderTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of FiberPlaceholderTest
File
-
core/
modules/ big_pipe/ tests/ src/ Unit/ Render/ FiberPlaceholderTest.php, line 33
Namespace
Drupal\Tests\big_pipe\Unit\RenderView source
class FiberPlaceholderTest extends UnitTestCase {
/**
* @covers \Drupal\big_pipe\Render\BigPipe::sendPlaceholders
*/
public function testLongPlaceholderFiberSuspendingLoop() : void {
$request_stack = $this->prophesize(RequestStack::class);
$request_stack->getMainRequest()
->willReturn(new Request());
$request_stack->getCurrentRequest()
->willReturn(new Request());
$callableResolver = $this->prophesize(CallableResolver::class);
$callableResolver->getCallableFromDefinition(Argument::any())
->willReturn([
TurtleLazyBuilder::class,
'turtle',
]);
$renderer = new Renderer($callableResolver->reveal(), $this->prophesize(ThemeManagerInterface::class)
->reveal(), $this->prophesize(ElementInfoManagerInterface::class)
->reveal(), $this->prophesize(PlaceholderGeneratorInterface::class)
->reveal(), $this->prophesize(RenderCacheInterface::class)
->reveal(), $request_stack->reveal(), [
'required_cache_contexts' => [
'languages:language_interface',
'theme',
],
]);
$session = $this->prophesize(SessionInterface::class);
$session->start()
->willReturn(TRUE);
$bigpipe = new BigPipe($renderer, $session->reveal(), $request_stack->reveal(), $this->prophesize(HttpKernelInterface::class)
->reveal(), $this->createMock(EventDispatcherInterface::class), $this->prophesize(ConfigFactoryInterface::class)
->reveal(), $this->prophesize(MessengerInterface::class)
->reveal(), $this->prophesize(RequestContext::class)
->reveal(), $this->prophesize(LoggerInterface::class)
->reveal());
$response = new BigPipeResponse(new HtmlResponse());
$attachments = [
'library' => [],
'drupalSettings' => [
'ajaxPageState' => [],
],
'big_pipe_placeholders' => [
// cspell:disable-next-line
'callback=%5CDrupal%5CTests%5Cbig_pipe%5CUnit%5CRender%5CTurtleLazyBuilder%3A%3Aturtle&&token=uhKFNfT4eF449_W-kDQX8E5z4yHyt0-nSHUlwaGAQeU' => [
'#lazy_builder' => [
'\\Drupal\\Tests\\big_pipe\\Unit\\Render\\TurtleLazyBuilder::turtle',
[],
],
],
],
];
$response->setAttachments($attachments);
// Construct minimal HTML response.
// cspell:disable-next-line
$content = '<html><body><span data-big-pipe-placeholder-id="callback=%5CDrupal%5CTests%5Cbig_pipe%5CUnit%5CRender%5CTurtleLazyBuilder%3A%3Aturtle&&token=uhKFNfT4eF449_W-kDQX8E5z4yHyt0-nSHUlwaGAQeU"></body></html>';
$response->setContent($content);
// Capture the result to avoid PHPUnit complaining.
ob_start();
$fiber = new \Fiber(function () use ($bigpipe, $response) {
$bigpipe->sendContent($response);
});
$fiber->start();
$this->assertFalse($fiber->isTerminated(), 'Placeholder fibers with long execution time supposed to return control before terminating');
ob_get_clean();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
ExpectDeprecationTrait::getCallableName | private static | function | Returns a callable as a string suitable for inclusion in a message. | |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
FiberPlaceholderTest::testLongPlaceholderFiberSuspendingLoop | public | function | @covers \Drupal\big_pipe\Render\BigPipe::sendPlaceholders | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
UnitTestCase::$root | protected | property | The app root. | |
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase::setUp | protected | function | 358 | |
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.