RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð ....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 104.225.223.251  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux agtdemo03 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /srv/wp/ciieduconnect.in/www/modules/contrib/token/tests/src/Functional/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /srv/wp/ciieduconnect.in/www/modules/contrib/token/tests/src/Functional/TokenMenuTest.php
<?php

namespace Drupal\Tests\token\Functional;

use Behat\Mink\Element\NodeElement;
use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Entity\Menu;

/**
 * Tests menu tokens.
 *
 * @group token
 */
class TokenMenuTest extends TokenTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'menu_ui',
    'node',
    'block',
    'language',
    'block_content',
    'content_translation',
  ];

  function testMenuTokens() {
    // Make sure we have a body field on the node type.
    $this->drupalCreateContentType(['type' => 'page']);
    // Add a menu.
    $menu = Menu::create([
      'id' => 'main-menu',
      'label' => 'Main menu',
      'description' => 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.',
    ]);
    $menu->save();

    // Place the menu block.
    $this->drupalPlaceBlock('system_menu_block:main-menu');

    // Add a root link.
    /** @var \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $root_link */
    $root_link = MenuLinkContent::create([
      'link' => ['uri' => 'internal:/admin'],
      'title' => 'Administration',
      'menu_name' => 'main-menu',
    ]);
    $root_link->save();

    // Add another link with the root link as the parent.
    /** @var \Drupal\menu_link_content\Plugin\Menu\MenuLinkContent $parent_link */
    $parent_link = MenuLinkContent::create([
      'link' => ['uri' => 'internal:/admin/config'],
      'title' => 'Configuration',
      'menu_name' => 'main-menu',
      'parent' => $root_link->getPluginId(),
    ]);
    $parent_link->save();

    // Test menu link tokens.
    $tokens = [
      'id' => $parent_link->getPluginId(),
      'title' => 'Configuration',
      'menu' => 'Main menu',
      'menu:name' => 'Main menu',
      'menu:machine-name' => $menu->id(),
      'menu:description' => 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.',
      'menu:menu-link-count' => '2',
      'menu:edit-url' => Url::fromRoute('entity.menu.edit_form', ['menu' => 'main-menu'], ['absolute' => TRUE])->toString(),
      'url' => Url::fromRoute('system.admin_config', [], ['absolute' => TRUE])->toString(),
      'url:absolute' => Url::fromRoute('system.admin_config', [], ['absolute' => TRUE])->toString(),
      'url:relative' => Url::fromRoute('system.admin_config', [], ['absolute' => FALSE])->toString(),
      'url:path' => '/admin/config',
      'url:alias' => '/admin/config',
      'edit-url' => Url::fromRoute('entity.menu_link_content.canonical', ['menu_link_content' => $parent_link->id()], ['absolute' => TRUE])->toString(),
      'parent' => 'Administration',
      'parent:id' => $root_link->getPluginId(),
      'parent:title' => 'Administration',
      'parent:menu' => 'Main menu',
      'parent:parent' => NULL,
      'parents' => 'Administration',
      'parents:count' => 1,
      'parents:keys' => $root_link->getPluginId(),
      'root' => 'Administration',
      'root:id' => $root_link->getPluginId(),
      'root:parent' => NULL,
      'root:root' => NULL,
    ];
    $this->assertTokens('menu-link', ['menu-link' => $parent_link], $tokens);

    // Add a node.
    $node = $this->drupalCreateNode();

    // Allow main menu for this node type.
    //$this->config('menu.entity.node.' . $node->getType())->set('available_menus', ['main-menu'])->save();

    // Add a node menu link.
    /** @var \Drupal\menu_link_content\MenuLinkContentInterface $node_link */
    $node_link = MenuLinkContent::create([
      'link' => ['uri' => 'entity:node/' . $node->id()],
      'title' => 'Node link',
      'parent' => $parent_link->getPluginId(),
      'menu_name' => 'main-menu',
    ]);
    $node_link->save();

    // Test [node:menu] tokens.
    $tokens = [
      'menu-link' => 'Node link',
      'menu-link:id' => $node_link->getPluginId(),
      'menu-link:title' => 'Node link',
      'menu-link:menu' => 'Main menu',
      'menu-link:url' => $node->toUrl('canonical', ['absolute' => TRUE])->toString(),
      'menu-link:url:path' => '/node/' . $node->id(),
      'menu-link:edit-url' => $node_link->toUrl('edit-form', ['absolute' => TRUE])->toString(),
      'menu-link:parent' => 'Configuration',
      'menu-link:parent:id' => $parent_link->getPluginId(),
      'menu-link:parents' => 'Administration, Configuration',
      'menu-link:parents:count' => 2,
      'menu-link:parents:keys' => $root_link->getPluginId() . ', ' . $parent_link->getPluginId(),
      'menu-link:root' => 'Administration',
      'menu-link:root:id' => $root_link->getPluginId(),
    ];
    $this->assertTokens('node', ['node' => $node], $tokens);

    // Reload the node which will not have $node->menu defined and re-test.
    $loaded_node = Node::load($node->id());
    $this->assertTokens('node', ['node' => $loaded_node], $tokens);

    // Regression test for http://drupal.org/node/1317926 to ensure the
    // original node object is not changed when calling menu_node_prepare().
    $this->assertTrue(!isset($loaded_node->menu), 'The $node->menu property was not modified during token replacement.', 'Regression');

    // Now add a node with a menu-link from the UI and ensure it works.
    $this->drupalLogin($this->drupalCreateUser([
      'create page content',
      'edit any page content',
      'administer menu',
      'administer nodes',
      'administer content types',
      'access administration pages',
    ]));
    // Setup node type menu options.
    $edit = [
      'menu_options[main-menu]' => 1,
      'menu_options[main]' => 1,
      'menu_parent' => 'main-menu:',
    ];
    $this->drupalGet('admin/structure/types/manage/page');
    $this->submitForm($edit, 'Save content type');

    // Use a menu-link token in the body.
    $this->drupalGet('node/add/page');
    $this->submitForm([
      // This should get replaced on save.
      // @see token_module_test_node_presave()
      'title[0][value]' => 'Node menu title test',
      'body[0][value]' => 'This is a [node:menu-link:title] token to the menu link title',
      'menu[enabled]' => 1,
      'menu[title]' => 'Test preview',
    ], 'Save');
    $node = $this->drupalGetNodeByTitle('Node menu title test');
    $this->assertEquals('This is a Test preview token to the menu link title', $node->body->value);

    // Disable the menu link, save the node and verify that the menu link is
    // no longer displayed.
    $link = menu_ui_get_menu_link_defaults($node);
    $this->drupalGet('admin/structure/menu/manage/main-menu');
    $this->submitForm(['links[menu_plugin_id:' . $link['id'] . '][enabled]' => FALSE], 'Save');
    $this->assertSession()->pageTextContains('Menu Main menu has been updated.');
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm([], 'Save');
    $this->assertSession()->linkNotExists('Test preview');

    // Now test a parent link and token.
    $this->drupalGet('node/add/page');
    // Make sure that the previous node save didn't result in two menu-links
    // being created by the computed menu-link ER field.
    // @see token_entity_base_field_info()
    // @see token_node_menu_link_submit()
    $selects = $this->cssSelect('select[name="menu[menu_parent]"]');
    $select = reset($selects);
    $options = $select->findAll('css', 'option');
    // Filter to items with title containing 'Test preview'.
    $options = array_filter($options, function (NodeElement $element) {
      return strpos($element->getText(), 'Test preview') !== FALSE;
    });
    $this->assertCount(1, $options);
    $this->submitForm([
      'title[0][value]' => 'Node menu title parent path test',
      'body[0][value]' => 'This is a [node:menu-link:parent:url:path] token to the menu link parent',
      'menu[enabled]' => 1,
      'menu[title]' => 'Child link',
      'menu[menu_parent]' => 'main-menu:' . $parent_link->getPluginId(),
    ], 'Save');
    $node = $this->drupalGetNodeByTitle('Node menu title parent path test');
    $this->assertEquals('This is a /admin/config token to the menu link parent', $node->body->value);

    // Now edit the node and update the parent and title.
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm([
      'menu[menu_parent]' => 'main-menu:' . $node_link->getPluginId(),
      'title[0][value]' => 'Node menu title edit parent path test',
      'body[0][value]' => 'This is a [node:menu-link:parent:url:path] token to the menu link parent',
    ], 'Save');
    $node = $this->drupalGetNodeByTitle('Node menu title edit parent path test', TRUE);
    $this->assertEquals(sprintf('This is a /node/%d token to the menu link parent', $loaded_node->id()), $node->body->value);

    // Make sure that the previous node edit didn't result in two menu-links
    // being created by the computed menu-link ER field.
    // @see token_entity_base_field_info()
    // @see token_node_menu_link_submit()
    $this->drupalGet('node/add/page');
    $selects = $this->cssSelect('select[name="menu[menu_parent]"]');
    $select = reset($selects);
    $options = $select->findAll('css', 'option');
    // Filter to items with title containing 'Test preview'.
    $options = array_filter($options, function (NodeElement $item) {
      return strpos($item->getText(), 'Child link') !== FALSE;
    });
    $this->assertCount(1, $options);

    // Now add a new node with no menu.
    $this->drupalGet('node/add/page');
    $this->submitForm([
      'title[0][value]' => 'Node menu adding menu later test',
      'body[0][value]' => 'Going to add a menu link on edit',
      'menu[enabled]' => 0,
    ], 'Save');
    $node = $this->drupalGetNodeByTitle('Node menu adding menu later test');
    // Now edit it and add a menu item.
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm([
      'title[0][value]' => 'Node menu adding menu later test',
      'body[0][value]' => 'This is a [node:menu-link:parent:url:path] token to the menu link parent',
      'menu[enabled]' => 1,
      'menu[title]' => 'Child link',
      'menu[menu_parent]' => 'main-menu:' . $parent_link->getPluginId(),
    ], 'Save');
    $node = $this->drupalGetNodeByTitle('Node menu adding menu later test', TRUE);
    $this->assertEquals('This is a /admin/config token to the menu link parent', $node->body->value);
    // And make sure the menu link exists with the right URI.
    $link = menu_ui_get_menu_link_defaults($node);
    $this->assertNotEmpty($link['entity_id']);
    $query = \Drupal::entityQuery('menu_link_content')
      ->condition('link.uri', 'entity:node/' . $node->id())
      ->accessCheck(TRUE)
      ->sort('id', 'ASC')
      ->range(0, 1);
    $result = $query->execute();
    $this->assertNotEmpty($result);

    // Create a node with a menu link and create 2 menu links linking to this
    // node after. Verify that the menu link provided by the node has priority.
    $node_title = $this->randomMachineName();
    $edit = [
      'title[0][value]' => $node_title,
      'menu[enabled]' => 1,
      'menu[title]' => 'menu link provided by node',
    ];
    $this->drupalGet('node/add/page');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('page ' . $node_title . ' has been created');
    $node = $this->drupalGetNodeByTitle($node_title);

    $menu_ui_link1 = MenuLinkContent::create([
      'link' => ['uri' => 'entity:node/' . $node->id()],
      'title' => 'menu link 1 provided by menu ui',
      'menu_name' => 'main-menu',
    ]);
    $menu_ui_link1->save();

    $menu_ui_link2 = MenuLinkContent::create([
      'link' => ['uri' => 'entity:node/' . $node->id()],
      'title' => 'menu link 2 provided by menu ui',
      'menu_name' => 'main-menu',
    ]);
    $menu_ui_link2->save();

    $tokens = [
      'menu-link' => 'menu link provided by node',
      'menu-link:title' => 'menu link provided by node',
    ];
    $this->assertTokens('node', ['node' => $node], $tokens);
  }

  /**
   * Tests that the module doesn't affect integrity of the menu, when
   * translating them and that menu links tokens are correct.
   */
  function testMultilingualMenu() {
    // Place the menu block.
    $this->drupalPlaceBlock('system_menu_block:main');

    // Add a second language.
    $language = ConfigurableLanguage::create([
      'id' => 'de',
      'label' => 'German',
    ]);
    $language->save();

    // Create the article content type.
    $node_type = NodeType::create([
      'type' => 'article',
      'name' => 'Article',
    ]);
    $node_type->save();

    $permissions = [
      'access administration pages',
      'administer content translation',
      'administer content types',
      'administer languages',
      'create content translations',
      'create article content',
      'edit any article content',
      'translate any entity',
      'administer menu',
    ];
    $this->drupalLogin($this->drupalCreateUser($permissions));

    // Enable translation for articles and menu links.
    $this->drupalGet('admin/config/regional/content-language');
    $edit = [
      'entity_types[node]' => TRUE,
      'entity_types[menu_link_content]' => TRUE,
      'settings[node][article][translatable]' => TRUE,
      'settings[node][article][fields][title]' => TRUE,
      'settings[menu_link_content][menu_link_content][translatable]' => TRUE,
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->assertSession()->pageTextContains('Settings successfully updated.');

    // Create an english node with an english menu.
    $this->drupalGet('/node/add/article');
    $edit = [
      'title[0][value]' => 'English test node with menu',
      'menu[enabled]' => TRUE,
      'menu[title]' => 'English menu title',
    ];
    $this->drupalGet('/node/add/article');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('English test node with menu has been created.');

    // Add a german translation.
    $this->drupalGet('node/1/translations');
    $this->clickLink('Add');
    $edit = [
      'title[0][value]' => 'German test node with menu',
      'menu[enabled]' => TRUE,
      'menu[title]' => 'German menu title',
    ];
    $this->submitForm($edit, 'Save (this translation)');
    $this->assertSession()->pageTextContains('German test node with menu has been updated.');

    // Verify that the menu links are correct.
    $this->drupalGet('node/1');
    $this->assertSession()->linkExists('English menu title');
    $this->drupalGet('de/node/1');
    $this->assertSession()->linkExists('German menu title');

    // Verify that tokens are correct.
    $node = Node::load(1);
    $this->assertTokens('node', ['node' => $node], ['menu-link' => 'English menu title']);
    $this->assertTokens('node', ['node' => $node], [
      'menu-link' => 'German menu title',
      'menu-link:title' => 'German menu title',
    ], ['langcode' => 'de']);

    // Get the menu link and create a child menu link to assert parent and root
    // tokens.
    $url = $node->toUrl();
    /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    $links = $menu_link_manager->loadLinksByRoute($url->getRouteName(), $url->getRouteParameters());
    $link = reset($links);

    $base_options = [
      'provider' => 'menu_test',
      'menu_name' => 'menu_test',
    ];
    $child_1 = $base_options + [
        'title' => 'child_1 title EN',
        'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child_1'],
        'parent' => $link->getPluginId(),
        'langcode' => 'en',
      ];
    $child_1 = MenuLinkContent::create($child_1);
    $child_1->save();

    // Add the german translation.
    $child_1->addTranslation('de', ['title' => 'child_1 title DE'] + $child_1->toArray());
    $child_1->save();

    $this->assertTokens('menu-link', ['menu-link' => $child_1], [
      'title' => 'child_1 title EN',
      'parents' => 'English menu title',
      'root' => 'English menu title',
    ]);
    $this->assertTokens('menu-link', ['menu-link' => $child_1], [
      'title' => 'child_1 title DE',
      'parents' => 'German menu title',
      'root' => 'German menu title',
    ], ['langcode' => 'de']);
  }

  /**
   * Tests menu link parents token.
   */
  public function testMenuLinkParentsToken() {
    // Create a menu with a simple link hierarchy :
    // - parent
    //   - child-1
    //      - child-1-1
    Menu::create([
      'id' => 'menu_test',
      'label' => 'Test menu',
    ])->save();
    $base_options = [
      'provider' => 'menu_test',
      'menu_name' => 'menu_test',
    ];
    $parent = $base_options + [
        'title' => 'parent title',
        'link' => ['uri' => 'internal:/menu-test/hierarchy/parent'],
    ];
    $parent = MenuLinkContent::create($parent);
    $parent->save();
    $child_1 = $base_options + [
        'title' => 'child_1 title',
        'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child_1'],
        'parent' => $parent->getPluginId(),
    ];
    $child_1 = MenuLinkContent::create($child_1);
    $child_1->save();
    $child_1_1 = $base_options + [
        'title' => 'child_1_1 title',
        'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child_1/child_1_1'],
        'parent' => $child_1->getPluginId(),
    ];
    $child_1_1 = MenuLinkContent::create($child_1_1);
    $child_1_1->save();

    $this->assertTokens('menu-link', ['menu-link' => $child_1_1], ['parents' => 'parent title, child_1 title']);

    // Change the parent of child_1_1 to 'parent' at the entity level.
    $child_1_1->parent->value = $parent->getPluginId();
    $child_1_1->save();

    $this->assertTokens('menu-link', ['menu-link' => $child_1_1], ['parents' => 'parent title']);

    // Change the parent of child_1_1 to 'main', at the entity level.
    $child_1_1->parent->value = '';
    $child_1_1->save();

    // The token shouldn't have been generated; the menu link has no parent.
    $this->assertNoTokens('menu-link', ['menu-link' => $child_1_1], ['parents']);
  }

  /**
   * Tests that no menu link is generated when the node gets previewed.
   */
  public function testPreviewMenuLink() {
    $this->drupalCreateContentType(['type' => 'article']);
    $permissions = [
      'access administration pages',
      'administer content types',
      'create article content',
      'edit any article content',
      'administer menu',
    ];
    $this->drupalLogin($this->drupalCreateUser($permissions));
    // Create an english node with an english menu.
    $this->drupalGet('/node/add/article');
    $edit = [
      'title[0][value]' => 'English test node with menu',
      'menu[enabled]' => TRUE,
      'menu[title]' => 'English menu title',
    ];
    $this->drupalGet('node/add/article');
    $this->submitForm($edit, 'Preview');
    $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(['menu_name' => 'main']);
    $this->assertEmpty($menu_links);
  }

}

Youez - 2016 - github.com/yon3zu
LinuXploit