class PreprocessPagerTest in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php \Drupal\Tests\system\Unit\Pager\PreprocessPagerTest
Tests pager preprocessing.
@group system
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\system\Unit\Pager\PreprocessPagerTest
Expanded class hierarchy of PreprocessPagerTest
File
- core/
modules/ system/ tests/ src/ Unit/ Pager/ PreprocessPagerTest.php, line 13
Namespace
Drupal\Tests\system\Unit\PagerView source
class PreprocessPagerTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$pager_manager = $this
->getMockBuilder('Drupal\\Core\\Pager\\PagerManager')
->disableOriginalConstructor()
->getMock();
$pager = $this
->getMockBuilder('Drupal\\Core\\Pager\\Pager')
->disableOriginalConstructor()
->getMock();
$url_generator = $this
->getMockBuilder('Drupal\\Core\\Routing\\UrlGenerator')
->disableOriginalConstructor()
->getMock();
$pager
->method('getTotalPages')
->willReturn(2);
$pager
->method('getCurrentPage')
->willReturn(1);
$url_generator
->method('generateFromRoute')
->willReturn('');
$pager_manager
->method('getPager')
->willReturn($pager);
$pager_manager
->method('getUpdatedParameters')
->willReturn('');
$container = new ContainerBuilder();
$container
->set('pager.manager', $pager_manager);
$container
->set('url_generator', $url_generator);
\Drupal::setContainer($container);
}
/**
* Tests template_preprocess_pager() when an empty #quantity is passed.
*
* @covers ::template_preprocess_pager
*/
public function testQuantityNotSet() {
require_once $this->root . '/core/includes/theme.inc';
$variables = [
'pager' => [
'#element' => '',
'#parameters' => [],
'#quantity' => '',
'#route_name' => '',
'#tags' => '',
],
];
template_preprocess_pager($variables);
$this
->assertEquals([
'first',
'previous',
], array_keys($variables['items']));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
PreprocessPagerTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PreprocessPagerTest:: |
public | function | Tests template_preprocess_pager() when an empty #quantity is passed. | |
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 | 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:: |
public static | function |