class ParseBooleanFlagsTest in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x tests/src/Unit/LinkManipulator/ParseBooleanFlagsTest.php \Drupal\Tests\fillpdf\Unit\LinkManipulator\ParseBooleanFlagsTest
@coversDefaultClass \Drupal\fillpdf\Service\FillPdfLinkManipulator
@group fillpdf
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\fillpdf\Unit\LinkManipulator\ParseBooleanFlagsTest
Expanded class hierarchy of ParseBooleanFlagsTest
File
- tests/
src/ Unit/ LinkManipulator/ ParseBooleanFlagsTest.php, line 13
Namespace
Drupal\Tests\fillpdf\Unit\LinkManipulatorView source
class ParseBooleanFlagsTest extends UnitTestCase {
/**
* Tests &sample=, &download= and &flatten= query parameters.
*
* @covers ::parseBooleanFlags
*
* @dataProvider providerTestBooleanFlags
*/
public function testBooleanFlags($input, $expected) {
$context = FillPdfLinkManipulator::parseBooleanFlags($this
->buildQuery($input));
$this
->assertEquals(is_null($expected) ? FALSE : $expected, $context['sample']);
$this
->assertEquals(is_null($expected) ? FALSE : $expected, $context['force_download']);
$this
->assertEquals(is_null($expected) ? TRUE : $expected, $context['flatten']);
}
/**
* Input helper for testBooleanFlags().
*/
public function buildQuery($input) {
return [
'fid' => 1,
'entity_type' => 'node',
'entity_id' => 1,
'sample' => $input,
'download' => $input,
'flatten' => $input,
];
}
/**
* Data provider for testBooleanFlags().
*/
public function providerTestBooleanFlags() {
return [
[
'1',
TRUE,
],
[
'true',
TRUE,
],
[
'True',
TRUE,
],
[
'TRUE',
TRUE,
],
[
'on',
TRUE,
],
[
'On',
TRUE,
],
[
'ON',
TRUE,
],
[
'yes',
TRUE,
],
[
'Yes',
TRUE,
],
[
'YES',
TRUE,
],
[
'0',
FALSE,
],
[
'false',
FALSE,
],
[
'False',
FALSE,
],
[
'FALSE',
FALSE,
],
[
'off',
FALSE,
],
[
'Off',
FALSE,
],
[
'OFF',
FALSE,
],
[
'no',
FALSE,
],
[
'No',
FALSE,
],
[
'NO',
FALSE,
],
// These three are important, so should always be obeyed:
[
'',
NULL,
],
[
'foo',
NULL,
],
[
'bar',
NULL,
],
// The following ones are less fortunate, so may be refactored:
[
'-1',
NULL,
],
[
'2',
NULL,
],
[
'y',
NULL,
],
[
'Y',
NULL,
],
[
'n',
NULL,
],
[
'N',
NULL,
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParseBooleanFlagsTest:: |
public | function | Input helper for testBooleanFlags(). | |
ParseBooleanFlagsTest:: |
public | function | Data provider for testBooleanFlags(). | |
ParseBooleanFlagsTest:: |
public | function | Tests &sample=, &download= and &flatten= query parameters. | |
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 |