class SqlBaseTest
Same name in this branch
- main core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- main core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
- 11.x core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- 11.x core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
- 10 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
- 10 core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- 10 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
- 9 core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest
- 9 core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- 9 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
- 8.9.x core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\SqlBaseTest
- 8.9.x core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\SqlBaseTest
Tests Drupal\views\Plugin\views\pager\SqlBase.
Attributes
#[CoversClass(SqlBase::class)]
#[Group('views')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Unit\Plugin\pager\SqlBaseTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of SqlBaseTest
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ pager/ SqlBaseTest.php, line 22
Namespace
Drupal\Tests\views\Unit\Plugin\pagerView source
class SqlBaseTest extends UnitTestCase {
/**
* The mock pager plugin instance.
*
* @var \Drupal\views\Plugin\views\pager\SqlBase
*/
protected $pager;
/**
* The mock view instance.
*
* @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\Stub
*/
protected $view;
/**
* The mock display plugin instance.
*
* @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit\Framework\MockObject\Stub
*/
protected $display;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->pager = new StubSqlBase([], 'test_plugin', [], $this->createStub(PagerManagerInterface::class), $this->createStub(PagerParametersInterface::class));
$this->view = $this->createStub(ViewExecutable::class);
$query = $this->createStub(QueryPluginBase::class);
$this->view->query = $query;
$this->display = $this->createStub(DisplayPluginBase::class);
$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() : void {
$request = new Request([
'items_per_page' => 'All',
]);
$this->view
->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
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
|---|---|---|---|---|---|
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 | |
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | ||
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | ||
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | ||
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | ||
| SqlBaseTest::$display | protected | property | The mock display plugin instance. | ||
| SqlBaseTest::$pager | protected | property | The mock pager plugin instance. | ||
| SqlBaseTest::$view | protected | property | The mock view instance. | ||
| SqlBaseTest::setUp | protected | function | Overrides UnitTestCase::setUp | ||
| SqlBaseTest::testQuery | public | function | Tests the query() method. | ||
| UnitTestCase::$root | protected | property | The app root. | ||
| UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | ||
| UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | ||
| UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | ||
| UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | ||
| UnitTestCase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | ||
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.