public function SchedulerSetupTrait::getEntityByTitle in Scheduler 2.x
Gets an entity by title, a direct replacement of drupalGetNodeByTitle().
This allows the same test code to be run for Nodes, Media and Products.
Parameters
string $entityTypeId: The machine id of the entity type - 'node', 'media', 'commerce_product'.
string $title: The title to match with.
Return value
mixed Either a node object, media object, commerce_product object, or none.
12 calls to SchedulerSetupTrait::getEntityByTitle()
- SchedulerDefaultTimeTest::testDefaultTime in tests/
src/ Functional/ SchedulerDefaultTimeTest.php - Test the default time functionality during content creation and edit.
- SchedulerDefaultTimeTest::testDefaultWithHiddenTime in tests/
src/ Functional/ SchedulerDefaultTimeTest.php - Test that the default times are set if the form time elements are hidden.
- SchedulerFieldsDisplayTest::testHideSeconds in tests/
src/ Functional/ SchedulerFieldsDisplayTest.php - Test the option to hide the seconds on the time input fields.
- SchedulerJavascriptDefaultTimeTest::testTimeWhenSchedulingIsRequired in tests/
src/ FunctionalJavascript/ SchedulerJavascriptDefaultTimeTest.php - Test the default time functionality when scheduling dates are required.
- SchedulerMessageTest::testConfirmationMessage in tests/
src/ Functional/ SchedulerMessageTest.php - Tests the option to display or not display the confirmation message.
File
- tests/
src/ Traits/ SchedulerSetupTrait.php, line 283
Class
- SchedulerSetupTrait
- Generic setup for all Scheduler tests.
Namespace
Drupal\Tests\scheduler\TraitsCode
public function getEntityByTitle(string $entityTypeId, string $title) {
switch ($entityTypeId) {
case 'node':
return $this
->drupalGetNodeByTitle($title);
case 'media':
return $this
->getMediaItem($title);
case 'commerce_product':
return $this
->getProduct($title);
default:
// Incorrect parameter value.
throw new \Exception(sprintf('Unrecognised entityTypeId value "%s" passed to getEntityByTitle()', $entityTypeId));
}
}