class ParseEntityIdsTest in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x tests/src/Unit/LinkManipulator/ParseEntityIdsTest.php \Drupal\Tests\fillpdf\Unit\LinkManipulator\ParseEntityIdsTest
@coversDefaultClass \Drupal\fillpdf\Service\FillPdfLinkManipulator
@group fillpdf
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\fillpdf\Unit\LinkManipulator\ParseEntityIdsTest
Expanded class hierarchy of ParseEntityIdsTest
File
- tests/
src/ Unit/ LinkManipulator/ ParseEntityIdsTest.php, line 13
Namespace
Drupal\Tests\fillpdf\Unit\LinkManipulatorView source
class ParseEntityIdsTest extends UnitTestCase {
/**
* Tests parsing entity IDs from query parameters and back.
*
* @param array $input
* Input query parameters.
* @param array $expected
* Expected output query parameters.
*
* @covers ::parseEntityIds
* @covers ::prepareEntityIds
*
* @dataProvider providerTestEntityIds
*/
public function testEntityIds(array $input, array $expected) {
// Parse query parameters, creating a context.
$context = FillPdfLinkManipulator::parseEntityIds($input);
// Turn the context back into query parameters.
$actual = FillPdfLinkManipulator::prepareEntityIds($context);
$this
->assertEquals($expected, $actual);
}
/**
* Data provider for testEntityIds().
*
* @return array[]
* Array of test cases.
*/
public function providerTestEntityIds() {
$cases = [];
$cases[0] = [
[],
[],
];
$cases[1] = [
[
'entity_ids' => [
'node:1',
],
],
[
'entity_id' => 'node:1',
],
];
$cases[2] = [
[
'entity_ids' => [
'term:5',
],
],
[
'entity_id' => 'term:5',
],
];
$cases[3] = [
[
'entity_ids' => [
'node:1',
'node:2',
],
],
[
'entity_ids' => [
'node:1',
'node:2',
],
],
];
$cases[4] = [
[
'entity_ids' => [
'node:1',
'node:1',
],
],
[
'entity_id' => 'node:1',
],
];
$cases[5] = [
[
'entity_ids' => [
'user:3',
'term:5',
],
],
[
'entity_ids' => [
'user:3',
'term:5',
],
],
];
$cases[6] = [
[
'entity_ids' => [],
'entity_type' => '',
'entity_id' => 1,
],
[
'entity_id' => 'node:1',
],
];
$cases[7] = [
[
'entity_id' => 1,
],
[
'entity_id' => 'node:1',
],
];
$cases[8] = [
[
'entity_type' => 'term',
'entity_id' => 5,
],
[
'entity_id' => 'term:5',
],
];
$cases[9] = [
[
'entity_ids' => [
'1',
],
'entity_type' => 'node',
],
[
'entity_id' => 'node:1',
],
];
$cases[10] = [
[
'entity_ids' => [
'1',
'2',
],
'entity_type' => 'node',
],
[
'entity_ids' => [
'node:1',
'node:2',
],
],
];
$cases[11] = [
[
'entity_ids' => [
'3',
'4',
],
'entity_type' => 'user',
],
[
'entity_ids' => [
'user:3',
'user:4',
],
],
];
$cases[12] = [
[
'entity_ids' => [
'3',
'4',
],
'entity_type' => 'user',
'entity_id' => '5',
],
[
'entity_id' => 'user:5',
],
];
return $cases;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParseEntityIdsTest:: |
public | function | Data provider for testEntityIds(). | |
ParseEntityIdsTest:: |
public | function | Tests parsing entity IDs from query parameters and back. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |