Drupal 8  8.0.2
LinkGeneratorTest Class Reference
Inheritance diagram for LinkGeneratorTest:

Public Member Functions

 providerTestGenerateHrefs ()
 
 testGenerateHrefs ($route_name, array $parameters, $absolute, $expected_url)
 
 testGenerate ()
 
 testGenerateExternal ()
 
 testGenerateUrlWithQuotes ()
 
 testGenerateAttributes ()
 
 testGenerateQuery ()
 
 testGenerateParametersAsQuery ()
 
 testGenerateOptions ()
 
 testGenerateXss ()
 
 testGenerateWithHtml ()
 
 testGenerateActive ()
 
 testGenerateBubbleableMetadata ()
 
- Public Member Functions inherited from UnitTestCase
 randomMachineName ($length=8)
 
 getConfigFactoryStub (array $configs=array())
 
 getConfigStorageStub (array $configs)
 
 getStringTranslationStub ()
 

Static Public Member Functions

static assertLink (array $properties, MarkupInterface $html, $count=1)
 

Protected Member Functions

 setUp ()
 
 assertNoXPathResults ($query, $html)
 
- Protected Member Functions inherited from UnitTestCase
 setUp ()
 
 getRandomGenerator ()
 
 assertArrayEquals (array $expected, array $actual, $message=NULL)
 
 getBlockMockWithMachineName ($machine_name)
 
 getContainerWithCacheTagsInvalidator (CacheTagsInvalidatorInterface $cache_tags_validator)
 
 getClassResolverStub ()
 

Protected Attributes

 $linkGenerator
 
 $urlGenerator
 
 $moduleHandler
 
 $renderer
 
 $urlAssembler
 
 $defaultOptions
 
- Protected Attributes inherited from UnitTestCase
 $randomGenerator
 
 $root
 

Detailed Description

Utility

Member Function Documentation

static assertLink ( array  $properties,
MarkupInterface  $html,
  $count = 1 
)
static

Checks that a link with certain properties exists in a given HTML snippet.

Parameters
array$propertiesAn associative array of link properties, with the following keys:
  • attributes: optional array of HTML attributes that should be present.
  • content: optional link content.
\Drupal\Component\Render\MarkupInterface$htmlThe HTML to check.
int$countHow many times the link should be present in the HTML. Defaults to 1.

Referenced by LinkGeneratorTest\testGenerate(), LinkGeneratorTest\testGenerateActive(), LinkGeneratorTest\testGenerateAttributes(), LinkGeneratorTest\testGenerateExternal(), LinkGeneratorTest\testGenerateHrefs(), LinkGeneratorTest\testGenerateOptions(), LinkGeneratorTest\testGenerateParametersAsQuery(), LinkGeneratorTest\testGenerateQuery(), LinkGeneratorTest\testGenerateUrlWithQuotes(), and LinkGeneratorTest\testGenerateWithHtml().

Here is the caller graph for this function:

assertNoXPathResults (   $query,
  $html 
)
protected

Checks that the given XPath query has no results in a given HTML snippet.

Parameters
string$queryThe XPath query to execute.
string$htmlThe HTML snippet to check.
Returns
int The number of results that are found.

Referenced by LinkGeneratorTest\testGenerateActive(), and LinkGeneratorTest\testGenerateXss().

Here is the caller graph for this function:

providerTestGenerateHrefs ( )

Provides test data for testing the link method.

See Also
::testGenerateHrefs()
Returns
array Returns some test data.
setUp ( )
protected

{}

References Drupal\linkGenerator(), Drupal\moduleHandler(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerate ( )

Tests the generate() method with a route.

::generate

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), Drupal\moduleHandler(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateActive ( )

Tests the active class on the link method.

See Also
::generate()

References LinkGeneratorTest\assertLink(), LinkGeneratorTest\assertNoXPathResults(), Drupal\linkGenerator(), Drupal\moduleHandler(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateAttributes ( )

Tests the link method with additional attributes.

See Also
::generate()

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateBubbleableMetadata ( )

Tests the LinkGenerator's support for collecting bubbleable metadata.

See Also
::generate()
::generateFromLink()

References Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateExternal ( )

Tests the generate() method with an external URL.

The set_active_class option is set to TRUE to ensure this does not cause an error together with an external URL.

::generate

References LinkGeneratorTest\assertLink(), Url\fromUri(), Drupal\linkGenerator(), Drupal\moduleHandler(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateHrefs (   $route_name,
array  $parameters,
  $absolute,
  $expected_url 
)

Tests the link method with certain hrefs.

See Also
::generate()
::providerTestGenerate()

providerTestGenerateHrefs

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), Drupal\moduleHandler(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateOptions ( )

Tests the link method with arbitrary passed options.

See Also
::generate()

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateParametersAsQuery ( )

Tests the link method with passed query options via parameters.

See Also
::generate()

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateQuery ( )

Tests the link method with passed query options.

See Also
::generate()

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateUrlWithQuotes ( )

Tests the generate() method with a url containing double quotes.

::generate

References LinkGeneratorTest\assertLink(), Url\fromUserInput(), Drupal\linkGenerator(), Drupal\setContainer(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateWithHtml ( )

Tests the link method with html.

See Also
::generate()

References LinkGeneratorTest\assertLink(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

testGenerateXss ( )

Tests the link method with a script tab.

See Also
::generate()

References LinkGeneratorTest\assertNoXPathResults(), Drupal\linkGenerator(), and Drupal\urlGenerator().

Here is the call graph for this function:

Field Documentation

$defaultOptions
protected
Initial value:
= array(
'query' => array(),
'language' => NULL,
'set_active_class' => FALSE,
'absolute' => FALSE,
)

Contains the LinkGenerator default options.


The documentation for this class was generated from the following file: