Same name in this branch
- 10 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
- 10 core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- 10 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\pager\SqlBase @group views
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, RandomGeneratorTrait, PhpUnitWarnings
- class \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
Expanded class hierarchy of SqlBaseTest
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ pager/ SqlBaseTest.php, line 16
Namespace
Drupal\Tests\views\Unit\Plugin\pagerView source
class SqlBaseTest extends UnitTestCase {
/**
* The mock pager plugin instance.
*
* @var \Drupal\views\Plugin\views\pager\SqlBase|\PHPUnit\Framework\MockObject\MockObject
*/
protected $pager;
/**
* The mock view instance.
*
* @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject
*/
protected $view;
/**
* The mock display plugin instance.
*
* @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit\Framework\MockObject\MockObject
*/
protected $display;
protected function setUp() : void {
parent::setUp();
$this->pager = $this
->getMockBuilder('Drupal\\views\\Plugin\\views\\pager\\SqlBase')
->disableOriginalConstructor()
->getMockForAbstractClass();
/** @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject $view */
$this->view = $this
->getMockBuilder('Drupal\\views\\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$query = $this
->getMockBuilder(QueryPluginBase::class)
->disableOriginalConstructor()
->getMock();
$this->view->query = $query;
$this->display = $this
->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$container = new ContainerBuilder();
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
}
/**
* Tests the query() method.
*
* @see \Drupal\views\Plugin\views\pager\SqlBase::query()
*/
public function testQuery() {
$request = new Request([
'items_per_page' => 'All',
]);
$this->view
->expects($this
->any())
->method('getRequest')
->willReturn($request);
$options = [];
$this->pager
->init($this->view, $this->display, $options);
$this->pager
->query();
$this
->assertSame(10, $this->pager->options['items_per_page']);
$options = [
'expose' => [
'items_per_page' => TRUE,
'items_per_page_options_all' => TRUE,
],
];
$this->pager
->init($this->view, $this->display, $options);
$this->pager
->query();
$this
->assertSame(0, $this->pager->options['items_per_page']);
}
}
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. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
SqlBaseTest:: |
protected | property | The mock display plugin instance. | |
SqlBaseTest:: |
protected | property | The mock pager plugin instance. | |
SqlBaseTest:: |
protected | property | The mock view instance. | |
SqlBaseTest:: |
protected | function |
Overrides UnitTestCase:: |
|
SqlBaseTest:: |
public | function | Tests the query() method. | |
UnitTestCase:: |
protected | property | The app root. | 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:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public static | function | ||
UnitTestCase:: |
public | function |