protected function CartLinksTest::createCartLinksPage in Ubercart 8.4
Create a page with Cart Links in the body.
Parameters
array $links: Array of Cart Links to appear on page.
Return value
\Drupal\node\NodeInterface The created node entity.
6 calls to CartLinksTest::createCartLinksPage()
- CartLinksTest::testCartLinksAllowEmptying in uc_cart_links/
src/ Tests/ CartLinksTest.php - Tests Cart Links cart empty action.
- CartLinksTest::testCartLinksBasicFunctionality in uc_cart_links/
src/ Tests/ CartLinksTest.php - Tests Cart Links on a page under a variety of conditions.
- CartLinksTest::testCartLinksMessages in uc_cart_links/
src/ Tests/ CartLinksTest.php - Tests Cart Links custom messages.
- CartLinksTest::testCartLinksProductActionMessage in uc_cart_links/
src/ Tests/ CartLinksTest.php - Tests Cart Links product action messages.
- CartLinksTest::testCartLinksRestrictions in uc_cart_links/
src/ Tests/ CartLinksTest.php - Tests Cart Links restrictions.
File
- uc_cart_links/
src/ Tests/ CartLinksTest.php, line 695
Class
- CartLinksTest
- Tests the Cart Links functionality.
Namespace
Drupal\uc_cart_links\TestsCode
protected function createCartLinksPage(array $links = []) {
$item_list = [
'#theme' => 'links',
'#links' => [],
];
if (!empty($links)) {
$i = 0;
foreach ($links as $link) {
$item_list['#links'][] = [
'title' => t('Cart Link #@num', [
'@num' => $i++,
]),
'url' => Url::fromUri('base:' . $link),
];
}
}
$page = [
'type' => 'page',
// This is default anyway ...
'body' => [
0 => [
'value' => !empty($links) ? \Drupal::service('renderer')
->renderPlain($item_list) : $this
->randomMachineName(128),
'format' => 'full_html',
],
],
'promote' => 0,
];
return $this
->drupalCreateNode($page);
}