protected function EntityReferenceSelectionAccessTest::assertReferenceable in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php \Drupal\Tests\system\Functional\Entity\EntityReferenceSelection\EntityReferenceSelectionAccessTest::assertReferenceable()
Checks that a selection plugin returns the expected results.
Parameters
array $selection_options: An array of options as required by entity reference selection plugins.
array $tests: An array of tests to run.
string $handler_name: The name of the entity type selection handler being tested.
5 calls to EntityReferenceSelectionAccessTest::assertReferenceable()
- EntityReferenceSelectionAccessTest::testCommentHandler in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the comment-specific overrides of the entity handler.
- EntityReferenceSelectionAccessTest::testMediaHandler in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the selection handler for the media entity type.
- EntityReferenceSelectionAccessTest::testNodeHandler in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the node-specific overrides of the entity handler.
- EntityReferenceSelectionAccessTest::testTermHandler in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the term-specific overrides of the selection handler.
- EntityReferenceSelectionAccessTest::testUserHandler in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php - Tests the user-specific overrides of the entity handler.
File
- core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityReferenceSelection/ EntityReferenceSelectionAccessTest.php, line 95
Class
- EntityReferenceSelectionAccessTest
- Tests for the base handlers provided by Entity Reference.
Namespace
Drupal\Tests\system\Functional\Entity\EntityReferenceSelectionCode
protected function assertReferenceable(array $selection_options, $tests, $handler_name) {
$handler = \Drupal::service('plugin.manager.entity_reference_selection')
->getInstance($selection_options);
foreach ($tests as $test) {
foreach ($test['arguments'] as $arguments) {
$result = call_user_func_array([
$handler,
'getReferenceableEntities',
], $arguments);
$this
->assertEquals($test['result'], $result, new FormattableMarkup('Valid result set returned by @handler.', [
'@handler' => $handler_name,
]));
$result = call_user_func_array([
$handler,
'countReferenceableEntities',
], $arguments);
if (!empty($test['result'])) {
$bundle = key($test['result']);
$count = count($test['result'][$bundle]);
}
else {
$count = 0;
}
$this
->assertEquals($count, $result, new FormattableMarkup('Valid count returned by @handler.', [
'@handler' => $handler_name,
]));
}
}
}