all contrib module security updates done
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
Link 7.x-1.7, 2019-11-14
|
||||
------------------------
|
||||
#3094381 by DamienMcKenna: Add a CHANGELOG.txt file.
|
||||
#3094370 by DamienMcKenna: Coding standards tidy-up.
|
||||
#3094307 by DamienMcKenna: Clean up tests a bit.
|
||||
By DamienMcKenna: Added myself to the maintainers list.
|
||||
#3041220 by Daniel Korte, nileema.jadhav, Deepak.Sharma, pifagor: False positive
|
||||
in link_validate_url() function with relative URLs with fragments.
|
||||
#3038104 by jwilson3, cm0dit, pifagor: Support hashbang (#!) in URLs.
|
||||
By drumm: Ensure attributes are not strings.
|
||||
#2654246 by SurfinSpirit, moleCuleFFF, recrit, okapi1987@gmail.com, whthat,
|
||||
sdstyles, rajiv.singh, ac, pifagor, dgtlmoon, Chris Matthews, Nishruu: Anchor
|
||||
and Query urls are not supported.
|
||||
#2943127 by sean_e_dietrich, kyuubi, Chris Matthews, ShaunLaws, pifagor: Link
|
||||
field with static title always shows even when no url entered.
|
||||
#2675568 by pianomansam, Chris Matthews, pifagor: Whether URL and Title entity
|
||||
properties are required is incorrectly determined.
|
||||
#2718563 by makbul_khan8, jgalletta, idebr, malcomio, joekers, b.lammers,
|
||||
pifagor: Use link field widget in custom form.
|
||||
#1475790 by idebr, quicksketch, donquixote, skessler, jcfiala, stevector, Zach,
|
||||
bk_bigfish, balumahender, jrao, pifagor, jbitdrop, das-peter: Link should not
|
||||
modify $item['url'] on node_view() (causes data loss when combined with
|
||||
Workbench Moderation).
|
||||
#949604 by boazr, webadpro, zilverdistel, TheRuslan, GaëlG, barraponto,
|
||||
jhodgdon, diqidoq, jcfiala, Gábor Hojtsy, colan, mErilainen, knalstaaf,
|
||||
mfernea, pifagor: Static link text cannot be translated.
|
||||
#1993920 by lwalley, johnnybgoode, Dragan Eror, weri, idebr, Etroid, jcfiala,
|
||||
jsst, alex_optim, diqidoq, dandaman: Allow tel: links.
|
||||
#2428185 by das-peter, harsha012, hgoto, recrit, eelkeblok, weseze, nironan,
|
||||
pifagor, Alex Bukach, diqidoq: Language prefix and relative links broken.
|
||||
#2974486 by naidim: Title field assumed when it may not exist.
|
||||
#2966141 by RenatoG: Add translate in help section.
|
||||
#2574331 by RenatoG, tjhart87: Utilize link target action in rules.
|
||||
#2653852 by sassafrass, pifagor, NWOM, RenatoG: Token displayed when field is
|
||||
empty.
|
||||
#2966082 by RenatoG: Remove unused file for structure.
|
||||
#2965798 by RenatoG: Update documentation for requirements.
|
||||
#2965735 by RenatoG: Organize style structure. Create css folder for organizer.
|
||||
#2965727 by RenatoG: Remove unused / commented code in views/link.views.inc.
|
||||
#2295071 by interX, pifagor: Recursion in field formatter with views.
|
||||
#2195699 by Dane Powell, pifagor: Generate more creative URLS with
|
||||
devel_generate.
|
||||
#2536756 by gareth-davies, pifagor: Unless using the default field formatter,
|
||||
classes are not transformed into an array which causes a fatal error.
|
||||
#2916152 by azinck, pifagor: Override title in field formatter.
|
||||
#2921141 by chishah92, Ambient.Impact, RenatoG: Use a real ellpsis instead of
|
||||
three dots (...).
|
||||
#2945199 by salvis, pifagor: drupal_encode_path() is called twice.
|
||||
#2813057 by klausi, pifagor, John Cook: mailto: link with subject parameter and
|
||||
upper case letter does not validate.
|
||||
#2952073 by pifagor: Change correct deskription.
|
||||
#2930024 by Dylan Donkersgoed, pifagor: file:// links often don't work.
|
||||
#2948578 by RenatoG: Resolve all items reported by pareview.sh.
|
||||
|
||||
Link 7.x-1.6, 2019-02-20
|
||||
------------------------
|
||||
Ensure attributes are not strings.
|
||||
|
||||
Link 7.x-1.5, 2018-05-13
|
||||
------------------------
|
||||
#2553705 and #2961210 by billywardrop, pifagor, vinmassaro, alex_optim,
|
||||
alex.mazaltov: Preparation of module version 1.5.
|
||||
|
||||
Link 7.x-1.5-beta3, 2018-02-21
|
||||
------------------------------
|
||||
By pifagor: Fixed test.
|
||||
#2945139: options(&$options) deprecated since views2.
|
||||
#2945137: Unused variables.
|
||||
#2945133: Warning: Method call uses 2 parameters, but method signature uses 1
|
||||
parameters.
|
||||
#2945131: Fix coding standards module.
|
||||
#2945128: Fix coding standard test parts
|
||||
#2901656 and #2210297 by nightwalkr, mfernea: validates that the input on the
|
||||
URL field actually exists as a path alias. Theme_link_formatter_link_default()
|
||||
doesn't work with classes defined in a preprocess function.
|
||||
#2216399 by jemond: Provide Formatter to remove http:// or https:// from URL.
|
||||
#1836632 by jmart: Double HTML escaping when using plain_title formatter.
|
||||
By nileema.jadhav: Modification for bug fixes related to HTML entities in title
|
||||
and no protocol for url display format.
|
||||
#2480723 by krystalcode, naidim, rrrob, sumitmadan, Argus, diqidoq, RenatoG,
|
||||
jbitdrop: Avoid warning in diff integration for links without title.
|
||||
#2911860 by RenatoG: Fix tests items results.
|
||||
By RenatoG: Fix tests.
|
||||
#2244041 by alberto56, RenatoG: Undefined index: widget in link.module on line
|
||||
1341.
|
||||
#2743401 by RenatoG, MHuebner: Use parent directory in internal url.
|
||||
#2897563 by RenatoG: Fix Coding Standards, Best Practices and Insert
|
||||
Documentation in Comments for Tests.
|
||||
#2897348 by RenatoG: Update documentation in README file for nre template of
|
||||
Drupal.org.
|
||||
#2897332 by RenatoG: Fix all items of Code Review for Link.
|
||||
#2166459 by j0rd, mstef: Notice: Undefined index: error_element in
|
||||
link_field_widget_error() (line 328 of link.module).
|
||||
|
||||
Link 7.x-1.5-beta2, 2017-07-25
|
||||
------------------------------
|
||||
#2889683 by Yago Elias, RenatoG: Protocol-less URLs should be cleaned for use.
|
||||
#2558497 by joachim, RenatoG: property type for 'url' entity metadata property
|
||||
should not be 'url'.
|
||||
#2299657 by RenatoG, egfrith, ChuChuNaKu, idebr, jtsnow, rootwork,
|
||||
kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
|
||||
brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
|
||||
brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
|
||||
DamienMcKenna, doraf, jmart, reptilex, Berliner-dupe, jp.stacey, JonMcL: Allow
|
||||
any TLD because site admins can never keep up with ICANN.
|
||||
#2499165 by jcnventura, RenatoG: Validate all latin accented chars.
|
||||
#1295132 by Scyther, RenatoG: Unnecessary variables in link.install.
|
||||
#1335424 by claudiu.cristea, RenatoG: Title as a select.
|
||||
#2612176 by FluxSauce, pcambra, RenatoG: PHP Fatal error: Class
|
||||
'MigrateFieldHandler' not found.
|
||||
#2693731 by Antonnavi, RenatoG: Tokens replaced on "Static title" when "Allow
|
||||
user-entered tokens" not enabled.
|
||||
|
||||
Link 7.x-1.5-beta1, 2017-01-14
|
||||
------------------------------
|
||||
#2140087 by olofjohansson, maximpodorov, mistermoper, RenatoG: Allow '0' as the
|
||||
link title.
|
||||
#1418762 by num37, RenatoG, rvilar, jcfiala, randyhook: Provide default title
|
||||
when title is optional.
|
||||
#2553705 by Trav84, aguilarm, michaelfavia, reshma.i, RenatoG, roopeshnaik:
|
||||
Static Title does not show up when using 'Optional URL' + 'Static Title' with
|
||||
an empty URL.
|
||||
#2323441 by paolomainardi, sumitmadan, SylvainM, brockfanning, rob_johnston,
|
||||
RenatoG, mikeryan: [Patch] Migrate language argument array handling.
|
||||
#2299657 by egfrith, RenatoG, ChuChuNaKu, idebr, jtsnow, rootwork,
|
||||
kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
|
||||
brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
|
||||
brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
|
||||
DamienMcKenna, doraf, jmart, reptilex, jp.stacey, JonMcL: Allow any TLD
|
||||
because site admins can never keep up with ICANN.
|
||||
#1909788 by mthomas, jesss, csc4, Kpolymorphic, RenatoG: Add an entity token for
|
||||
the display_url.
|
||||
#2650956 by loopduplicate, amitmaity, karsumit94, RenatoG: Code standards are
|
||||
not followed for array modified in 2367069.
|
||||
#2299657 by egfrith, RenatoG, ChuChuNaKu, idebr, jtsnow, rootwork,
|
||||
kristiaanvandeneynde, GoddamnNoise, Leeteq, jcfiala, Remon, drumm, tobiberlin,
|
||||
brantwynn, klonos, Vacilando, quicksketch, mikeytown2, samuel.mortenson,
|
||||
brice_gato, katjam, kenorb, ultimike, Graber, rv0, othermachines, r0nn1ef,
|
||||
DamienMcKenna, doraf, jmart, reptilex, Berliner-dupe, jp.stacey, JonMcL,
|
||||
peter-majmesku: Allow any TLD because site admins can never keep up with
|
||||
ICANN.
|
||||
#2299657 by egfrith, ChuChuNaKu, RenatoG, idebr, jtsnow, rootwork, Leeteq,
|
||||
kristiaanvandeneynde, GoddamnNoise, tobiberlin, Remon, drumm, jcfiala, klonos,
|
||||
brantwynn, quicksketch, mikeytown2, samuel.mortenson, brice_gato, Vacilando,
|
||||
katjam, kenorb, ultimike, Graber, rv0, DamienMcKenna, doraf, jmart, reptilex,
|
||||
jp.stacey, JonMcL: Allow any TLD because site admins can never keep up with
|
||||
ICANN.
|
||||
#2890057 by RenatoG: All content of file commented "link.views.inc" should be
|
||||
use @codingStandardsIgnoreFile tag.
|
||||
#2299657 by egfrith, ChuChuNaKu, RenatoG, idebr, jtsnow, Leeteq, GoddamnNoise,
|
||||
tobiberlin, kristiaanvandeneynde, Remon, jcfiala, rootwork, drumm, klonos,
|
||||
brice_gato, quicksketch, brantwynn, mikeytown2, Vacilando, reptilex,
|
||||
samuel.mortenson, DamienMcKenna, ultimike, Graber, rv0, doraf, jp.stacey,
|
||||
kenorb, jmart, JonMcL, katjam: Allow any TLD because site admins can never
|
||||
keep up with ICANN.
|
||||
#2890013 by RenatoG: Fix codings standards for Link.
|
||||
#2889755 by RenatoG: Fixed Best practice in Drupal.
|
||||
#2566443 by ohthehugemanatee, RenatoG: Broken description text when used through
|
||||
Form API.
|
||||
#2888582 by RenatoG: Resolved unused variables in install file.
|
||||
#2723993 by dhruveshdtripathi, rahul.shinde, jeevanbhushetty, RenatoG: help hook
|
||||
is not there.
|
||||
#2578521 by kala4ek, arialvix, soapboxcicero, ervit, RenatoG: Validation error.
|
||||
#2888510 by RenatoG: Create tip for token on install.
|
||||
#2888480 by RenatoG: Fixed documentation links in new window target "blank".
|
||||
#2888461 by RenatoG: Clear variable "link_extra_domains" on uninstall.
|
||||
#2843813 by idebr, klausi, michael_wojcik, clemens.tolboom: Fix failing tests
|
||||
due to missing 'administer fields' permission.
|
||||
|
||||
Link 7.x-1.4, 2016-01-14
|
||||
------------------------
|
||||
UPC-99: Apply patch: link-field_link_validate_overrites_langcode-2632728.patch
|
||||
#2470377 by rhclayto: Adding a class with underscores, the class gets rendered
|
||||
with hyphens
|
||||
#609560 by Boobaa: Provide token for hostname
|
||||
#2470968: Add README.txt
|
||||
#2247261 by heddn, sumitmadan: URLs are not validated
|
||||
#2513706 by rrfegade: Spelling errors in D7
|
||||
#2055111 by joelpittet, mikeytown2: skip over re-loading entities for tokens in
|
||||
link field attributes unless there's a token to process.
|
||||
#2367069 by jcfiala:Fixed entity_token for link after node_view was called.
|
||||
Added setup function to LinkValidateUrlLight to enable link module, which was
|
||||
failing drupal.org qa testbot.
|
||||
#2364673 by jcfiala: Replaced drupal_html_class() with
|
||||
drupal_clean_css_identifier() so that link field classes are not forced to
|
||||
lower case.
|
||||
Added tests to test entity_token token with link.
|
||||
|
||||
Link 7.x-1.3, 2014-10-21
|
||||
------------------------
|
||||
By jcfiala: Various small fixes to pass coder review.
|
||||
#2351223 by Xano: Improve field validation error message.
|
||||
#2350253 by genjohnson: Fixed Link with ! (exclamation) in URL query returns
|
||||
"not a valid URL".
|
||||
#1483494 by vinmassaro, cord1: Notice: Undefined index: url in _link_process()
|
||||
(line 345 of ../link.module).
|
||||
#1955976 by chOP, erikhopp, idebr, d.clarke | Jim Cutler: Added Allow relative
|
||||
paths with validation.
|
||||
#2117099 by tim.plunkett: Expose attributes as property info.
|
||||
#1930430 by benjifisher: Fixed Migration integration misses title attribute for
|
||||
mutiple-valued link fields.
|
||||
#97766 by tanepiper, heddn, timbrandin, droath, alanburke, Digidog: Class
|
||||
attribute field option for each dataset in link widget.
|
||||
#1266474 by redndahead, franz, RobLoach, jcfiala, markabur: Use field label as
|
||||
the label for the title field
|
||||
#2036645 by lex0r: restricting the explode to 2 items when breaking apart
|
||||
querystrings helps prevent problems with unescaped = characters in the data.
|
||||
#2223571 by jcfiala: Included new tld that had been included into the 6.x-2.x
|
||||
branch.
|
||||
#1836632 by jcfiala:Removed double-encoding of titles when url not specified in
|
||||
link field.
|
||||
#1980736 by Cottser: Allow child elements of the link field to be rendered.
|
||||
|
||||
Link 7.x-1.2, 2013-11-24
|
||||
------------------------
|
||||
#1866632 by mohamadaliakbari,poiu:Adding rtl support to the link field.
|
||||
#1928116 by jcfiala: Added field variable to variables for link formatter
|
||||
functions in hook_theme.
|
||||
#2141643:Applying changes suggested by coder
|
||||
#2043001 by zhuber:Add xxx to list of top level domains.
|
||||
#2036115 by Samvel:Validation of link field was not being properly passed
|
||||
through to hook_field_widget_error().
|
||||
#1616752 by Taran2L:Period in names of querystring items was being replaced with
|
||||
underscores.
|
||||
#2123277 by zhuber:Link devel generate was applying titles to links with no
|
||||
title set.
|
||||
#1936784 by jeffam, illmasterc: Ampersands were being escaped in urls.
|
||||
#1784862 by aaronbauman: Added dialog switch to code displaying available
|
||||
tokens.
|
||||
#1914286 by facine: Fixes Title value in link_field_update_instance undefined
|
||||
error.
|
||||
#1918850 by jsacksick: Prevents undefined variable messages in
|
||||
link_i18n_string_list_field_alter().
|
||||
|
||||
Link 7.x-1.1, 2013-02-09
|
||||
------------------------
|
||||
By jcfiala: Fixed broken token tests - setUp on LinkBaseTestClass was broken.
|
||||
#949604 by zilverdistel: Added i18n support for the static link text field
|
||||
option.
|
||||
#1909314 by Simon Georges: Removing link.install from the link.info files[]
|
||||
array.
|
||||
By jcfiala: Removed all places where #markup was being set to a theme function
|
||||
output with #theme.
|
||||
#1674284 by sun, jcfiala: Cleaning up the code to Drupal standards, this time
|
||||
with the tests.
|
||||
#1674284 by sun, jcfiala: Cleaning up the code to Drupal standards.
|
||||
By hass:Fixing a string in the target argument handler to be t-compatible.
|
||||
By hackwater: Fixed minor typo which spelled automatically wrong.
|
||||
#1458502 by eugene.brit:Fixing Undefined index: target in _link_sanitize()
|
||||
#1010850 by benjifisher: Update MigrateFieldHandler to work with migrate-7.x-2.4
|
||||
and later.
|
||||
#1889918 by jcfiala,Boobaa: Changed the bad url error message to include the
|
||||
field's label.
|
||||
#1179944 by jcfiala, mr.york: Added variable_get calls so that the list of TLD
|
||||
that pass validation can be set by admins.
|
||||
#1766150 by jcfiala: Blank urls will no longer be treated the same as links to
|
||||
<front>.
|
||||
#1686024 by Alan D.: Added implementation of hook_field_diff_view().
|
||||
#1715246 by Haza, jcfiala: Fixed strict warning when loading entity for token
|
||||
use, also fixed problem with the title attribute not being handeld properly.
|
||||
#1309768 by jcfiala: Made URL label of url-only link fields invisible instead of
|
||||
removing it, to be 508 compliant.
|
||||
#1645640 by barraponto:Fixing <front> links as well as double-printing of
|
||||
querystring.
|
||||
By jcfiala: Fixed how possible tokens are displayed when setting up a link field
|
||||
- had been using a variable which was not defined in that scope.
|
||||
#43870: Cleaned up and conslidated the link formatter tests so that the tests
|
||||
can run faster.
|
||||
#438770: Fixed code to align with tests - handling the 'token type' fetching
|
||||
better and fixing the separate link display to match previous functionality.
|
||||
#1047444 by Sweetchuck, jcfiala: Updated how tokens are handled so that the
|
||||
proper token references are used, and not just 'node'.
|
||||
#1309658 by jcfiala: Small nudge to the views tokens fix to handle problem with
|
||||
relative links going through url() twice.
|
||||
#472766 by mstrelan: Added new formatter to display domain as link.
|
||||
#1710578 by jcfiala: Added code to prevent unnecessary = signs in querystrings.
|
||||
#1309658 by jcfiala: Rearranged the link code so that the query and fragment are
|
||||
not separated from the url so that views can access them in a token.
|
||||
#1290904 by gordon:Moved link processing on save from the hook_field_presave
|
||||
link to the hook_field_insert/update hook to prevent problem with
|
||||
field_attach_update.
|
||||
#1525668 by mikeryan: Removed type-hint of $entity in the migrate prepare
|
||||
handler.
|
||||
#1599314 by arpieb: Adding spaces, periods, and parenthesis to internal file
|
||||
paths.
|
||||
#1368616 by grndlvl: Fix required marker so it shows if title is not displayed.
|
||||
#1512954 by jfiala, mikeytown2: Added code to prevent error in
|
||||
theme_link_formatter_link_plain(), improved use of $link_options array in
|
||||
theme functions.
|
||||
#1125766 by jcfiala, David Stosik, Eric_A: Provided default value for link
|
||||
targets when link field uses user input for target.
|
||||
#1230256 by yched: Fixed D6 migration (cck_migrate()).
|
||||
#1218428 by twistor, Digidog: Fixed - Link tests, LinkValidateUrlLight because
|
||||
link validate_url is called but not available.
|
||||
#1409980 by luisortizramos, effulgentsia, Digidog: Fixed - Validation error
|
||||
-Invalid URL- is not reported properly. The corresponding form_set_error()
|
||||
calls have been fixed.
|
||||
#1441702 by Digidog: Fixed - Rel attribute should have an option to get
|
||||
automaticly turned on/off if link is internal/external.
|
||||
#1418674 by rvilar, Digidog: Fixed - Bad variable concatenation in t() function-
|
||||
#1321482 by Liam Morland, KarlShea, Summit, Jevedor, Digidog: Fixed -Query
|
||||
string and fragment are removed, resulting in parts of the URL being lost-
|
||||
#1066328 by Bevan, jcfiala, dkingofpa, sammys, Digidog: Formatter for use with
|
||||
url() and Views its -output this field as a link- fields (Absolute url
|
||||
formatter added).
|
||||
#1429684 by das-pater: Dont unserialize already unserialized attributes in
|
||||
_link_load(). The patch contains condition before unserialize in _link_load(),
|
||||
link_views_handler_argument_target::query() is now compatible to its parent to
|
||||
avoid php strict notices.
|
||||
#698438 by tim.plunkett: Added support for Devel Generate
|
||||
#1010850 by jcfiala, quartsize, raman2385, Bevan, eporama, das-peter,
|
||||
smithmilner, Digidog: Fixed MigrateFieldHandler to work with Migrate Module.
|
||||
|
||||
Link 7.x-1.0, 2011-10-23
|
||||
------------------------
|
||||
#1318850 by Digidog: Fixed completion of special chars for function
|
||||
link_validate_url() in line 916.
|
||||
#1199806 by ss81, jcfiala, Digidog: Fixed fatal error when the link URl is equal
|
||||
to page URL.
|
||||
#1307788 Feature request by nmc, tars16, Digidog: Fixed Add custom maxlength to
|
||||
link title text.
|
||||
#1217396 by WilliamB,noahb,orakili,Digidog: Fixed options multiple-value &
|
||||
required break input/save and produces error: At least one title or URL must
|
||||
be entered.
|
||||
#1036628 by gargoyle,jcfiala,wizonesolutions,Digidog: Fixed to allow more
|
||||
special chars in url validation for use cases like twitter etc. (f.e.: # , ~ )
|
||||
#948658 by brenk28, Dave Reid, becw, jcfiala, iMiksu, BTMash, Digidog: Fixed
|
||||
noticeof Undefined index: title in _link_sanitize() - hopefully, finally.
|
||||
#1079782 by fago, klausi, drunken monkey, jcfiala, Digidog: Fixed support for
|
||||
hook_entity_property_info() including search API and Rules. @TODO: needs
|
||||
simpletests to be submitted for rc1.
|
||||
|
||||
Link 7.x-1.0-beta1, 2011-09-26
|
||||
-------------------------------
|
||||
#1264208 by lazysoundsystem, Digidog: Fixed recursive serialization of
|
||||
attributes.
|
||||
#1218422 by Dave Reid, twistor, Digidog: Fixed tests files: strict warnings
|
||||
about static getInfo and parameters for setUp(), whitespace, and file
|
||||
structure.
|
||||
#1038444 by Dave Reid, Digidog: Fixed 3 issues plus #required on title prevents
|
||||
submission. All issues have been fixed with patch of Dave Reid from January.
|
||||
Patch manually retrieved for latest 7.x-1.x by Digidog.
|
||||
#1105816 by thekevinday, jcfiala, Digidog: Fixed improper use of db_type by
|
||||
committing patch of thekevinday at comment-5028534.
|
||||
#335281 by thePanz, jcfiala, stella, Digidog: committed patch by stella
|
||||
#comment-4929778 for title attribute support.
|
||||
#519416 by jcfiala: Added the plain text display of just the link title, which
|
||||
was available in 6.x but had not been added to 7.x yet.
|
||||
By jcfiala: Added slight changes to how links are validated to bring them in
|
||||
line withvalid_url().
|
||||
#1148864 by jcfiala: Re-enabled the ability to turn off url validation.
|
||||
#1063764 by bdragon,jcfiala: Renamed all field formatters to start with 'link_'
|
||||
so they will be unique.
|
||||
#1078254 by jcfiala: added a hook_update_n call that copies settings from the
|
||||
field to the instance.
|
||||
#1126384 by burki: Started using field_widget_instance to get link field
|
||||
settings in link_field_process, which is more standard than hunting in the
|
||||
for it.
|
||||
#1125384 by Rob Loach: Changed url length in link_field_schema to not use the
|
||||
constant which is not always defined.
|
||||
#1043348 by jcfiala: Finished updating the formatting code so that querystrings
|
||||
and fragments of urls work as in 6.x-2.x.
|
||||
#438770 by jcfiala: Adding test that makes sure the 'plain url' formatter is
|
||||
working properly with the basic case.
|
||||
#1043348 by jcfiala: First pass at fixing problems with raw www.example.com urls
|
||||
ending up as index.php?q=www.example.com. Need more testing/fixing with
|
||||
fragments and querystrings - not complete.
|
||||
#1056364 by the_phi: Checking that ['settings']['enable_tokens'] exists before
|
||||
the value is compared.
|
||||
#1078736 by jcfiala: Added empty handler for hook_link_form_settings to make
|
||||
ield Permissions work.
|
||||
|
||||
Link 7.x-1.0-alpha3, 2011-02-07
|
||||
-------------------------------
|
||||
bug report #1008562 by jcfiala: Looking into URL, as link error caused me to
|
||||
realize that the _link_sanitize was being called in the wrong place - now
|
||||
called on link_field_prepare_view.
|
||||
bug report by jcfiala: Fixed error from missing index by changing ['required']
|
||||
to ['required'].
|
||||
bug report #1026040 by pcambra: Updated token help to use the updated token
|
||||
module and token display.
|
||||
bug report #1033112 by Dave Reid: Removing extra lines from link.info.
|
||||
task #970392 by jcfiala: Added content_migrate_field_alter and
|
||||
content_migrate_instance_alter hooks to link.module to help with upgrading
|
||||
from D6 to D7.
|
||||
feature request #1012372 by jcfiala: Tried using
|
||||
hook_field_instance_settings_form to allow per-instance settings. Also,
|
||||
re-added a bunch of old tests from 6.x.
|
||||
|
||||
Link 7.x-1.0-alpha2, 2010-12-13
|
||||
-------------------------------
|
||||
task #960062 by jcfiala: Added package of 'fields' to the link.info file.
|
||||
task #997270 by jcfiala: Removed content in link.views.inc, and added file
|
||||
references to the link_views_handler files in link.info for better views
|
||||
integration.
|
||||
By jcfiala: Added more code to attribute test.
|
||||
By jcfiala: Edited the two test files so that simpletests run without error,
|
||||
although they don't test nearly enough.
|
||||
bug report #952656 by Dave_Reid: Moved hook_field_schema() to link.install,
|
||||
other small tweaks to remove old references.
|
||||
bug report #948628 by brenk28, bec: Fixing setting references in and removing
|
||||
calls to see if token is enabled.
|
||||
|
||||
Link 7.x-1.0-alpha1, 2010-12-07
|
||||
-------------------------------
|
||||
#955214 by alex_b,jcfiala: Fixed problem where a url with a querystring caused
|
||||
fatal errors.
|
||||
#956182 by jmiccolis, bec, Bevan: Theme fixing for the theme_link_field
|
||||
#696678 by tristanoneil: Link module now showing basic functionality - still not
|
||||
done, but better.
|
||||
#696678 by Garrett Albright: Initial attempt at updating Link module to Drupal 7
|
||||
- does not really work but is a start.
|
||||
By dropcube: First working copy of the 7.x version.
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
diff --git a/link.module b/link.module
|
||||
index 241066d..103cde6 100644
|
||||
--- a/link.module
|
||||
+++ b/link.module
|
||||
@@ -1302,7 +1302,7 @@ function link_field_item_property_info() {
|
||||
* Implements hook_field_update_instance().
|
||||
*/
|
||||
function link_field_update_instance($instance, $prior_instance) {
|
||||
- if (function_exists('i18n_string_update') && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {
|
||||
+ if (function_exists('i18n_string_update') && $instance['widget']['type'] == 'link_field' && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {
|
||||
$i18n_string_name = "field:{$instance['field_name']}:{$instance['bundle']}:title_value";
|
||||
i18n_string_update($i18n_string_name, $instance['settings']['title_value']);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
CONTENTS OF THIS FILE
|
||||
---------------------
|
||||
|
||||
* Introduction
|
||||
* Requirements
|
||||
* Installation
|
||||
* Configuration
|
||||
* Example
|
||||
* Theming and Output
|
||||
* Maintainers
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
------------
|
||||
|
||||
The link can be count to the top 50 projects in Drupal installations and
|
||||
provides a standard custom content field for links. With this module links can
|
||||
be added easily to any content types and profiles and include advanced
|
||||
validating and different ways of storing internal or external links and URLs. It
|
||||
also supports additional link text title, site wide tokens for titles and title
|
||||
attributes, target attributes, css class attribution, static repeating values,
|
||||
input conversion, and many more.
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
No special requirements
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
Install as you would normally install a contributed Drupal module. See:
|
||||
https://drupal.org/documentation/install/modules-themes/modules-7 for further
|
||||
information.
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
* Configuration is only slightly more complicated than a text field. Link text
|
||||
titles for URLs can be made required, set as instead of URL, optional
|
||||
(default), or left out entirely. If no link text title is provided, the
|
||||
trimmed version of the complete URL will be displayed. The target attribute
|
||||
should be set to "_blank", "top", or left out completely (checkboxes provide
|
||||
info). The rel=nofollow attribute prevents the link from being followed by
|
||||
certain search engines. More info at Wikipedia
|
||||
(http://en.wikipedia.org/wiki/Spam_in_blogs#rel.3D.22nofollow.22).
|
||||
|
||||
|
||||
EXAMPLE
|
||||
-------
|
||||
If you were to create a field named 'My New Link', the default display of the
|
||||
link would be:
|
||||
<em><div class="field_my_new_link" target="[target_value]"><a href="[URL]">
|
||||
[Title]</a></div></em> where items between [] characters would be customized
|
||||
based on the user input.
|
||||
|
||||
The link project supports both, internal and external URLs. URLs are validated
|
||||
on input. Here are some examples of data input and the default view of a link:
|
||||
http://drupal.org results in http://drupal.org, but drupal.org results in
|
||||
http://drupal.org, while <front> will convert into http://drupal.org and
|
||||
node/74971 into http://drupal.org/project/link
|
||||
|
||||
Anchors and query strings may also be used in any of these cases, including:
|
||||
node/74971/edit?destination=node/74972<front>#pager
|
||||
|
||||
|
||||
THEMING AND OUTPUT
|
||||
------------------
|
||||
Since link module is mainly a data storage field in a modular framework, the
|
||||
theming and output is up to the site builder and other additional modules. There
|
||||
are many modules in the Drupal repository, which control the output of fields
|
||||
perfectly and can handle rules, user actions, markup dependencies, and can vary
|
||||
the output under many different conditions, with much more efficience and
|
||||
flexibility for different scenarios. Please check out modules like views,
|
||||
display suite, panels, etc for such needs
|
||||
|
||||
|
||||
MAINTAINERS
|
||||
-----------
|
||||
|
||||
Current maintainers:
|
||||
* John C Fiala (jcfiala) - https://www.drupal.org/user/163643
|
||||
* Renato Gonçalves (RenatoG) - https://www.drupal.org/user/3326031
|
||||
* Clemens Tolboom (clemens.tolboom) - https://www.drupal.org/user/125814
|
||||
* diqidoq - https://www.drupal.org/user/1001934
|
||||
* dropcube - https://www.drupal.org/user/37031
|
||||
* Tom Kirkpatrick (mrfelton) - https://www.drupal.org/user/305669
|
||||
* Sumit Madan (sumitmadan) - https://www.drupal.org/user/1538790
|
||||
* Daniel Kudwien (sun) - https://www.drupal.org/user/54136
|
||||
* Damien McKenna - https://www.drupal.org/u/damienmckenna
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
float: left;
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.link-field-column .form-text {
|
||||
width: 95%;
|
||||
}
|
||||
@@ -21,9 +21,13 @@ function link_devel_generate($object, $field, $instance, $bundle) {
|
||||
* Callback for hook_devel_generate().
|
||||
*/
|
||||
function _link_devel_generate($object, $field, $instance, $bundle) {
|
||||
return array(
|
||||
'url' => url('<front>', array('absolute' => TRUE)),
|
||||
'title' => devel_create_greeking(mt_rand(1, 3), TRUE),
|
||||
$url = 'http://example.com/' . devel_generate_word(mt_rand(6, 12));
|
||||
$link = array(
|
||||
'url' => url($url, array('absolute' => TRUE)),
|
||||
'attributes' => _link_default_attributes(),
|
||||
);
|
||||
if ($instance['settings']['title'] != 'none') {
|
||||
$link['title'] = devel_create_greeking(mt_rand(1, 3), TRUE);
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
function link_field_diff_view($items, $context) {
|
||||
$diff_items = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
if ($item['url'] && $item['title']) {
|
||||
if ($item['url'] && isset($item['title'])) {
|
||||
$diff_items[$delta] = $item['title'] . ' (' . $item['url'] . ')';
|
||||
}
|
||||
else {
|
||||
$diff_items[$delta] = $item['title'] . $item['url'];
|
||||
$diff_items[$delta] = $item['url'];
|
||||
}
|
||||
}
|
||||
return $diff_items;
|
||||
|
||||
@@ -3,7 +3,6 @@ description = Defines simple link field types.
|
||||
core = 7.x
|
||||
package = Fields
|
||||
|
||||
files[] = link.module
|
||||
files[] = link.migrate.inc
|
||||
|
||||
; Tests
|
||||
@@ -12,15 +11,16 @@ files[] = tests/link.attribute.test
|
||||
files[] = tests/link.crud.test
|
||||
files[] = tests/link.crud_browser.test
|
||||
files[] = tests/link.token.test
|
||||
files[] = tests/link.entity_token.test
|
||||
files[] = tests/link.validate.test
|
||||
files[] = tests/link.multilingual.test
|
||||
|
||||
; Views Handlers
|
||||
files[] = views/link_views_handler_argument_target.inc
|
||||
files[] = views/link_views_handler_filter_protocol.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-02-09
|
||||
version = "7.x-1.1"
|
||||
; Information added by Drupal.org packaging script on 2019-11-14
|
||||
version = "7.x-1.7"
|
||||
core = "7.x"
|
||||
project = "link"
|
||||
datestamp = "1360444361"
|
||||
|
||||
datestamp = "1573731676"
|
||||
|
||||
@@ -6,10 +6,38 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Upgrade notes:
|
||||
* Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:
|
||||
* Upgrade notes.
|
||||
*
|
||||
* Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function link_install() {
|
||||
// Notify the user they may want to install token.
|
||||
if (!module_exists('token')) {
|
||||
$t = get_t();
|
||||
drupal_set_message($t('If you install the <a href="!url" target="blank">Token</a>, static title can use any other entity field as its value.', array(
|
||||
'!url' => 'http://drupal.org/project/token',
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes unused link_extra_domains variable.
|
||||
*/
|
||||
function link_update_7002() {
|
||||
variable_del('link_extra_domains');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function link_uninstall() {
|
||||
variable_del('link_allowed_domains');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_schema().
|
||||
*/
|
||||
@@ -46,19 +74,21 @@ function link_update_last_removed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles moving settings data from field_config.data to field_config_instance.data.
|
||||
* Implements hook_update_N().
|
||||
*
|
||||
* Handles moving settings data from field_config.data to
|
||||
* field_config_instance.data.
|
||||
*/
|
||||
function link_update_7000() {
|
||||
|
||||
// For each field that is a link field, we need to copy the settings from the general field level down to the instance.
|
||||
//$field_data = array();
|
||||
|
||||
// For each field that is a link field, we need to copy the settings from the
|
||||
// general field level down to the instance.
|
||||
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
|
||||
foreach ($result as $field) {
|
||||
$field_id = $field->id;
|
||||
$name = $field->field_name;
|
||||
|
||||
$field_data = unserialize($field->data);
|
||||
|
||||
$instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
|
||||
|
||||
$instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
|
||||
foreach ($instances as $instance) {
|
||||
// If this field has been updated already, we want to skip it.
|
||||
$instance_data = unserialize($instance->data);
|
||||
@@ -71,8 +101,8 @@ function link_update_7000() {
|
||||
}
|
||||
}
|
||||
if ($update_instance) {
|
||||
// update the database.
|
||||
$num_updated = db_update('field_config_instance')
|
||||
// Update the database.
|
||||
db_update('field_config_instance')
|
||||
->fields(array('data' => serialize($instance_data)))
|
||||
->condition('id', $instance->id)
|
||||
->execute();
|
||||
@@ -80,22 +110,19 @@ function link_update_7000() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return t("Instance settings have been set with the data from the field settings.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames all displays from foobar to link_foobar
|
||||
* Renames all displays from foobar to link_foobar.
|
||||
*/
|
||||
function link_update_7001() {
|
||||
// Update the display type for each link field type.
|
||||
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
|
||||
foreach ($result as $field) {
|
||||
$field_id = $field->id;
|
||||
$name = $field->field_name;
|
||||
$field_data = unserialize($field->data);
|
||||
|
||||
$instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
|
||||
|
||||
$instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field->id));
|
||||
foreach ($instances as $instance) {
|
||||
// If this field has been updated already, we want to skip it.
|
||||
$instance_data = unserialize($instance->data);
|
||||
|
||||
@@ -11,11 +11,9 @@
|
||||
* $this->addFieldMapping('field_my_link', 'source_url');
|
||||
* $this->addFieldMapping('field_my_link:title', 'source_title');
|
||||
* $this->addFieldMapping('field_my_link:attributes', 'source_attributes');
|
||||
* @endcode
|
||||
*
|
||||
* With earlier versions of Migrate, you must pass an arguments array:
|
||||
* # With earlier versions of Migrate, you must pass an arguments array:
|
||||
*
|
||||
* @code
|
||||
* $link_args = array(
|
||||
* 'title' => array('source_field' => 'source_title'),
|
||||
* 'attributes' => array('source_field' => 'source_attributes'),
|
||||
@@ -25,6 +23,10 @@
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
if (!class_exists('MigrateFieldHandler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
@@ -35,12 +37,20 @@ function link_migrate_api() {
|
||||
);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreLine
|
||||
class MigrateLinkFieldHandler extends MigrateFieldHandler {
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->registerTypes(array('link_field'));
|
||||
}
|
||||
|
||||
static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
|
||||
/**
|
||||
* Arguments.
|
||||
*/
|
||||
public static function arguments($title = NULL, $attributes = NULL, $language = NULL) {
|
||||
$arguments = array();
|
||||
if (!is_null($title)) {
|
||||
$arguments['title'] = $title;
|
||||
@@ -57,16 +67,21 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
|
||||
/**
|
||||
* Implementation of MigrateFieldHandler::fields().
|
||||
*
|
||||
* @param $type
|
||||
* The field type.
|
||||
* @param $instance
|
||||
* Instance info for the field.
|
||||
* @param array $type
|
||||
* The field type.
|
||||
* @param array $instance
|
||||
* Instance info for the field.
|
||||
* @param Migration $migration
|
||||
* The migration context for the parent field. We can look at the mappings
|
||||
* and determine which subfields are relevant.
|
||||
* The migration context for the parent field. We can look at the mappings
|
||||
* and determine which subfields are relevant.
|
||||
*
|
||||
* @return array
|
||||
* Array with values.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function fields($type, $instance, $migration = NULL) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
return array(
|
||||
'title' => t('Subfield: The link title attribute'),
|
||||
'attributes' => t('Subfield: The attributes for this link'),
|
||||
@@ -74,6 +89,9 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare.
|
||||
*/
|
||||
public function prepare($entity, array $field_info, array $instance, array $values) {
|
||||
if (isset($values['arguments'])) {
|
||||
$arguments = $values['arguments'];
|
||||
@@ -97,12 +115,25 @@ class MigrateLinkFieldHandler extends MigrateFieldHandler {
|
||||
}
|
||||
}
|
||||
if (isset($arguments['attributes'])) {
|
||||
$item['attributes'] = $arguments['attributes'];
|
||||
if (is_array($arguments['attributes']) && isset($arguments['attributes'][$delta])) {
|
||||
$item['attributes'] = $arguments['attributes'][$delta];
|
||||
}
|
||||
else {
|
||||
$item['attributes'] = $arguments['attributes'];
|
||||
}
|
||||
}
|
||||
$item['url'] = $value;
|
||||
$return[$language][$delta] = $item;
|
||||
|
||||
if (is_array($language)) {
|
||||
$current_language = $language[$delta];
|
||||
}
|
||||
else {
|
||||
$current_language = $language;
|
||||
}
|
||||
$return[$current_language][$delta] = $item;
|
||||
}
|
||||
|
||||
return isset($return) ? $return : NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,11 @@
|
||||
* Basic simpletests to test options on link module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attribute Crud Test.
|
||||
*/
|
||||
class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
|
||||
private $zebra;
|
||||
|
||||
protected $permissions = array(
|
||||
@@ -19,6 +23,9 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
'access administration pages',
|
||||
);
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link Attribute Tests',
|
||||
@@ -27,14 +34,27 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
parent::setup('field_ui', 'link');
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'field_ui';
|
||||
$modules[] = 'link';
|
||||
parent::setUp($modules);
|
||||
|
||||
$this->zebra = 0;
|
||||
|
||||
// Create and login user.
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types'));
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Link.
|
||||
*/
|
||||
protected function createLink($url, $title, $attributes = array()) {
|
||||
return array(
|
||||
'url' => $url,
|
||||
@@ -43,20 +63,26 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert Link On Node.
|
||||
*/
|
||||
protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
|
||||
$this->zebra++;
|
||||
$zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
|
||||
$cssFieldLocator = 'field-'. str_replace('_', '-', $field_name);
|
||||
$this->assertPattern('@<div class="field field-type-link '. $cssFieldLocator .'".*<div class="field-item '. $zebra_string .'">\s*'. $link_value .'\s*</div>@is',
|
||||
$message,
|
||||
$group);
|
||||
$cssFieldLocator = 'field-' . str_replace('_', '-', $field_name);
|
||||
$this->assertPattern('@<div class="field field-type-link ' . $cssFieldLocator . '".*<div class="field-item ' . $zebra_string . '">\s*' . $link_value . '\s*</div>@is',
|
||||
$message,
|
||||
$group);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple test that just creates a new node type, adds a link field to it, creates a new node of that type, and makes sure
|
||||
* that the node is being displayed.
|
||||
* Test Basic.
|
||||
*
|
||||
* A simple test that just creates a new node type, adds a link field to it,
|
||||
* creates a new node of that type, and makes sure that the node is being
|
||||
* displayed.
|
||||
*/
|
||||
function testBasic() {
|
||||
public function testBasic() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
$title = $this->randomName(20);
|
||||
@@ -66,7 +92,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Create the content type.
|
||||
$this->clickLink(t('Add content type'));
|
||||
|
||||
$edit = array (
|
||||
$edit = array(
|
||||
'name' => $content_type_friendly,
|
||||
'type' => $content_type_machine,
|
||||
);
|
||||
@@ -76,8 +102,8 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
$single_field_name = 'field_'. $single_field_name_machine;
|
||||
$edit = array (
|
||||
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $single_field_name_friendly,
|
||||
'fields[_add_new_field][field_name]' => $single_field_name_machine,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
@@ -101,7 +127,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
|
||||
|
||||
$permission = 'create ' . $content_type_machine . ' content';
|
||||
$permission_edit = 'edit ' . $content_type_machine . ' content';
|
||||
|
||||
// Reset the permissions cache.
|
||||
$this->checkPermissions(array($permission), TRUE);
|
||||
|
||||
@@ -112,19 +138,22 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Go to page.
|
||||
$this->drupalGet('node/add/'. $content_type_machine);
|
||||
$this->drupalGet('node/add/' . $content_type_machine);
|
||||
|
||||
// Add a node.
|
||||
$edit = array(
|
||||
'title' => $title,
|
||||
'field_'. $single_field_name_machine. '[und][0][title]' => 'Link',
|
||||
'field_'. $single_field_name_machine. '[und][0][url]' => 'http://www.drupal.org/',
|
||||
'field_' . $single_field_name_machine . '[und][0][title]' => 'Link',
|
||||
'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.drupal.org/',
|
||||
);
|
||||
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array(
|
||||
'@content_type_friendly' => $content_type_friendly,
|
||||
'@title' => $title,
|
||||
)));
|
||||
|
||||
$this->drupalGet('node/add/'. $content_type_machine);
|
||||
$this->drupalGet('node/add/' . $content_type_machine);
|
||||
|
||||
// Create a node:
|
||||
$edit = array(
|
||||
@@ -135,15 +164,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
|
||||
// Now we can fill in the second item in the multivalue field and save.
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array(
|
||||
'@content_type_friendly' => $content_type_friendly,
|
||||
'@title' => $title,
|
||||
)));
|
||||
|
||||
$this->assertText('Display');
|
||||
$this->assertLinkByHref('http://www.example.com');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Simple Link Field.
|
||||
*/
|
||||
protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields');
|
||||
$edit = array (
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $single_field_name_friendly,
|
||||
'fields[_add_new_field][field_name]' => $single_field_name_machine,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
@@ -166,9 +201,11 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Node Type User.
|
||||
*/
|
||||
protected function createNodeTypeUser($content_type_machine) {
|
||||
$permission = 'create ' . $content_type_machine . ' content';
|
||||
$permission_edit = 'edit ' . $content_type_machine . ' content';
|
||||
// Reset the permissions cache.
|
||||
$this->checkPermissions(array($permission), TRUE);
|
||||
|
||||
@@ -179,8 +216,11 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Node For Testing.
|
||||
*/
|
||||
protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
|
||||
$this->drupalGet('node/add/'. $content_type_machine);
|
||||
$this->drupalGet('node/add/' . $content_type_machine);
|
||||
|
||||
if (!$node_title) {
|
||||
$node_title = $this->randomName(20);
|
||||
@@ -196,14 +236,16 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $node_title)));
|
||||
|
||||
$this->assertText(t('@content_type_friendly @title has been created', array(
|
||||
'@content_type_friendly' => $content_type_friendly,
|
||||
'@title' => $node_title,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the link_plain formatter and it's output.
|
||||
*/
|
||||
function testFormatterPlain() {
|
||||
public function testFormatterPlain() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
@@ -215,19 +257,19 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_plain',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$this->createNodeTypeUser($content_type_machine);
|
||||
|
||||
|
||||
$link_tests = array(
|
||||
'plain' => array(
|
||||
'text' => 'Display',
|
||||
@@ -243,18 +285,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($link_tests as $key => $link_test) {
|
||||
foreach ($link_tests as $link_test) {
|
||||
$link_text = $link_test['text'];
|
||||
$link_url = $link_test['url'];
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertText($link_url);
|
||||
$this->assertNoText($link_text);
|
||||
$this->assertNoLinkByHref($link_url);
|
||||
}
|
||||
}
|
||||
|
||||
function testFormatterURL() {
|
||||
/**
|
||||
* Formatter Host.
|
||||
*/
|
||||
public function testFormatterHost() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
@@ -266,19 +311,56 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_host',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$this->createNodeTypeUser($content_type_machine);
|
||||
|
||||
|
||||
$link_text = 'Display';
|
||||
$link_url = 'http://www.example.com/';
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
$this->assertText('www.example.com');
|
||||
$this->assertNoText($link_text);
|
||||
$this->assertNoLinkByHref($link_url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatter URL.
|
||||
*/
|
||||
public function testFormatterUrl() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
$this->drupalCreateContentType(array(
|
||||
'type' => $content_type_machine,
|
||||
'name' => $content_type_friendly,
|
||||
));
|
||||
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_url',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$this->createNodeTypeUser($content_type_machine);
|
||||
|
||||
$link_tests = array(
|
||||
'plain' => array(
|
||||
'text' => 'Display',
|
||||
@@ -294,17 +376,20 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($link_tests as $key => $link_test) {
|
||||
foreach ($link_tests as $link_test) {
|
||||
$link_text = $link_test['text'];
|
||||
$link_url = $link_test['url'];
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertNoText($link_text);
|
||||
$this->assertLinkByHref($link_url);
|
||||
}
|
||||
}
|
||||
|
||||
function testFormatterShort() {
|
||||
/**
|
||||
* Formatter Short.
|
||||
*/
|
||||
public function testFormatterShort() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
@@ -316,14 +401,14 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_short',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
@@ -344,18 +429,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($link_tests as $key => $link_test) {
|
||||
foreach ($link_tests as $link_test) {
|
||||
$link_text = $link_test['text'];
|
||||
$link_url = $link_test['url'];
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertText('Link');
|
||||
$this->assertNoText($link_text);
|
||||
$this->assertLinkByHref($link_url);
|
||||
}
|
||||
}
|
||||
|
||||
function testFormatterLabel() {
|
||||
/**
|
||||
* Formatter Label.
|
||||
*/
|
||||
public function testFormatterLabel() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
@@ -367,14 +455,14 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_label',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
@@ -395,18 +483,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($link_tests as $key => $link_test) {
|
||||
foreach ($link_tests as $link_test) {
|
||||
$link_text = $link_test['text'];
|
||||
$link_url = $link_test['url'];
|
||||
$link_url = $link_test['url'];
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertNoText($link_text);
|
||||
$this->assertText($single_field_name_friendly);
|
||||
$this->assertLinkByHref($link_url);
|
||||
}
|
||||
}
|
||||
|
||||
function testFormatterSeparate() {
|
||||
/**
|
||||
* Formatter Separate.
|
||||
*/
|
||||
public function testFormatterSeparate() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
@@ -418,14 +509,14 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_separate',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
@@ -447,48 +538,52 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($link_tests as $key => $link_test) {
|
||||
foreach ($link_tests as $link_test) {
|
||||
$link_text = $link_test['text'];
|
||||
$link_url = $link_test['url'];
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertText($link_text);
|
||||
$this->assertLink($plain_url);
|
||||
$this->assertLinkByHref($link_url);
|
||||
}
|
||||
}
|
||||
|
||||
function testFormatterPlainTitle() {
|
||||
|
||||
/**
|
||||
* Formatter Plain Title.
|
||||
*/
|
||||
public function testFormatterPlainTitle() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
|
||||
|
||||
$this->drupalCreateContentType(array(
|
||||
'type' => $content_type_machine,
|
||||
'name' => $content_type_friendly,
|
||||
));
|
||||
|
||||
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
//$single_field_name = 'field_'. $single_field_name_machine;
|
||||
// $single_field_name = 'field_'. $single_field_name_machine;.
|
||||
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
|
||||
|
||||
|
||||
// Okay, now we want to make sure this display is changed:
|
||||
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
|
||||
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
|
||||
$edit = array(
|
||||
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
|
||||
'fields[field_'. $single_field_name_machine .'][type]' => 'link_title_plain',
|
||||
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
|
||||
'fields[field_' . $single_field_name_machine . '][type]' => 'link_title_plain',
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
|
||||
$this->createNodeTypeUser($content_type_machine);
|
||||
|
||||
|
||||
$link_text = 'Display';
|
||||
$link_url = 'http://www.example.com/';
|
||||
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
|
||||
|
||||
|
||||
$this->assertText($link_text);
|
||||
$this->assertNoText($link_url);
|
||||
$this->assertNoLinkByHref($link_url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,20 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Basic CRUD simpletests for the link module, based off of content.crud.test in CCK.
|
||||
* File for Crud Tests.
|
||||
*
|
||||
* Basic CRUD simpletests for the link module, based off of content.crud.test in
|
||||
* CCK.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Content Crud.
|
||||
*/
|
||||
class LinkContentCrudTest extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link CRUD - Basic API tests',
|
||||
@@ -15,21 +24,30 @@ class LinkContentCrudTest extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('field_ui', 'link');
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'field_ui';
|
||||
$modules[] = 'link';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* All we're doing here is creating a content type, creating a simple link field
|
||||
* on that content type.
|
||||
* Create Field API.
|
||||
*
|
||||
* All we're doing here is creating a content type, creating a simple link
|
||||
* field on that content type.
|
||||
*/
|
||||
function testLinkCreateFieldAPI() {
|
||||
public function testLinkCreateFieldApi() {
|
||||
$content_type_friendly = $this->randomName(20);
|
||||
$content_type_machine = strtolower($this->randomName(10));
|
||||
$title = $this->randomName(20);
|
||||
|
||||
// Create and login user.
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types'));
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
$this->drupalGet('admin/structure/types');
|
||||
@@ -37,18 +55,17 @@ class LinkContentCrudTest extends DrupalWebTestCase {
|
||||
// Create the content type.
|
||||
$this->clickLink(t('Add content type'));
|
||||
|
||||
$edit = array (
|
||||
$edit = array(
|
||||
'name' => $content_type_friendly,
|
||||
'type' => $content_type_machine,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save and add fields'));
|
||||
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
|
||||
|
||||
//$field = $this->createField(array('type' => 'link', 'widget_type' => 'link'), 0);
|
||||
// Now add a singleton field.
|
||||
$single_field_name_friendly = $this->randomName(20);
|
||||
$single_field_name_machine = strtolower($this->randomName(10));
|
||||
$edit = array (
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $single_field_name_friendly,
|
||||
'fields[_add_new_field][field_name]' => $single_field_name_machine,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
@@ -69,14 +86,6 @@ class LinkContentCrudTest extends DrupalWebTestCase {
|
||||
menu_rebuild();
|
||||
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
|
||||
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
|
||||
|
||||
/*$table_schema = drupal_get_schema();
|
||||
$this->assertEqual(1, 1, print_r(array_keys($table_schema), TRUE));
|
||||
// Check the schema - the values should be in the per-type table.
|
||||
$this->assertSchemaMatchesTables(array(
|
||||
'per_type' => array(
|
||||
$this->content_types[0]->type => array($field['field_name'] => array('url', 'title', 'attributes')),
|
||||
),
|
||||
));*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,25 +6,28 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Testing that users can not input bad URLs or labels
|
||||
* Testing that users can not input bad URLs or labels.
|
||||
*/
|
||||
class LinkUITest extends DrupalWebTestcase {
|
||||
class LinkUiTest extends DrupalWebTestcase {
|
||||
|
||||
/**
|
||||
* Link supposed to be good
|
||||
* Link supposed to be good.
|
||||
*/
|
||||
const LINK_INPUT_TYPE_GOOD = 0;
|
||||
|
||||
/**
|
||||
* Link supposed to have a bad title
|
||||
* Link supposed to have a bad title.
|
||||
*/
|
||||
const LINK_INPUT_TYPE_BAD_TITLE = 1;
|
||||
|
||||
/**
|
||||
* Link supposed to have a bad URL
|
||||
* Link supposed to have a bad URL.
|
||||
*/
|
||||
const LINK_INPUT_TYPE_BAD_URL = 2;
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link CRUD - browser test',
|
||||
@@ -33,26 +36,32 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp('field_ui', 'link');
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'field_ui';
|
||||
$modules[] = 'link';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link field for the "page" type and creates a page with a link.
|
||||
*/
|
||||
function testLinkCreate() {
|
||||
//libxml_use_internal_errors(true);
|
||||
public function testLinkCreate() {
|
||||
// libxml_use_internal_errors(true);
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages'
|
||||
'access administration pages',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
@@ -72,58 +81,64 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
$permission = 'create page content';
|
||||
$this->checkPermissions(array($permission), TRUE);
|
||||
|
||||
// create page form
|
||||
//$this->drupalGet('node/add');
|
||||
// Create page form
|
||||
// $this->drupalGet('node/add');.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
||||
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
||||
|
||||
$input_test_cases = array(
|
||||
array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
'msg' => 'Link found',
|
||||
'type' => self::LINK_INPUT_TYPE_GOOD
|
||||
'type' => self::LINK_INPUT_TYPE_GOOD,
|
||||
),
|
||||
array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName() . '<script>alert("hi");</script>',
|
||||
'msg' => 'js label',
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
|
||||
),
|
||||
array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName() . '<script src="http://devil.site.com"></script>',
|
||||
'msg' => 'js label',
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
|
||||
),
|
||||
array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName() . '" onmouseover="alert(\'hi\')',
|
||||
'msg' => 'js label',
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
|
||||
'msg' => 'js label',
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_TITLE,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
|
||||
'label' => $this->randomName(),
|
||||
'msg' => 'js url',
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_URL
|
||||
'type' => self::LINK_INPUT_TYPE_BAD_URL,
|
||||
),
|
||||
array(
|
||||
'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
|
||||
'label' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
|
||||
'msg' => 'Url with . in querystring',
|
||||
'type' => self::LINK_INPUT_TYPE_GOOD,
|
||||
),
|
||||
);
|
||||
$test_case = array(
|
||||
'href' => 'www.example.com/'. $this->randomName(),
|
||||
'href' => 'www.example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
'msg' => 'Link found',
|
||||
'type' => self::LINK_INPUT_TYPE_GOOD,
|
||||
);
|
||||
$test_case['expected_href'] = 'http://'. $test_case['href'];
|
||||
$test_case['expected_href'] = 'http://' . $test_case['href'];
|
||||
$input_test_cases[] = $test_case;
|
||||
|
||||
foreach ($input_test_cases as $input) {
|
||||
@@ -137,49 +152,59 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
|
||||
$this->assertRaw(t('The value provided for %field is not a valid URL.', array('%field' => $name)), 'Not a valid URL: ' . $input['href']);
|
||||
$this->assertRaw(t('The value %value provided for %field is not a valid URL.', array(
|
||||
'%field' => $name,
|
||||
'%value' => trim($input['href']),
|
||||
)), 'Not a valid URL: ' . $input['href']);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
$this->assertRaw(t(' has been created.',
|
||||
array('@type' => 'Basic Page', '%title' => $edit['title'])),
|
||||
'Page created: ' . $input['href']);
|
||||
$this->assertRaw(' ' . t('has been created.',
|
||||
array('@type' => 'Basic Page', '%title' => $edit['title'])),
|
||||
'Page created: ' . $input['href']);
|
||||
}
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonym user
|
||||
// Change to Anonymous user.
|
||||
$this->drupalLogout();
|
||||
|
||||
$this->drupalGet($url);
|
||||
//debug($this);
|
||||
// If simpletest starts using something to override the error system, this will flag
|
||||
// us and let us know it's broken.
|
||||
// debug($this);
|
||||
// If simpletest starts using something to override the error system, this
|
||||
// will flag us and let us know it's broken.
|
||||
$this->assertFalse(libxml_use_internal_errors(TRUE));
|
||||
if (isset($input['expected_href'])) {
|
||||
$path = '//a[@href="'. $input['expected_href'] .'" and text()="'. $input['label'] .'"]';
|
||||
$path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
|
||||
}
|
||||
else {
|
||||
$path = '//a[@href="'. $input['href'] .'" and text()="'. $input['label'] .'"]';
|
||||
$path = '//a[@href="' . $input['href'] . '" and text()="' . $input['label'] . '"]';
|
||||
}
|
||||
//$this->pass(htmlentities($path));
|
||||
$elements = $this->xpath($path);
|
||||
libxml_use_internal_errors(FALSE);
|
||||
$this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
|
||||
}
|
||||
//libxml_use_internal_errors(FALSE);
|
||||
// libxml_use_internal_errors(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static Link Create.
|
||||
*
|
||||
* Testing that if you use <strong> in a static title for your link, that the
|
||||
* title actually displays <strong>.
|
||||
*/
|
||||
function testStaticLinkCreate() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
|
||||
public function testStaticLinkCreate() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$field_name = 'field_'. $name;
|
||||
$field_name = 'field_' . $name;
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
'fields[_add_new_field][field_name]' => $name,
|
||||
@@ -190,17 +215,18 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$this->drupalPost(NULL, array(
|
||||
'instance[settings][title]' => 'value',
|
||||
'instance[settings][title_value]' => '<strong>'. $name .'</strong>'), t('Save settings'));
|
||||
'instance[settings][title_value]' => '<strong>' . $name . '</strong>',
|
||||
), t('Save settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName()
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
);
|
||||
|
||||
$edit = array(
|
||||
@@ -211,22 +237,88 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw(l('<strong>'. $name .'</strong>', $input['href'], array('html' => TRUE)));
|
||||
$this->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array('html' => TRUE)));
|
||||
}
|
||||
|
||||
/**
|
||||
* If we're creating a new field and just hit 'save' on the default options, we want to make
|
||||
* sure they are set to the expected results.
|
||||
* CRUD Title Only Title No Link.
|
||||
*
|
||||
* Testing that if you have the title but no url, the title is not sanitized
|
||||
* twice.
|
||||
*/
|
||||
function testCRUDCreateFieldDefaults() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
|
||||
public function testCrudTitleOnlyTitleNoLink() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$field_name = 'field_' . $name;
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
'fields[_add_new_field][field_name]' => $name,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
'fields[_add_new_field][widget_type]' => 'link_field',
|
||||
);
|
||||
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$this->drupalPost(NULL, array(
|
||||
'instance[settings][url]' => 1,
|
||||
), t('Save settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'title' => 'This & That',
|
||||
'href' => '',
|
||||
);
|
||||
|
||||
$edit = array(
|
||||
'title' => $name,
|
||||
$field_name . '[und][0][title]' => $input['title'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw('This & That');
|
||||
}
|
||||
|
||||
/**
|
||||
* CRUD Create Field Defaults.
|
||||
*
|
||||
* If we're creating a new field and just hit 'save' on the default options,
|
||||
* we want to make sure they are set to the expected results.
|
||||
*/
|
||||
public function testCrudCreateFieldDefaults() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
@@ -242,25 +334,178 @@ class LinkUITest extends DrupalWebTestcase {
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
//_content_type_info(TRUE);
|
||||
//$fields = content_fields();
|
||||
//$field = $fields['field_'. $name];
|
||||
//$field = field_info_field('field_'. $name);
|
||||
|
||||
_field_info_collate_fields(TRUE);
|
||||
$instances = field_info_instances('node', 'page');
|
||||
//$this->debug($instances);
|
||||
//$this->assert('debug', '<pre>'. print_r($instances, TRUE) .'</pre>', 'Debug');
|
||||
$instance = $instances['field_'. $name];
|
||||
//$this->assertTrue(1 === $instance['validate_url'], 'Make sure validation is on.');
|
||||
|
||||
$instance = $instances['field_' . $name];
|
||||
$this->assertFalse($instance['required'], 'Make sure field is not required.');
|
||||
$this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
|
||||
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be off by default.');
|
||||
$this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
|
||||
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
|
||||
$this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
|
||||
$this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
|
||||
$this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
|
||||
$this->assertFalse($instance['settings']['attributes']['class'], 'By default, no class should be set.');
|
||||
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
|
||||
|
||||
//$this->fail('<pre>'. print_r($fields['field_'. $name], TRUE) .'</pre>');
|
||||
}
|
||||
|
||||
/**
|
||||
* CRUD Create Field With Class.
|
||||
*
|
||||
* If we're creating a new field and just hit 'save' on the default options,
|
||||
* we want to make sure they are set to the expected results.
|
||||
*/
|
||||
public function testCrudCreateFieldWithClass() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
'fields[_add_new_field][field_name]' => $name,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
'fields[_add_new_field][widget_type]' => 'link_field',
|
||||
);
|
||||
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
|
||||
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$link_class_name = 'basic-link-' . strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'instance[settings][attributes][class]' => $link_class_name,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
|
||||
_field_info_collate_fields(TRUE);
|
||||
$instances = field_info_instances('node', 'page');
|
||||
|
||||
$instance = $instances['field_' . $name];
|
||||
$this->assertFalse($instance['required'], 'Make sure field is not required.');
|
||||
$this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
|
||||
$this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
|
||||
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
|
||||
$this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
|
||||
$this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
|
||||
$this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
|
||||
$this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'One class should be set.');
|
||||
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
|
||||
|
||||
// Now, let's create a node with this field and make sure the link shows up:
|
||||
// create page form.
|
||||
$field_name = 'field_' . $name;
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'title' => 'This & That',
|
||||
'href' => 'http://www.example.com/',
|
||||
);
|
||||
|
||||
$edit = array(
|
||||
'title' => $field_name,
|
||||
$field_name . '[und][0][title]' => $input['title'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw('This & That');
|
||||
$this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Class $link_class_name exists on page.");
|
||||
}
|
||||
|
||||
/**
|
||||
* CRUD Create Field With Two Classes.
|
||||
*
|
||||
* If we're creating a new field and just hit 'save' on the default options,
|
||||
* we want to make sure they are set to the expected results.
|
||||
*/
|
||||
public function testCrudCreateFieldWithTwoClasses() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
'fields[_add_new_field][field_name]' => $name,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
'fields[_add_new_field][widget_type]' => 'link_field',
|
||||
);
|
||||
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
|
||||
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$link_class_name = 'basic-link ' . strtoupper($this->randomName());
|
||||
$edit = array(
|
||||
'instance[settings][attributes][class]' => $link_class_name,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
|
||||
_field_info_collate_fields(TRUE);
|
||||
$instances = field_info_instances('node', 'page');
|
||||
|
||||
$instance = $instances['field_' . $name];
|
||||
$this->assertFalse($instance['required'], 'Make sure field is not required.');
|
||||
$this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
|
||||
$this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
|
||||
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
|
||||
$this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
|
||||
$this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
|
||||
$this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
|
||||
$this->assertEqual($instance['settings']['attributes']['class'], $link_class_name, 'Two classes should be set.');
|
||||
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
|
||||
|
||||
// Now, let's create a node with this field and make sure the link shows up:
|
||||
// create page form.
|
||||
$field_name = 'field_' . $name;
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'title' => 'This & That',
|
||||
'href' => 'http://www.example.com/',
|
||||
);
|
||||
|
||||
$edit = array(
|
||||
'title' => $field_name,
|
||||
$field_name . '[und][0][title]' => $input['title'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw('This & That');
|
||||
$this->assertPattern('|class\s?=\s?"' . $link_class_name . '"|', "Classes $link_class_name exist on page.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains simpletests making sure entity_token integration works.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Testing that tokens can be used in link titles.
|
||||
*/
|
||||
class LinkEntityTokenTest extends LinkBaseTestClass {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link entity tokens test',
|
||||
'description' => 'Tests that a link field appears properly in entity tokens',
|
||||
'group' => 'Link',
|
||||
'dependencies' => array('token', 'entity', 'entity_token'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'token';
|
||||
$modules[] = 'entity';
|
||||
$modules[] = 'entity_token';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link field, fills it, then uses a loaded node to test tokens.
|
||||
*/
|
||||
public function testFieldTokenNodeLoaded() {
|
||||
// Create field.
|
||||
$settings = array(
|
||||
'instance[settings][enable_tokens]' => 0,
|
||||
);
|
||||
$field_name = $this->createLinkField('page',
|
||||
$settings);
|
||||
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
// $field_name = 'field_' . $name;.
|
||||
$this->assertField($field_name . '[und][0][title]', 'Title found');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$token_url_tests = array(
|
||||
1 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
2 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '?property=value',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
3 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '#position',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
4 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
);
|
||||
// @codingStandardsIgnoreLine
|
||||
// $this->assert('pass', '<pre>' . print_r($token_url_tests, TRUE) . '<pre>');.
|
||||
foreach ($token_url_tests as &$input) {
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
'title' => $input['label'],
|
||||
$field_name . '[und][0][title]' => $input['label'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
$input['url'] = $url;
|
||||
}
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
|
||||
foreach ($token_url_tests as $index => $input2) {
|
||||
$node = node_load($index);
|
||||
$this->assertNotEqual(NULL, $node, "Do we have a node?");
|
||||
$this->assertEqual($node->nid, $index, "Test that we have a node.");
|
||||
$token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
|
||||
$assert_data = token_replace($token_name,
|
||||
array('node' => $node));
|
||||
$this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Token Node Viewed.
|
||||
*
|
||||
* Creates a link field, fills it, then uses a loaded and node_view'd node to
|
||||
* test tokens.
|
||||
*/
|
||||
public function testFieldTokenNodeViewed() {
|
||||
// Create field.
|
||||
$settings = array(
|
||||
'instance[settings][enable_tokens]' => 0,
|
||||
);
|
||||
$field_name = $this->createLinkField('page',
|
||||
$settings);
|
||||
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
// $field_name = 'field_' . $name;.
|
||||
$this->assertField($field_name . '[und][0][title]', 'Title found');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$token_url_tests = array(
|
||||
1 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
2 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '?property=value',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
3 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '#position',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
4 => array(
|
||||
'href' => 'http://example.com/' . $this->randomName() . '#lower?property=value2',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
);
|
||||
|
||||
//@codingStandardsIgnoreLine
|
||||
// $this->assert('pass', '<pre>' . print_r($token_url_tests, TRUE) . '<pre>');.
|
||||
foreach ($token_url_tests as &$input) {
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
'title' => $input['label'],
|
||||
$field_name . '[und][0][title]' => $input['label'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
$input['url'] = $url;
|
||||
}
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
|
||||
foreach ($token_url_tests as $index => $input2) {
|
||||
$node = node_load($index);
|
||||
$this->assertNotEqual(NULL, $node, "Do we have a node?");
|
||||
$this->assertEqual($node->nid, $index, "Test that we have a node.");
|
||||
$token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
|
||||
$assert_data = token_replace($token_name,
|
||||
array('node' => $node));
|
||||
$this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that exercise the relative / absolute output of the link module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Testing that absolute / relative outputs match the expected format.
|
||||
*/
|
||||
class LinkMultilingualTestCase extends LinkBaseTestClass {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$this->permissions = array_merge($this->permissions, array(
|
||||
'administer site configuration',
|
||||
'administer languages',
|
||||
));
|
||||
$modules[] = 'locale';
|
||||
$modules[] = 'locale_test';
|
||||
$modules[] = 'translation';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables and configured language related stuff.
|
||||
*/
|
||||
public function setUpLanguage() {
|
||||
global $language_url;
|
||||
$this->drupalGet('admin/config/regional/language');
|
||||
// Enable the path prefix for the default language: this way any un-prefixed
|
||||
// URL must have a valid fallback value.
|
||||
$edit = array('prefix' => 'en');
|
||||
$this->drupalPost('admin/config/regional/language/edit/en', $edit, t('Save language'));
|
||||
$language_url->prefix = $language_url->language;
|
||||
|
||||
// Add custom language - as we need more than 1 language to be multilingual.
|
||||
// Code for the language.
|
||||
$langcode = 'xx';
|
||||
// The English name for the language.
|
||||
$name = $this->randomName(16);
|
||||
// The native name for the language.
|
||||
$native = $this->randomName(16);
|
||||
$edit = array(
|
||||
'langcode' => $langcode,
|
||||
'name' => $name,
|
||||
'native' => $native,
|
||||
'prefix' => $langcode,
|
||||
'direction' => '0',
|
||||
);
|
||||
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
|
||||
|
||||
// Enable URL language detection and selection.
|
||||
$edit = array('language[enabled][locale-url]' => 1);
|
||||
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
||||
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, array(LOCALE_LANGUAGE_NEGOTIATION_URL));
|
||||
|
||||
// Reset static caching.
|
||||
drupal_static_reset('language_list');
|
||||
drupal_static_reset('locale_url_outbound_alter');
|
||||
drupal_static_reset('locale_language_url_rewrite_url');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class LinkMultilingualPathTest extends LinkMultilingualTestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link language path prefix',
|
||||
'description' => 'Tests that path properly work with language path prefixes.',
|
||||
'group' => 'Link',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link field, fills it, then uses a loaded node to test paths.
|
||||
*/
|
||||
public function testLanguagePrefixedPaths() {
|
||||
$this->setUpLanguage();
|
||||
|
||||
// Create fields.
|
||||
// Field for absolute urls.
|
||||
$field_name_absolute = $this->createLinkField('page');
|
||||
|
||||
// Field for relative urls.
|
||||
$settings = array(
|
||||
'instance[settings][absolute_url]' => FALSE,
|
||||
);
|
||||
$field_name_relative = $this->createLinkField('page', $settings);
|
||||
|
||||
// Check the node edit form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name_absolute . '[und][0][title]', 'Title absolute found');
|
||||
$this->assertField($field_name_absolute . '[und][0][url]', 'URL absolute found');
|
||||
$this->assertField($field_name_relative . '[und][0][title]', 'Title relative found');
|
||||
$this->assertField($field_name_relative . '[und][0][url]', 'URL relative found');
|
||||
|
||||
// Create test content.
|
||||
$url_tests = array(
|
||||
1 => array(
|
||||
'href' => 'http://dummy.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
2 => array(
|
||||
'href' => 'node/1',
|
||||
'label' => $this->randomName(),
|
||||
),
|
||||
3 => array(
|
||||
'href' => 'node/1?property=value',
|
||||
'label' => $this->randomName(),
|
||||
'query' => array('property' => 'value'),
|
||||
),
|
||||
4 => array(
|
||||
'href' => 'node/1#position',
|
||||
'label' => $this->randomName(),
|
||||
'fragment' => 'position',
|
||||
),
|
||||
5 => array(
|
||||
'href' => 'node/1?property=value2#lower',
|
||||
'label' => $this->randomName(),
|
||||
'fragment' => 'lower',
|
||||
'query' => array('property' => 'value2'),
|
||||
),
|
||||
);
|
||||
foreach ($url_tests as $index => &$input) {
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
'title' => $input['label'],
|
||||
$field_name_absolute . '[und][0][title]' => $input['label'],
|
||||
$field_name_absolute . '[und][0][url]' => $input['href'],
|
||||
$field_name_relative . '[und][0][title]' => $input['label'],
|
||||
$field_name_relative . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
$input['url'] = $url;
|
||||
}
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
|
||||
foreach (array_slice($url_tests, 1, NULL, TRUE) as $index => $input2) {
|
||||
$node = node_load($index);
|
||||
$this->assertNotEqual(NULL, $node, "Do we have a node?");
|
||||
$this->assertEqual($node->nid, $index, "Test that we have a node.");
|
||||
$this->drupalGet('node/' . $index);
|
||||
|
||||
$relative_expected = url('node/1', array('absolute' => FALSE) + $input2);
|
||||
$absolute_expected = url('node/1', array('absolute' => TRUE) + $input2);
|
||||
|
||||
$absolute_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_absolute) . '")]/div/div/a/@href');
|
||||
$absolute_result = (string) reset($absolute_result);
|
||||
$this->assertEqual($absolute_result, $absolute_expected, "Absolute url output ('" . $absolute_result . "') looks as expected ('" . $absolute_expected . "')");
|
||||
|
||||
$relative_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_relative) . '")]/div/div/a/@href');
|
||||
$relative_result = (string) reset($relative_result);
|
||||
$this->assertEqual($relative_result, $relative_expected, "Relative url output ('" . $relative_result . "') looks as expected ('" . $relative_expected . "')");
|
||||
}
|
||||
|
||||
// Check if this works with the alias too.
|
||||
// Add a path alias for node 1.
|
||||
$path = array(
|
||||
'source' => 'node/1',
|
||||
'alias' => $url_tests[1]['label'],
|
||||
);
|
||||
path_save($path);
|
||||
// Another iteration over the same nodes - this time they should use the
|
||||
// path alias.
|
||||
foreach (array_slice($url_tests, 1, NULL, TRUE) as $index => $input2) {
|
||||
$node = node_load($index);
|
||||
$this->assertNotEqual(NULL, $node, "Do we have a node?");
|
||||
$this->assertEqual($node->nid, $index, "Test that we have a node.");
|
||||
$this->drupalGet('node/' . $index);
|
||||
|
||||
$relative_expected = url('node/1', array('absolute' => FALSE) + $input2);
|
||||
$absolute_expected = url('node/1', array('absolute' => TRUE) + $input2);
|
||||
|
||||
$absolute_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_absolute) . '")]/div/div/a/@href');
|
||||
$absolute_result = (string) reset($absolute_result);
|
||||
$this->assertEqual($absolute_result, $absolute_expected, "Absolute alias-url output ('" . $absolute_result . "') looks as expected ('" . $absolute_expected . "')");
|
||||
|
||||
$relative_result = $this->xpath('//*[contains(@class, "field-name-' . drupal_clean_css_identifier($field_name_relative) . '")]/div/div/a/@href');
|
||||
$relative_result = (string) reset($relative_result);
|
||||
$this->assertEqual($relative_result, $relative_expected, "Relative alias-url output ('" . $relative_result . "') looks as expected ('" . $relative_expected . "')");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,10 +5,15 @@
|
||||
* Link base test file - contains common functions for testing links.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base Test Class.
|
||||
*/
|
||||
class LinkBaseTestClass extends DrupalWebTestCase {
|
||||
|
||||
protected $permissions = array(
|
||||
'access content',
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access comments',
|
||||
@@ -17,17 +22,21 @@ class LinkBaseTestClass extends DrupalWebTestCase {
|
||||
'create page content',
|
||||
);
|
||||
|
||||
function setUp() {
|
||||
$modules = func_get_args();
|
||||
$modules = (isset($modules[0]) && is_array($modules[0]) ? $modules[0] : $modules);
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'field_ui';
|
||||
$modules[] = 'link';
|
||||
parent::setUp($modules);
|
||||
|
||||
|
||||
$this->web_user = $this->drupalCreateUser($this->permissions);
|
||||
$this->drupalLogin($this->web_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Link Field.
|
||||
*/
|
||||
protected function createLinkField($node_type = 'page', $settings = array()) {
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
@@ -36,8 +45,8 @@ class LinkBaseTestClass extends DrupalWebTestCase {
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
'fields[_add_new_field][widget_type]' => 'link_field',
|
||||
);
|
||||
$field_name = 'field_'. $name;
|
||||
$this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
|
||||
$field_name = 'field_' . $name;
|
||||
$this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$this->drupalPost(NULL, $settings, t('Save settings'));
|
||||
|
||||
@@ -48,4 +57,5 @@ class LinkBaseTestClass extends DrupalWebTestCase {
|
||||
|
||||
return $field_name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Testing that tokens can be used in link titles
|
||||
* Testing that tokens can be used in link titles.
|
||||
*/
|
||||
class LinkTokenTest extends LinkBaseTestClass {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link tokens - browser test',
|
||||
@@ -19,34 +22,39 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp($modules = array()) {
|
||||
parent::setUp(array('token'));
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'token';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link field with a required title enabled for user-entered tokens.
|
||||
*
|
||||
* Creates a node with a token in the link title and checks the value.
|
||||
*/
|
||||
function testUserTokenLinkCreate() {
|
||||
// create field
|
||||
public function testUserTokenLinkCreate() {
|
||||
// Create field.
|
||||
$settings = array(
|
||||
'instance[settings][enable_tokens]' => 1,
|
||||
);
|
||||
$field_name = $this->createLinkField('page',
|
||||
$settings);
|
||||
$settings);
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
//$field_name = 'field_' . $name;
|
||||
// $field_name = 'field_' . $name;.
|
||||
$this->assertField($field_name . '[und][0][title]', 'Title found');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
);
|
||||
|
||||
//$this->drupalLogin($this->web_user);
|
||||
// $this->drupalLogin($this->web_user);.
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
@@ -57,36 +65,36 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw(l($input['label'] . ' page', $input['href']));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a link field with a static title and an admin-entered token.
|
||||
*
|
||||
* Creates a node with a link and checks the title value.
|
||||
*/
|
||||
function testStaticTokenLinkCreate() {
|
||||
|
||||
// create field
|
||||
public function testStaticTokenLinkCreate() {
|
||||
// Create field.
|
||||
$name = $this->randomName();
|
||||
$settings = array(
|
||||
'instance[settings][title]' => 'value',
|
||||
'instance[settings][title_value]' => $name .' [node:content-type:machine-name]');
|
||||
'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]',
|
||||
);
|
||||
$field_name = $this->createLinkField('page', $settings);
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName()
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
);
|
||||
|
||||
//$this->drupalLogin($this->web_user);
|
||||
// $this->drupalLogin($this->web_user);.
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
@@ -97,7 +105,7 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
@@ -106,30 +114,31 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
|
||||
/**
|
||||
* Creates a link field with a static title and an admin-entered token.
|
||||
*
|
||||
* Creates a node with a link and checks the title value.
|
||||
*
|
||||
* Basically, I want to make sure the [title-raw] token works, because it's a
|
||||
* token that changes from node to node, where [type]'s always going to be the
|
||||
* same.
|
||||
*/
|
||||
function testStaticTokenLinkCreate2() {
|
||||
|
||||
// create field
|
||||
public function testStaticTokenLinkCreate2() {
|
||||
// Create field.
|
||||
$name = $this->randomName();
|
||||
$settings = array(
|
||||
'instance[settings][title]' => 'value',
|
||||
'instance[settings][title_value]' => $name .' [node:title]');
|
||||
'instance[settings][title_value]' => $name . ' [node:title]',
|
||||
);
|
||||
$field_name = $this->createLinkField('page', $settings);
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName()
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
);
|
||||
|
||||
//$this->drupalLogin($this->web_user);
|
||||
// $this->drupalLogin($this->web_user);.
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$edit = array(
|
||||
@@ -140,27 +149,31 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw(l($name .' '. $name, $input['href']));
|
||||
$this->assertRaw(l($name . ' ' . $name, $input['href']));
|
||||
}
|
||||
|
||||
// This test doesn't seem to actually work, due to lack of 'title' in url.
|
||||
function _test_Link_With_Title_Attribute_token_url_form() {
|
||||
/* $this->loginWithPermissions($this->permissions);
|
||||
/**
|
||||
* This test doesn't seem to actually work, due to lack of 'title' in url.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function xTestLinkWithTitleAttributeTokenUrlForm() {
|
||||
/* $this->loginWithPermissions($this->permissions);
|
||||
$this->acquireContentTypes(1);
|
||||
$field_settings = array(
|
||||
'type' => 'link',
|
||||
'widget_type' => 'link',
|
||||
'type_name' => $this->content_types[0]->name,
|
||||
'attributes' => array(
|
||||
'class' => '',
|
||||
'target' => 'default',
|
||||
'rel' => 'nofollow',
|
||||
'title' => '',
|
||||
),
|
||||
'type' => 'link',
|
||||
'widget_type' => 'link',
|
||||
'type_name' => $this->content_types[0]->name,
|
||||
'attributes' => array(
|
||||
'class' => '',
|
||||
'target' => 'default',
|
||||
'rel' => 'nofollow',
|
||||
'title' => '',
|
||||
),
|
||||
);
|
||||
|
||||
$field = $this->createField($field_settings, 0);
|
||||
@@ -170,11 +183,12 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$url_type = str_replace('_', '-', $this->content_types[0]->type);
|
||||
|
||||
$edit = array('attributes[title]' => '['. $field_name .'-url]',
|
||||
'enable_tokens' => TRUE);
|
||||
|
||||
'enable_tokens' => TRUE);
|
||||
// @codingStandardsIgnoreLine
|
||||
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
|
||||
$edit, t('Save field settings'));
|
||||
$edit, t('Save field settings'));
|
||||
$this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));*/
|
||||
// @codingStandardsIgnoreEnd
|
||||
$name = $this->randomName();
|
||||
$settings = array(
|
||||
'instance[settings][attributes][rel]' => 'nofollow',
|
||||
@@ -183,40 +197,42 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$field_name = $this->createLinkField('page', $settings);
|
||||
|
||||
// So, having saved this field_name, let's see if it works...
|
||||
//$this->acquireNodes(1);
|
||||
|
||||
//$node = node_load($this->nodes[0]->nid);
|
||||
|
||||
//$this->drupalGet('node/'. $this->nodes[0]->nid);
|
||||
|
||||
// $this->acquireNodes(1);
|
||||
// $node = node_load($this->nodes[0]->nid);
|
||||
// $this->drupalGet('node/'. $this->nodes[0]->nid);.
|
||||
$edit = array();
|
||||
$test_link_url = 'http://www.example.com/test';
|
||||
$edit[$field_name .'[und][0][url]'] = $test_link_url;
|
||||
$title = 'title_'. $this->randomName(20);
|
||||
$edit[$field_name .'[und][0][title]'] = $title;
|
||||
$edit[$field_name . '[und][0][url]'] = $test_link_url;
|
||||
$title = 'title_' . $this->randomName(20);
|
||||
$edit[$field_name . '[und][0][title]'] = $title;
|
||||
$edit['title'] = $name;
|
||||
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
// Make sure we get a new version!
|
||||
//$node = node_load($this->nodes[0]->nid, NULL, TRUE);
|
||||
// $node = node_load($this->nodes[0]->nid, NULL, TRUE);.
|
||||
$this->assertText(t('Basic page @title has been updated.',
|
||||
array('@title' => $name)));
|
||||
array('@title' => $name)));
|
||||
|
||||
//$this->drupalGet('node/'. $node->nid);
|
||||
// $this->drupalGet('node/'. $node->nid);.
|
||||
$this->assertText($title, 'Make sure the link title/text shows');
|
||||
$this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
|
||||
$this->assertNoRaw(' title="['. $field_name .'-url]"');
|
||||
$this->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
|
||||
$this->assertNoRaw(' title="[' . $field_name . '-url]"');
|
||||
$this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));
|
||||
//$this->fail($this->content);
|
||||
// $this->fail($this->content);.
|
||||
}
|
||||
|
||||
/**
|
||||
* Link With Title Attribute token title form.
|
||||
*
|
||||
* If the title of the link is set to the title attribute, then the title
|
||||
* attribute isn't supposed to show.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function _test_Link_With_Title_Attribute_token_title_form() {
|
||||
public function xTestLinkWithTitleAttributeTokenTitleForm() {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->loginWithPermissions($this->permissions);
|
||||
$this->acquireContentTypes(1);
|
||||
$field_settings = array(
|
||||
@@ -233,51 +249,57 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
|
||||
$field = $this->createField($field_settings, 0);
|
||||
$field_name = $field['field_name'];
|
||||
$field_db_info = content_database_info($field);
|
||||
$url_type = str_replace('_', '-', $this->content_types[0]->type);
|
||||
|
||||
$edit = array('attributes[title]' => '['. $field_name .'-title]',
|
||||
'enable_tokens' => TRUE);
|
||||
$edit = array(
|
||||
'attributes[title]' => '[' . $field_name . '-title]',
|
||||
'enable_tokens' => TRUE,
|
||||
);
|
||||
|
||||
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
|
||||
$edit, t('Save field settings'));
|
||||
$this->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'],
|
||||
$edit, t('Save field settings'));
|
||||
$this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));
|
||||
|
||||
// So, having saved this field_name, let's see if it works...
|
||||
$this->acquireNodes(1);
|
||||
|
||||
$node = node_load($this->nodes[0]->nid);
|
||||
|
||||
$this->drupalGet('node/'. $this->nodes[0]->nid);
|
||||
$this->drupalGet('node/' . $this->nodes[0]->nid);
|
||||
|
||||
$edit = array();
|
||||
$edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test';
|
||||
$title = 'title_'. $this->randomName(20);
|
||||
$edit[$field['field_name'] .'[0][title]'] = $title;
|
||||
$edit[$field['field_name'] . '[0][url]'] = 'http://www.example.com/test';
|
||||
$title = 'title_' . $this->randomName(20);
|
||||
$edit[$field['field_name'] . '[0][title]'] = $title;
|
||||
|
||||
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
|
||||
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
|
||||
|
||||
// Make sure we get a new version!
|
||||
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
|
||||
$this->assertText(t('@type @title has been updated.',
|
||||
array('@title' => $node->title,
|
||||
'@type' => $this->content_types[0]->name)));
|
||||
array(
|
||||
'@title' => $node->title,
|
||||
'@type' => $this->content_types[0]->name,
|
||||
)));
|
||||
|
||||
$this->drupalGet('node/'. $node->nid);
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertText($title, 'Make sure the link title/text shows');
|
||||
$this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
|
||||
$this->assertNoRaw(' title="['. $field_name .'-title]"');
|
||||
//$this->fail($this->content);
|
||||
$this->assertNoRaw(' title="' . $title . '"', "We should not show the link title as the title attribute?");
|
||||
$this->assertNoRaw(' title="[' . $field_name . '-title]"');
|
||||
// $this->fail($this->content);.
|
||||
}
|
||||
|
||||
/**
|
||||
* Trying to set the url to contain a token.
|
||||
* Trying to set the url to contain a token.
|
||||
*/
|
||||
function _testUserTokenLinkCreateInURL() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
|
||||
public function xTestUserTokenLinkCreateInUrl() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'_add_new_field[label]' => $name,
|
||||
@@ -288,20 +310,21 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$this->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
|
||||
$this->drupalPost(NULL, array(
|
||||
'title' => 'required',
|
||||
'enable_tokens' => 1), t('Save field settings'));
|
||||
'enable_tokens' => 1,
|
||||
), t('Save field settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Added field %label.', array('%label' => $name)), 'Field added');
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField($field_name . '[0][title]', 'Title found');
|
||||
$this->assertField($field_name . '[0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
);
|
||||
|
||||
$this->drupalLogin($this->web_user);
|
||||
@@ -315,22 +338,27 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw(l($input['label'], $input['href'] .'/page'));
|
||||
//$this->fail($this->content);
|
||||
$this->assertRaw(l($input['label'], $input['href'] . '/page'));
|
||||
// $this->fail($this->content);.
|
||||
}
|
||||
|
||||
/**
|
||||
* Trying to set the url to contain a token.
|
||||
* Trying to set the url to contain a token.
|
||||
*/
|
||||
function _testUserTokenLinkCreateInURL2() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
|
||||
public function xTestUserTokenLinkCreateInUrl2() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'_add_new_field[label]' => $name,
|
||||
@@ -341,20 +369,21 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$this->drupalPost('admin/content/node-type/page/fields', $edit, t('Save'));
|
||||
$this->drupalPost(NULL, array(
|
||||
'title' => 'required',
|
||||
'enable_tokens' => 1), t('Save field settings'));
|
||||
'enable_tokens' => 1,
|
||||
), t('Save field settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Added field %label.', array('%label' => $name)), 'Field added');
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField($field_name . '[0][title]', 'Title found');
|
||||
$this->assertField($field_name . '[0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
'href' => 'http://example.com/' . $this->randomName(),
|
||||
'label' => $this->randomName(),
|
||||
);
|
||||
|
||||
$this->drupalLogin($this->web_user);
|
||||
@@ -368,10 +397,75 @@ class LinkTokenTest extends LinkBaseTestClass {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$url = $this->getUrl();
|
||||
|
||||
// change to anonymous user
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw(l($input['label'], $input['href'] .'/'. $this->web_user->uid));
|
||||
$this->assertRaw(l($input['label'], $input['href'] . '/' . $this->web_user->uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* CRUD Title Only Title No Link.
|
||||
*
|
||||
* Test that if you have a title and no url on a field which does not have
|
||||
* tokens enabled, that the title is sanitized once.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function testCRUDTitleOnlyTitleNoLink2() {
|
||||
//@codingStandardsIgnoreEnd
|
||||
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'access content',
|
||||
'create page content',
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$field_name = 'field_' . $name;
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
'fields[_add_new_field][field_name]' => $name,
|
||||
'fields[_add_new_field][type]' => 'link_field',
|
||||
'fields[_add_new_field][widget_type]' => 'link_field',
|
||||
);
|
||||
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$this->drupalPost(NULL, array(
|
||||
'instance[settings][url]' => 1,
|
||||
'instance[settings][enable_tokens]' => 0,
|
||||
), t('Save settings'));
|
||||
|
||||
// Is field created?
|
||||
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
|
||||
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->assertField($field_name . '[und][0][url]', 'URL found');
|
||||
|
||||
$input = array(
|
||||
'title' => 'This & That',
|
||||
'href' => '',
|
||||
);
|
||||
|
||||
$edit = array(
|
||||
'title' => $name,
|
||||
$field_name . '[und][0][title]' => $input['title'],
|
||||
$field_name . '[und][0][url]' => $input['href'],
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
|
||||
$url = $this->getUrl();
|
||||
|
||||
// Change to anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($url);
|
||||
|
||||
$this->assertRaw('This & That');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,14 @@
|
||||
* Tests that exercise the validation functions in the link module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validate Test Case.
|
||||
*/
|
||||
class LinkValidateTestCase extends LinkBaseTestClass {
|
||||
|
||||
/**
|
||||
* Create Link.
|
||||
*/
|
||||
protected function createLink($url, $title, $attributes = array()) {
|
||||
return array(
|
||||
'url' => $url,
|
||||
@@ -16,36 +22,41 @@ class LinkValidateTestCase extends LinkBaseTestClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a url, and sees if it can validate that the url is valid.
|
||||
* Takes a URL, sees if it can validate that the URL is valid.
|
||||
*/
|
||||
protected function link_test_validate_url($url) {
|
||||
|
||||
protected function linkTestValidateUrl($url) {
|
||||
$field_name = $this->createLinkField();
|
||||
|
||||
$permission = 'create page content';
|
||||
$this->checkPermissions(array($permission), TRUE);
|
||||
|
||||
$this->drupalGet('node/add/page');
|
||||
|
||||
$label = $this->randomName();
|
||||
$edit = array(
|
||||
$settings = array(
|
||||
'title' => $label,
|
||||
$field_name . '[und][0][title]' => $label,
|
||||
$field_name . '[und][0][url]' => $url,
|
||||
$field_name => array(
|
||||
LANGUAGE_NONE => array(
|
||||
array(
|
||||
'title' => $label,
|
||||
'url' => $url,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertRaw(t(' has been created.'), 'Node created');
|
||||
|
||||
$nid = 1; //$matches[1];
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
$node = node_load($nid);
|
||||
$this->assertNotNull($node, ' has been created.', 'Node created');
|
||||
|
||||
$this->assertEqual($url, $node->{$field_name}['und'][0]['url']);
|
||||
$this->assertEqual($url, $node->{$field_name}[LANGUAGE_NONE][0]['url']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for Validate Test.
|
||||
*/
|
||||
class LinkValidateTest extends LinkValidateTestCase {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link Validation Tests',
|
||||
@@ -54,23 +65,29 @@ class LinkValidateTest extends LinkValidateTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_link_validate_basic_url() {
|
||||
$this->link_test_validate_url('http://www.example.com');
|
||||
/**
|
||||
* Validate basic URL.
|
||||
*/
|
||||
public function testLinkValidateBasicUrl() {
|
||||
$this->linkTestValidateUrl('http://www.example.com');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if we're stopped from posting a bad url on default validation.
|
||||
*/
|
||||
function test_link_validate_bad_url_validate_default() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages'));
|
||||
public function testLinkValidateBadUrlValidateDefault() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
@@ -87,35 +104,40 @@ class LinkValidateTest extends LinkValidateTestCase {
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
||||
|
||||
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
||||
|
||||
$edit = array(
|
||||
'title' => 'Simple Title',
|
||||
$field_name .'[und][0][url]' => 'edik:naw',
|
||||
$field_name . '[und][0][url]' => 'edik:naw',
|
||||
);
|
||||
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
||||
$this->assertText(t('The value @value provided for @field is not a valid URL.', array(
|
||||
'@value' => 'edik:naw',
|
||||
'@field' => $name,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if we're stopped from posting a bad url with validation on.
|
||||
*/
|
||||
function test_link_validate_bad_url_validate_on() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages'));
|
||||
public function testLinkValidateBadUrlValidateOn() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
@@ -132,36 +154,41 @@ class LinkValidateTest extends LinkValidateTestCase {
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
||||
|
||||
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
||||
|
||||
$edit = array(
|
||||
'title' => 'Simple Title',
|
||||
$field_name .'[und][0][url]' => 'edik:naw',
|
||||
$field_name . '[und][0][url]' => 'edik:naw',
|
||||
);
|
||||
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
||||
$this->assertText(t('The value @value provided for @field is not a valid URL.', array(
|
||||
'@field' => $name,
|
||||
'@value' => 'edik:naw',
|
||||
)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if we can post a bad url if the validation is expressly turned off.
|
||||
*/
|
||||
function test_link_validate_bad_url_validate_off() {
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages'));
|
||||
public function testLinkValidateBadUrlValidateOff() {
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'administer filters',
|
||||
'access content',
|
||||
'create page content',
|
||||
'access administration pages',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// create field
|
||||
// Create field.
|
||||
$name = strtolower($this->randomName());
|
||||
$edit = array(
|
||||
'fields[_add_new_field][label]' => $name,
|
||||
@@ -173,6 +200,7 @@ class LinkValidateTest extends LinkValidateTestCase {
|
||||
$this->drupalPost(NULL, array(), t('Save field settings'));
|
||||
$this->drupalPost(NULL, array('instance[settings][validate_url]' => FALSE), t('Save settings'));
|
||||
|
||||
// @codingStandardsIgnoreLine
|
||||
/*$instance_details = db_query("SELECT * FROM {field_config_instance} WHERE field_name = :field_name AND bundle = 'page'", array(':field_name' => 'field_'. $name))->fetchObject();
|
||||
$this->fail('<pre>'. print_r($instance_details, TRUE) .'</pre>');
|
||||
$this->fail('<pre>'. print_r(unserialize($instance_details->data), TRUE) .'</pre>');*/
|
||||
@@ -182,112 +210,150 @@ class LinkValidateTest extends LinkValidateTestCase {
|
||||
node_types_rebuild();
|
||||
menu_rebuild();
|
||||
|
||||
// create page form
|
||||
// Create page form.
|
||||
$this->drupalGet('node/add/page');
|
||||
$field_name = 'field_' . $name;
|
||||
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
|
||||
|
||||
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
|
||||
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
|
||||
|
||||
$edit = array(
|
||||
'title' => 'Simple Title',
|
||||
$field_name .'[und][0][url]' => 'edik:naw',
|
||||
$field_name . '[und][0][url]' => 'edik:naw',
|
||||
);
|
||||
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertNoText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
|
||||
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
|
||||
'%field' => $name,
|
||||
'%value' => 'edik:naw',
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a bad url can sneak through un-filtered if we play with the validation...
|
||||
* Validate switching between validation status.
|
||||
*
|
||||
* Test if a bad url can sneak through un-filtered if we play with the
|
||||
* validation...
|
||||
*/
|
||||
function x_test_link_validate_switching_between_validation_status() {
|
||||
public function xTestLinkValidateSwitchingBetweenValidationStatus() {
|
||||
$this->acquireContentTypes(1);
|
||||
$this->web_user = $this->drupalCreateUser(array('administer content types',
|
||||
'administer nodes',
|
||||
'access administration pages',
|
||||
'access content',
|
||||
'create '. $this->content_types[0]->type .' content',
|
||||
'edit any '. $this->content_types[0]->type .' content'));
|
||||
$this->web_user = $this->drupalCreateUser(array(
|
||||
'administer content types',
|
||||
'administer fields',
|
||||
'administer nodes',
|
||||
'access administration pages',
|
||||
'access content',
|
||||
'create ' . $this->content_types[0]->type . ' content',
|
||||
'edit any ' . $this->content_types[0]->type . ' content',
|
||||
));
|
||||
$this->drupalLogin($this->web_user);
|
||||
variable_set('node_options_'. $this->content_types[0]->name, array('status', 'promote'));
|
||||
variable_set('node_options_' . $this->content_types[0]->name, array(
|
||||
'status',
|
||||
'promote',
|
||||
));
|
||||
$field_settings = array(
|
||||
'type' => 'link',
|
||||
'widget_type' => 'link',
|
||||
'type_name' => $this->content_types[0]->name,
|
||||
'attributes' => array(), // <-- This is needed or we have an error
|
||||
// <-- This is needed or we have an error.
|
||||
'attributes' => array(),
|
||||
'validate_url' => 0,
|
||||
);
|
||||
|
||||
$field = $this->createField($field_settings, 0);
|
||||
//$this->fail('<pre>'. print_r($field, TRUE) .'</pre>');
|
||||
$field_db_info = content_database_info($field);
|
||||
|
||||
$this->acquireNodes(2);
|
||||
|
||||
$node = node_load($this->nodes[0]->nid);
|
||||
|
||||
$this->drupalGet('node/'. $this->nodes[0]->nid);
|
||||
$this->drupalGet('node/' . $this->nodes[0]->nid);
|
||||
|
||||
$edit = array();
|
||||
$title = $this->randomName();
|
||||
$url = 'javascript:alert("http://example.com/' . $this->randomName() . '")';
|
||||
$edit[$field['field_name'] .'[0][url]'] = $url;
|
||||
$edit[$field['field_name'] .'[0][title]'] = $title;
|
||||
$edit[$field['field_name'] . '[0][url]'] = $url;
|
||||
$edit[$field['field_name'] . '[0][title]'] = $title;
|
||||
|
||||
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
|
||||
//$this->pass($this->content);
|
||||
$this->assertNoText(t('The value provided for %field is not a valid URL.', array('%field' => $name)));
|
||||
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
|
||||
// $this->pass($this->content);.
|
||||
// @codingStandardsIgnoreLine
|
||||
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
|
||||
// @codingStandardsIgnoreLine
|
||||
'%field' => $name,
|
||||
'%value' => trim($url),
|
||||
)));
|
||||
|
||||
// Make sure we get a new version!
|
||||
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
|
||||
$this->assertEqual($url, $node->{$field['field_name']}[0]['url']);
|
||||
|
||||
$this->drupalGet('node/'. $node->nid);
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
|
||||
|
||||
// Turn the array validation back _on_.
|
||||
$edit = array('validate_url' => TRUE);
|
||||
$node_type_link = str_replace('_', '-', $node->type);
|
||||
//$this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
|
||||
//$this->fail($this->content);
|
||||
$this->drupalPost('admin/content/node-type/'. $node_type_link .'/fields/'. $field['field_name'], $edit, t('Save field settings'));
|
||||
// @codingStandardsIgnoreLine
|
||||
// $this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
|
||||
// $this->fail($this->content);.
|
||||
$this->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
|
||||
|
||||
$this->drupalGet('node/'. $node->nid);
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
// This actually works because the display_url goes through the core
|
||||
// url() function. But we should have a test that makes sure it continues
|
||||
// to work.
|
||||
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
|
||||
//$this->fail($this->content);
|
||||
|
||||
// $this->fail($this->content);.
|
||||
}
|
||||
|
||||
// Validate that '<front>' is a valid url.
|
||||
function test_link_front_url() {
|
||||
$this->link_test_validate_url('<front>');
|
||||
/**
|
||||
* Validate that '<front>' is a valid url.
|
||||
*/
|
||||
public function testLinkFrontUrl() {
|
||||
$this->linkTestValidateUrl('<front>');
|
||||
}
|
||||
|
||||
// Validate that an internal url would be accepted.
|
||||
function test_link_internal_url() {
|
||||
$this->link_test_validate_url('node/32');
|
||||
/**
|
||||
* Validate that an internal url would be accepted.
|
||||
*/
|
||||
public function testLinkInternalUrl() {
|
||||
// Create the content first.
|
||||
$node = $this->drupalCreateNode();
|
||||
|
||||
$link = 'node/' . $node->nid;
|
||||
$this->linkTestValidateUrl($link);
|
||||
$type = link_url_type($link);
|
||||
$this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
|
||||
}
|
||||
|
||||
// Validate a simple mailto.
|
||||
function test_link_mailto() {
|
||||
$this->link_test_validate_url('mailto:jcfiala@gmail.com');
|
||||
/**
|
||||
* Validate a simple mailto.
|
||||
*/
|
||||
public function testLinkMailto() {
|
||||
$this->linkTestValidateUrl('mailto:jcfiala@gmail.com');
|
||||
}
|
||||
|
||||
function test_link_external_https() {
|
||||
$this->link_test_validate_url('https://www.example.com/');
|
||||
/**
|
||||
* Check link external https.
|
||||
*/
|
||||
public function testLinkExternalHttps() {
|
||||
$this->linkTestValidateUrl('https://www.example.com/');
|
||||
}
|
||||
|
||||
function test_link_ftp() {
|
||||
$this->link_test_validate_url('ftp://www.example.com/');
|
||||
/**
|
||||
* Check link FTP.
|
||||
*/
|
||||
public function testLinkFtp() {
|
||||
$this->linkTestValidateUrl('ftp://www.example.com/');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Test News.
|
||||
*/
|
||||
class LinkValidateTestNews extends LinkValidateTestCase {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link News Validation Tests',
|
||||
@@ -296,18 +362,30 @@ class LinkValidateTestNews extends LinkValidateTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// Validate a news link to a message group
|
||||
function test_link_news() {
|
||||
$this->link_test_validate_url('news:comp.infosystems.www.misc');
|
||||
/**
|
||||
* Validate a news link to a message group.
|
||||
*/
|
||||
public function testLinkNews() {
|
||||
$this->linkTestValidateUrl('news:comp.infosystems.www.misc');
|
||||
}
|
||||
|
||||
// Validate a news link to a message id. Said ID copied off of google groups.
|
||||
function test_link_news_message() {
|
||||
$this->link_test_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
|
||||
/**
|
||||
* Validate a news link to a message id. Said ID copied off of google groups.
|
||||
*/
|
||||
public function testLinkNewsMessage() {
|
||||
$this->linkTestValidateUrl('news:hj0db8$vrm$1@news.eternal-september.org');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Specific URL.
|
||||
*/
|
||||
class LinkValidateSpecificURL extends LinkValidateTestCase {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link Specific URL Validation Tests',
|
||||
@@ -316,46 +394,66 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
// Lets throw in a lot of umlouts for testing!
|
||||
function test_umlout_url() {
|
||||
$this->link_test_validate_url('http://üÜü.exämple.com/nöde');
|
||||
/**
|
||||
* Lets throw in a lot of umlouts for testing!
|
||||
*/
|
||||
public function testUmloutUrl() {
|
||||
$this->linkTestValidateUrl('http://üÜü.exämple.com/nöde');
|
||||
}
|
||||
|
||||
function test_umlout_mailto() {
|
||||
$this->link_test_validate_url('mailto:Üser@exÅmple.com');
|
||||
/**
|
||||
* Check umlout mailto.
|
||||
*/
|
||||
public function testUmloutMailto() {
|
||||
$this->linkTestValidateUrl('mailto:Üser@exÅmple.com');
|
||||
}
|
||||
|
||||
function test_german_b_url() {
|
||||
$this->link_test_validate_url('http://www.test.com/ßstuff');
|
||||
/**
|
||||
* Check German b in URL, aka Eszett.
|
||||
*/
|
||||
public function testGermanEszettUrl() {
|
||||
$this->linkTestValidateUrl('http://www.test.com/ßstuff');
|
||||
}
|
||||
|
||||
function test_special_n_url() {
|
||||
$this->link_test_validate_url('http://www.testÑñ.com/');
|
||||
/**
|
||||
* Check Spanish ñ in URL.
|
||||
*/
|
||||
public function testSpecialEneUrl() {
|
||||
$this->linkTestValidateUrl('http://www.testÑñ.com/');
|
||||
}
|
||||
|
||||
function test_curly_brackets_in_query() {
|
||||
$this->link_test_validate_url('http://www.healthyteennetwork.org/index.asp?Type=B_PR&SEC={2AE1D600-4FC6-4B4D-8822-F1D5F072ED7B}&DE={235FD1E7-208D-4363-9854-4E6775EB8A4C}');
|
||||
/**
|
||||
* Curly brackets in query.
|
||||
*/
|
||||
public function testCurlyBracketsInQuery() {
|
||||
$this->linkTestValidateUrl('http://www.healthyteennetwork.org/index.asp?Type=B_PR&SEC={2AE1D600-4FC6-4B4D-8822-F1D5F072ED7B}&DE={235FD1E7-208D-4363-9854-4E6775EB8A4C}');
|
||||
}
|
||||
|
||||
/**
|
||||
* Here, we're testing that a very long url is stored properly in the db.
|
||||
*
|
||||
* Basicly, trying to test http://drupal.org/node/376818
|
||||
* Basically, trying to test http://drupal.org/node/376818
|
||||
*/
|
||||
function testLinkURLFieldIsBig() {
|
||||
public function testLinkUrlFieldIsBig() {
|
||||
$long_url = 'http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%80%E0%B8%9A%E0%B8%8D%E0%B8%88%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A%E0%B8%B9%E0%B8%97%E0%B8%B4%E0%B8%A8_%E0%B8%99%E0%B8%84%E0%B8%A3%E0%B8%A8%E0%B8%A3%E0%B8%B5%E0%B8%98%E0%B8%A3%E0%B8%A3%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A';
|
||||
$this->link_test_validate_url($long_url);
|
||||
$this->linkTestValidateUrl($long_url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A series of tests of links, only going against the link_validate_url function in link.module.
|
||||
* Validate Url Light.
|
||||
*
|
||||
* A series of tests of links, only going against the link_validate_url function
|
||||
* in link.module.
|
||||
*
|
||||
* Validation is guided by the rules in http://tools.ietf.org/html/rfc1738 !
|
||||
*/
|
||||
class LinkValidateUrlLight extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Link Light Validation Tests',
|
||||
@@ -365,73 +463,159 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the LINK type constants to english for display and debugging of tests
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function name_Link_Type($type) {
|
||||
public function setUp(array $modules = array()) {
|
||||
$modules[] = 'link';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Name Link Type.
|
||||
*
|
||||
* Translates the LINK type constants to english for display and debugging of
|
||||
* tests.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function name_Link_Type($type) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
switch ($type) {
|
||||
case LINK_FRONT:
|
||||
return "Front";
|
||||
|
||||
case LINK_EMAIL:
|
||||
return "Email";
|
||||
|
||||
case LINK_TEL:
|
||||
return "Telephone";
|
||||
|
||||
case LINK_NEWS:
|
||||
return "Newsgroup";
|
||||
|
||||
case LINK_INTERNAL:
|
||||
return "Internal Link";
|
||||
|
||||
case LINK_EXTERNAL:
|
||||
return "External Link";
|
||||
|
||||
case FALSE:
|
||||
return "Invalid Link";
|
||||
|
||||
default:
|
||||
return "Bad Value:". $type;
|
||||
return "Bad Value:" . $type;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure that a link labelled <front> works.
|
||||
function testValidateFrontLink() {
|
||||
/**
|
||||
* Make sure that a link labeled <front> works.
|
||||
*/
|
||||
public function testValidateFrontLink() {
|
||||
$valid = link_validate_url('<front>');
|
||||
$this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verfied and identified');
|
||||
$this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verified and identified');
|
||||
}
|
||||
|
||||
function testValidateEmailLink() {
|
||||
/**
|
||||
* Validate Email Link.
|
||||
*/
|
||||
public function testValidateEmailLink() {
|
||||
$valid = link_validate_url('mailto:bob@example.com');
|
||||
$this->assertEqual(LINK_EMAIL, $valid, "Make sure a basic mailto is verified and identified");
|
||||
}
|
||||
|
||||
function testValidateEmailLinkBad() {
|
||||
/**
|
||||
* Validate Email Link Bad.
|
||||
*/
|
||||
public function testValidateEmailLinkBad() {
|
||||
$valid = link_validate_url(':bob@example.com');
|
||||
$this->assertEqual(FALSE, $valid, 'Make sure just a bad address is correctly failed');
|
||||
}
|
||||
|
||||
function testValidateNewsgroupLink() {
|
||||
/**
|
||||
* Confirm that valid tel: links work as expected.
|
||||
*/
|
||||
public function testValidateTelLinks() {
|
||||
$links = array(
|
||||
'tel:01',
|
||||
'tel:123456789012345',
|
||||
'tel:+123456789012345',
|
||||
);
|
||||
foreach ($links as $link) {
|
||||
$type = link_url_type($link);
|
||||
$this->assertEqual(LINK_TEL, $type, 'Test ' . $link . ' is a tel link.');
|
||||
$valid = link_validate_url($link);
|
||||
$this->assertTrue($valid, 'Test ' . $link . ' is valid tel link.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that invalid tel: links work as expected.
|
||||
*/
|
||||
public function testValidateTelLinksBad() {
|
||||
$links = array(
|
||||
'tel:0',
|
||||
'tel:1234567890123456',
|
||||
'tel:+1',
|
||||
'tel:+0123456789',
|
||||
'tel:+1234567890123456',
|
||||
':12345678',
|
||||
);
|
||||
foreach ($links as $link) {
|
||||
$type = link_url_type($link);
|
||||
$this->assertFalse($type, 'Test ' . $link . ' is not a tel link.');
|
||||
$valid = link_validate_url($link);
|
||||
$this->assertFalse($valid, 'Test ' . $link . ' is not a valid tel link.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Newsgroup Link.
|
||||
*/
|
||||
public function testValidateNewsgroupLink() {
|
||||
$valid = link_validate_url('news:comp.infosystems.www.misc');
|
||||
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to newsgroup validates as news.');
|
||||
}
|
||||
|
||||
function testValidateNewsArticleLink() {
|
||||
/**
|
||||
* Validate News Article Link.
|
||||
*/
|
||||
public function testValidateNewsArticleLink() {
|
||||
$valid = link_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
|
||||
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article valiates as news.');
|
||||
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article validates as news.');
|
||||
}
|
||||
|
||||
function testValidateBadNewsgroupLink() {
|
||||
/**
|
||||
* Validate Bad Newsgroup Link.
|
||||
*/
|
||||
public function testValidateBadNewsgroupLink() {
|
||||
$valid = link_validate_url('news:comp.bad_name.misc');
|
||||
$this->assertEqual(FALSE, $valid, 'newsgroup names can\'t contain underscores, so it should come back as invalid.');
|
||||
}
|
||||
|
||||
function testValidateInternalLinks() {
|
||||
/**
|
||||
* Validate Internal Links.
|
||||
*/
|
||||
public function testValidateInternalLinks() {
|
||||
$tempfile = drupal_tempnam('public://files', 'test');
|
||||
$links = array(
|
||||
'node/5',
|
||||
'rss.xml',
|
||||
'files/test.jpg',
|
||||
'/var/www/test',
|
||||
'foo#bar',
|
||||
file_uri_target($tempfile),
|
||||
drupal_realpath($tempfile),
|
||||
);
|
||||
|
||||
|
||||
foreach ($links as $link) {
|
||||
$type = link_url_type($link);
|
||||
$this->assertEqual(LINK_INTERNAL, $type, 'Test ' . $link . ' is an internal link.');
|
||||
$valid = link_validate_url($link);
|
||||
$this->assertEqual(LINK_INTERNAL, $valid, 'Test ' . $link . ' internal link.');
|
||||
$this->assertTrue($valid, 'Test ' . $link . ' is valid internal link.');
|
||||
}
|
||||
}
|
||||
|
||||
function testValidateExternalLinks() {
|
||||
/**
|
||||
* Validate External Links.
|
||||
*/
|
||||
public function testValidateExternalLinks() {
|
||||
$links = array(
|
||||
'http://localhost:8080/',
|
||||
'www.example.com',
|
||||
@@ -446,9 +630,8 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
|
||||
'http://255.255.255.255:4823/',
|
||||
'www.test-site.com',
|
||||
'http://example.com/index.php?q=node/123',
|
||||
'http://example.com/index.php?page=this\that',
|
||||
'http://example.com/?first_name=Joe Bob&last_name=Smith',
|
||||
// Anchors
|
||||
// Anchors.
|
||||
'http://www.example.com/index.php#test',
|
||||
'http://www.example.com/index.php#this@that.',
|
||||
'http://www.example.com/index.php#',
|
||||
@@ -456,39 +639,61 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
|
||||
'http://www.archive.org/stream/aesopsfables00aesorich#page/n7/mode/2up',
|
||||
'http://www.example.com/blah/#this@that?',
|
||||
);
|
||||
|
||||
// Test all of the protocols.
|
||||
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
|
||||
$allowed_protocols = variable_get('filter_allowed_protocols', array(
|
||||
'http',
|
||||
'https',
|
||||
'ftp',
|
||||
'news',
|
||||
'nntp',
|
||||
'telnet',
|
||||
'mailto',
|
||||
'irc',
|
||||
'ssh',
|
||||
'sftp',
|
||||
'webcal',
|
||||
));
|
||||
|
||||
foreach ($allowed_protocols as $protocol) {
|
||||
if ($protocol !== 'news' && $protocol !== 'mailto') {
|
||||
$links[] = $protocol .'://www.example.com';
|
||||
$links[] = $protocol . '://www.example.com';
|
||||
}
|
||||
}
|
||||
foreach ($links as $link) {
|
||||
$type = link_url_type($link);
|
||||
$this->assertEqual(LINK_EXTERNAL, $type, 'Testing that ' . $link . ' is an external link.');
|
||||
$valid = link_validate_url($link);
|
||||
$this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that '. $link .' is a valid external link.');
|
||||
// The following two lines are commented out and only used for comparisons.
|
||||
//$valid2 = valid_url($link, TRUE);
|
||||
//$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");
|
||||
$this->assertTrue($valid, 'Test ' . $link . ' is valid external link.');
|
||||
// The following two lines are commented out and only used for
|
||||
// comparisons.
|
||||
// $valid2 = valid_url($link, TRUE);
|
||||
// $this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");.
|
||||
}
|
||||
// Test if we can make a tld valid:
|
||||
variable_set('link_extra_domains', array('frog'));
|
||||
$valid = link_validate_url('http://www.example.frog');
|
||||
$this->assertEqual(LINK_EXTERNAL, $valid, "Testing that http://www.example.frog is a valid external link if we've added 'frog' to the list of valid domains.");
|
||||
}
|
||||
|
||||
function testInvalidExternalLinks() {
|
||||
/**
|
||||
* Check Invalid External Links.
|
||||
*/
|
||||
public function testInvalidExternalLinks() {
|
||||
$links = array(
|
||||
'http://www.ex ample.com/',
|
||||
'http://25.0.0/', // bad ip!
|
||||
// Bad ip!
|
||||
'http://25.0.0/',
|
||||
'http://4827.0.0.2/',
|
||||
'//www.example.com/',
|
||||
'http://www.testß.com/', // ß not allowed in domain names!
|
||||
'http://www.example.frog/', // Bad TLD
|
||||
//'http://www.-fudge.com/', // domains can't have sections starting with a dash.
|
||||
// ß not allowed in domain names!
|
||||
'http://www.testß.com/',
|
||||
// Bad TLD.
|
||||
'http://.www.foo.bar./',
|
||||
// Domains can't have sections starting with a dash.
|
||||
// 'http://www.-fudge.com/',
|
||||
'http://example.com/index.php?page=this\that',
|
||||
'example@example.com',
|
||||
);
|
||||
foreach ($links as $link) {
|
||||
$valid = link_validate_url($link);
|
||||
$this->assertEqual(FALSE, $valid, 'Testing that '. $link .' is not a valid link.');
|
||||
$this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains functions handling views integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_handlers().
|
||||
*/
|
||||
/*function link_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'link') .'/views',
|
||||
),
|
||||
'handlers' => array(
|
||||
'link_views_handler_argument_target' => array(
|
||||
'parent' => 'views_handler_argument',
|
||||
),
|
||||
'link_views_handler_filter_protocol' => array(
|
||||
'parent' => 'views_handler_filter_string',
|
||||
),
|
||||
),
|
||||
);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Return CCK Views data for the link_field_settings($op == 'views data').
|
||||
*
|
||||
* @TODO: Is there some way to tell views I have formatters for it?
|
||||
*/
|
||||
/*function link_views_content_field_data($field) {
|
||||
// Build the automatic views data provided for us by CCK.
|
||||
// This creates all the information necessary for the "url" field.
|
||||
$data = content_views_field_views_data($field);
|
||||
|
||||
$db_info = content_database_info($field);
|
||||
$table_alias = content_views_tablename($field);
|
||||
$field_types = _content_field_types();
|
||||
|
||||
// Tweak the automatic views data for the link "url" field.
|
||||
// Set the filter title to "@label URL"
|
||||
$data[$table_alias][$field['field_name'] .'_url']['filter']['title'] = t('@label URL', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']);
|
||||
// Remove the argument handling for URLs.
|
||||
unset($data[$table_alias][$field['field_name'] .'_url']['argument']);
|
||||
|
||||
// Build out additional views data for the link "title" field.
|
||||
$data[$table_alias][$field['field_name'] .'_title'] = array(
|
||||
'group' => t('Content'),
|
||||
'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
|
||||
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
|
||||
'argument' => array(
|
||||
'field' => $db_info['columns']['title']['column'],
|
||||
'tablename' => $db_info['table'],
|
||||
'handler' => 'content_handler_argument_string',
|
||||
'click sortable' => TRUE,
|
||||
'name field' => '', // TODO, mimic content.views.inc :)
|
||||
'content_field_name' => $field['field_name'],
|
||||
'allow_empty' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'field' => $db_info['columns']['title']['column'],
|
||||
'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))),
|
||||
'tablename' => $db_info['table'],
|
||||
'handler' => 'content_handler_filter_string',
|
||||
'additional fields' => array(),
|
||||
'content_field_name' => $field['field_name'],
|
||||
'allow_empty' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'field' => $db_info['columns']['title']['column'],
|
||||
'tablename' => $db_info['table'],
|
||||
'handler' => 'content_handler_sort',
|
||||
'content_field_name' => $field['field_name'],
|
||||
'allow_empty' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
// Build out additional Views filter for the link "protocol" pseudo field.
|
||||
// TODO: Add a protocol argument.
|
||||
$data[$table_alias][$field['field_name'] .'_protocol'] = array(
|
||||
'group' => t('Content'),
|
||||
'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
|
||||
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
|
||||
'filter' => array(
|
||||
'field' => $db_info['columns']['url']['column'],
|
||||
'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))),
|
||||
'tablename' => $db_info['table'],
|
||||
'handler' => 'link_views_handler_filter_protocol',
|
||||
'additional fields' => array(),
|
||||
'content_field_name' => $field['field_name'],
|
||||
'allow_empty' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
// Build out additional Views argument for the link "target" pseudo field.
|
||||
// TODO: Add a target filter.
|
||||
$data[$table_alias][$field['field_name'] .'_target'] = array(
|
||||
'group' => t('Content'),
|
||||
'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
|
||||
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
|
||||
'argument' => array(
|
||||
'field' => $db_info['columns']['attributes']['column'],
|
||||
'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
|
||||
'tablename' => $db_info['table'],
|
||||
'handler' => 'link_views_handler_argument_target',
|
||||
'additional fields' => array(),
|
||||
'content_field_name' => $field['field_name'],
|
||||
'allow_empty' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}*/
|
||||
@@ -7,20 +7,26 @@
|
||||
|
||||
/**
|
||||
* Argument handler to filter results by target.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
/**
|
||||
* Provide defaults for the argument when a new one is created.
|
||||
*/
|
||||
function options(&$options) {
|
||||
parent::options($options);
|
||||
}
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
return $options;
|
||||
}
|
||||
/**
|
||||
* Provide a default options form for the argument.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$defaults = $this->default_actions();
|
||||
|
||||
$form['title'] = array(
|
||||
@@ -52,7 +58,7 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
$form['wildcard'] = array(
|
||||
'#prefix' => '<div class="views-right-50">',
|
||||
// prefix and no suffix means these two items will be grouped together.
|
||||
// Prefix and no suffix means these two items will be grouped together.
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Wildcard'),
|
||||
'#size' => 20,
|
||||
@@ -125,8 +131,8 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
|
||||
asort($validate_types);
|
||||
$form['validate_type']['#options'] = $validate_types;
|
||||
// Show this gadget if *anything* but 'none' is selected
|
||||
|
||||
// Show this gadget if *anything* but 'none' is selected.
|
||||
$form['validate_fail'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Action to take if argument does not validate'),
|
||||
@@ -140,10 +146,11 @@ class link_views_handler_argument_target extends views_handler_argument {
|
||||
*
|
||||
* The argument sent may be found at $this->argument.
|
||||
*/
|
||||
function query($group_by = FALSE) {
|
||||
public function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
// Because attributes are stored serialized, our only option is to also
|
||||
// serialize the data we're searching for and use LIKE to find similar data.
|
||||
$this->query->add_where(0, $this->table_alias . '.' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
||||
$this->query->add_where(0, $this->table_alias . ' . ' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+52
-15
@@ -7,22 +7,29 @@
|
||||
|
||||
/**
|
||||
* Filter handler for limiting a view to URLs of a certain protocol.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Set defaults for the filter options.
|
||||
*/
|
||||
function options(&$options) {
|
||||
parent::options($options);
|
||||
public function option_definition() {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator'] = 'OR';
|
||||
$options['value'] = 'http';
|
||||
$options['case'] = 0;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the operators supported for protocols.
|
||||
*/
|
||||
function operators() {
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'OR' => array(
|
||||
'title' => t('Is one of'),
|
||||
@@ -35,7 +42,13 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
return $operators;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* Options form.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
//@codingStandardsIgnoreEnd
|
||||
parent::options_form($form, $form_state);
|
||||
$form['case'] = array(
|
||||
'#type' => 'value',
|
||||
@@ -45,8 +58,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Provide a select list to choose the desired protocols.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
public function value_form(&$form, &$form_state) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
// We have to make some choices when creating this as an exposed
|
||||
// filter form. For example, if the operator is locked and thus
|
||||
// not rendered, we can't render dependencies; instead we only
|
||||
@@ -61,7 +77,19 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
'#type' => 'select',
|
||||
'#title' => t('Protocol'),
|
||||
'#default_value' => $this->value,
|
||||
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'))),
|
||||
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array(
|
||||
'http',
|
||||
'https',
|
||||
'ftp',
|
||||
'news',
|
||||
'nntp',
|
||||
'telnet',
|
||||
'mailto',
|
||||
'irc',
|
||||
'ssh',
|
||||
'sftp',
|
||||
'webcal',
|
||||
))),
|
||||
'#multiple' => 1,
|
||||
'#size' => 4,
|
||||
'#description' => t('The protocols displayed here are those globally available. You may add more protocols by modifying the <em>filter_allowed_protocols</em> variable in your installation.'),
|
||||
@@ -71,8 +99,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* Filter down the query to include only the selected protocols.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
function op_protocol($field, $upper) {
|
||||
public function op_protocol($field, $upper) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
$db_type = db_driver();
|
||||
|
||||
$protocols = $this->value;
|
||||
@@ -82,20 +113,25 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
// Simple case, the URL begins with the specified protocol.
|
||||
$condition = $field . ' LIKE \'' . $protocol . '%\'';
|
||||
|
||||
// More complex case, no protocol specified but is automatically cleaned up
|
||||
// by link_cleanup_url(). RegEx is required for this search operation.
|
||||
// More complex case, no protocol specified but is automatically cleaned
|
||||
// up by link_cleanup_url(). RegEx is required for this search operation.
|
||||
if ($protocol == 'http') {
|
||||
$LINK_DOMAINS = _link_domains();
|
||||
$link_domains = _link_domains();
|
||||
if ($db_type == 'pgsql') {
|
||||
// PostGreSQL code has NOT been tested. Please report any problems to the link issue queue.
|
||||
// pgSQL requires all slashes to be double escaped in regular expressions.
|
||||
// PostGreSQL code has NOT been tested. Please report any problems to
|
||||
// the link issue queue.
|
||||
// pgSQL requires all slashes to be double escaped in regular
|
||||
// expressions.
|
||||
// @codingStandardsIgnoreLine
|
||||
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
|
||||
$condition .= ' OR ' . $field .' ~* \''.'^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
||||
$condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
|
||||
}
|
||||
else {
|
||||
// mySQL requires backslashes to be double (triple?) escaped within character classes.
|
||||
// mySQL requires backslashes to be double (triple?) escaped within
|
||||
// character classes.
|
||||
// @codingStandardsIgnoreLine
|
||||
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp
|
||||
$condition .= ' OR ' . $field . ' REGEXP \''.'^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
|
||||
$condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,4 +140,5 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
|
||||
|
||||
$this->query->add_where($this->options['group'], implode(' ' . $this->operator . ' ', $where_conditions));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user