class PreprocessPagerTest in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php \Drupal\Tests\system\Unit\Pager\PreprocessPagerTest
- 10 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 PhpunitCompatibilityTrait
- 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() {
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/pager.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 |
---|---|---|---|---|
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. | |
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 | 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. |