class MetadataBubblingUrlGeneratorTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest
- 10 core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest
- 9 core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest
- 8.9.x core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest
Confirm that the MetadataBubblingUrlGenerator is functioning properly.
Attributes
#[CoversClass(MetadataBubblingUrlGenerator::class)]
#[Group('Render')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Routing\UrlGeneratorTest extends \Drupal\Tests\UnitTestCase
- class \Drupal\Tests\Core\Render\MetadataBubblingUrlGeneratorTest extends \Drupal\Tests\Core\Routing\UrlGeneratorTest
- class \Drupal\Tests\Core\Routing\UrlGeneratorTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of MetadataBubblingUrlGeneratorTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Render/ MetadataBubblingUrlGeneratorTest.php, line 17
Namespace
Drupal\Tests\Core\RenderView source
class MetadataBubblingUrlGeneratorTest extends UrlGeneratorTest {
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected $renderer;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->renderer = $this->createMock('\\Drupal\\Core\\Render\\RendererInterface');
$this->renderer
->expects($this->any())
->method('hasRenderContext')
->willReturn(TRUE);
$this->generator = new MetadataBubblingUrlGenerator($this->generator, $this->renderer);
}
/**
* Tests bubbling of cacheable metadata for URLs.
*
* @param bool $collect_bubbleable_metadata
* Whether bubbleable metadata should be collected.
* @param int $invocations
* The expected amount of invocations for the ::bubble() method.
* @param array $options
* The URL options.
*
* @legacy-covers ::bubble
*/
public function testUrlBubbleableMetadataBubbling($collect_bubbleable_metadata, $invocations, array $options) : void {
$this->renderer
->expects($this->exactly($invocations))
->method('render')
->willReturnCallback(function ($build) : void {
$this->assertArrayHasKey('#cache', $build);
});
$url = new Url('test_1', [], $options);
$url->setUrlGenerator($this->generator);
$url->toString($collect_bubbleable_metadata);
}
/**
* Data provider for ::testUrlBubbleableMetadataBubbling().
*/
public static function providerUrlBubbleableMetadataBubbling() : array {
return [
// No bubbling when bubbleable metadata is collected.
[
TRUE,
0,
[],
],
// Bubbling when bubbleable metadata is not collected.
[
FALSE,
1,
[],
],
];
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|---|
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | ||
| ExpectDeprecationTrait::expectDeprecation | Deprecated | public | function | Adds an expected deprecation. | |
| ExpectDeprecationTrait::regularExpressionForFormatDescription | private | function | |||
| MetadataBubblingUrlGeneratorTest::$renderer | protected | property | The renderer. | ||
| MetadataBubblingUrlGeneratorTest::providerUrlBubbleableMetadataBubbling | public static | function | Data provider for ::testUrlBubbleableMetadataBubbling(). | ||
| MetadataBubblingUrlGeneratorTest::setUp | protected | function | Overrides UrlGeneratorTest::setUp | ||
| MetadataBubblingUrlGeneratorTest::testUrlBubbleableMetadataBubbling | public | function | Tests bubbling of cacheable metadata for URLs. | ||
| 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::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::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | ||
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. | ||
| UrlGeneratorTest::$aliasManager | protected | property | The alias manager. | ||
| UrlGeneratorTest::$context | protected | property | The request context. | ||
| UrlGeneratorTest::$generator | protected | property | The URL generator to test. | ||
| UrlGeneratorTest::$processorManager | protected | property | The path processor. | ||
| UrlGeneratorTest::$provider | protected | property | The route provider. | ||
| UrlGeneratorTest::$requestStack | protected | property | The request stack. | ||
| UrlGeneratorTest::$routeProcessorManager | protected | property | The mock route processor manager. | ||
| UrlGeneratorTest::aliasManagerCallback | public | function | Return value callback for getAliasByPath() on the mock alias manager. | ||
| UrlGeneratorTest::assertGenerateFromRoute | protected | function | Asserts \Drupal\Core\Routing\UrlGenerator::generateFromRoute()'s output. | ||
| UrlGeneratorTest::providerTestAliasGenerationWithOptions | public static | function | Provides test data for testAliasGenerationWithOptions. | ||
| UrlGeneratorTest::providerTestNoPath | public static | function | Data provider for ::testNoPath(). | ||
| UrlGeneratorTest::testAbsoluteURLGeneration | public | function | Confirms that absolute URLs work with generated routes. | ||
| UrlGeneratorTest::testAbsoluteURLGenerationUsingInterfaceConstants | public | function | Confirms that absolute URLs work with generated routes using interface constants. | ||
| UrlGeneratorTest::testAliasGeneration | public | function | Confirms that generated routes will have aliased paths. | ||
| UrlGeneratorTest::testAliasGenerationUsingInterfaceConstants | public | function | Confirms that generated routes will have aliased paths using interface constants. | ||
| UrlGeneratorTest::testAliasGenerationWithOptions | public | function | Confirms that generated routes will have aliased paths with options. | ||
| UrlGeneratorTest::testAliasGenerationWithParameters | public | function | Confirms that generated routes will have aliased paths. | ||
| UrlGeneratorTest::testBaseURLGeneration | public | function | Confirms that explicitly setting the base_url works with generated routes. | ||
| UrlGeneratorTest::testGenerateWithPathProcessorChangingOptions | public | function | Tests generate with path processor changing options. | ||
| UrlGeneratorTest::testGetPathFromRouteTrailing | public | function | Tests URL generation from route with trailing start and end slashes. | ||
| UrlGeneratorTest::testGetPathFromRouteWithSubdirectory | public | function | Tests URL generation in a subdirectory. | ||
| UrlGeneratorTest::testNoPath | public | function | Tests generating a relative URL with no path. | ||
| UrlGeneratorTest::testUrlGenerationWithDisabledPathProcessing | public | function | Tests url generation with disabled path processing. | ||
| UrlGeneratorTest::testUrlGenerationWithDisabledPathProcessingByRoute | public | function | Tests url generation with disabled path processing by route. | ||
| UrlGeneratorTest::testUrlGenerationWithDisabledPathProcessingByRouteAndOptedInPathProcessing | public | function | Tests url generation with disabled path processing by route and opted in path processing. | ||
| UrlGeneratorTest::testUrlGenerationWithHttpsRequirement | public | function | Tests the 'scheme' route requirement during URL generation. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.