Extracted text and test files from source code
This commit is contained in:
parent
676a7ea81c
commit
e7e66a9245
134 changed files with 0 additions and 14081 deletions
|
@ -1,156 +0,0 @@
|
|||
This document explains how to provide "Pathauto integration" in a
|
||||
module. You need this if you would like to provide additional tokens
|
||||
or if your module has paths and you wish to have them automatically
|
||||
aliased. The simplest integration is just to provide tokens so we
|
||||
cover that first. More advanced integration requires an
|
||||
implementation of hook_pathauto to provide a settings form.
|
||||
|
||||
It may be helpful to review some examples of integration from the
|
||||
pathauto_node.inc, pathauto_taxonomy.inc, and pathauto_user.inc files.
|
||||
|
||||
|
||||
==================
|
||||
1 - Providing additional tokens
|
||||
==================
|
||||
|
||||
If all you want is to enable tokens for your module you will simply
|
||||
need to implement two functions:
|
||||
|
||||
hook_token_values
|
||||
hook_token_list
|
||||
|
||||
See the token.module and it's API.txt for more information about this
|
||||
process.
|
||||
|
||||
If the token is intended to generate a path expected to contain slashes,
|
||||
the token name must end in 'path', 'path-raw' or 'alias'. This indicates to
|
||||
Pathauto that the slashes should not be removed from the replacement value.
|
||||
|
||||
When an object is created (whether it is a node or a user or a
|
||||
taxonomy term) the data that Pathauto hands to the token_values in the
|
||||
$object is in a specific format. This is the format that most people
|
||||
write code to handle. However, during edits and bulk updates the data
|
||||
may be in a totally different format. So, if you are writing a
|
||||
hook_token_values implementation to add special tokens, be sure to
|
||||
test creation, edit, and bulk update cases to make sure your code will
|
||||
handle it.
|
||||
|
||||
==================
|
||||
2 - Settings hook - To create aliases for your module
|
||||
==================
|
||||
You must implement hook_pathauto($op), where $op is always (at this
|
||||
time) 'settings'. Return an object (NOT an array) containing the
|
||||
following members, which will be used by pathauto to build a group
|
||||
of settings for your module and define the variables for saving your
|
||||
settings:
|
||||
|
||||
module - The name of your module (e.g., 'node')
|
||||
groupheader - The translated label for the settings group (e.g.,
|
||||
t('Node path settings')
|
||||
patterndescr - The translated label for the default pattern (e.g.,
|
||||
t('Default path pattern (applies to all node types with blank patterns below)')
|
||||
patterndefault - A translated default pattern (e.g., t('[cat]/[title].html'))
|
||||
placeholders - An array whose keys consist of the translated placeholders
|
||||
which will appear in patterns (e.g., t('[title]')) and values are
|
||||
the translated description of the placeholders (e.g.,
|
||||
t('The title of the node, with spaces and punctuation.')
|
||||
patternitems - For modules which need to express multiple patterns
|
||||
(for example, the node module supports a separate pattern for each
|
||||
node type), an array whose keys consist of identifiers for each
|
||||
pattern (e.g., the node type name) and values consist of the
|
||||
translated label for the pattern
|
||||
supportsfeeds - Modules which support RSS feeds should set this to the
|
||||
string that's appended to a path for its feed (usually 'feed') , so
|
||||
when administrators enable "Create feed aliases" an alias for this
|
||||
content type's feed will be generated in addition to the base alias.
|
||||
bulkname - For modules which support a bulk update operation, the
|
||||
translated label for the action (e.g., t('Bulk update node paths'))
|
||||
bulkdescr - For modules which support a bulk update operation, a
|
||||
translated, more thorough description of what the operation will do
|
||||
(e.g., t('Generate aliases for all existing nodes which do not already have aliases.'))
|
||||
|
||||
|
||||
==================
|
||||
2 - $alias = pathauto_create_alias($module, $op, $placeholders, $src, $type=NULL)
|
||||
==================
|
||||
|
||||
At the appropriate time (usually when a new item is being created for
|
||||
which a generated alias is desired), call pathauto_create_alias() to
|
||||
generate and create the alias. See the user, taxonomy, and nodeapi hook
|
||||
implementations in pathauto.module for examples.
|
||||
|
||||
$module - The name of your module (e.g., 'node')
|
||||
$op - Operation being performed on the item ('insert', 'update', or
|
||||
'bulkupdate')
|
||||
$placeholders - An array whose keys consist of the translated placeholders
|
||||
which appear in patterns and values are the "clean" values to be
|
||||
substituted into the pattern. Call pathauto_cleanstring() on any
|
||||
values which you do not know to be purely alphanumeric, to substitute
|
||||
any non-alphanumerics with the user's designated separator. Note that
|
||||
if the pattern has multiple slash-separated components (e.g., [catpath]),
|
||||
pathauto_cleanstring() should be called for each component, not the
|
||||
complete string.
|
||||
Example: $placeholders[t('[title]')] = pathauto_cleanstring($node->title);
|
||||
$src - The "real" URI of the content to be aliased (e.g., "node/$node->nid")
|
||||
$type - For modules which provided patternitems in hook_autopath(),
|
||||
the relevant identifier for the specific item to be aliased (e.g.,
|
||||
$node->type)
|
||||
|
||||
pathauto_create_alias() returns the alias that was created.
|
||||
|
||||
|
||||
==================
|
||||
3 - Bulk update function
|
||||
==================
|
||||
|
||||
If a module supports bulk updating of aliases, it must provide a
|
||||
function of this form, to be called by pathauto when the corresponding
|
||||
checkbox is selected and the settings page submitted:
|
||||
|
||||
function <module>_pathauto_bulkupdate()
|
||||
|
||||
The function should iterate over the content items controlled by the
|
||||
module, calling pathauto_create_alias() for each one. It is
|
||||
recommended that the function report on its success (e.g., with a
|
||||
count of created aliases) via drupal_set_message().
|
||||
|
||||
|
||||
==================
|
||||
4 - Bulk delete hook_path_alias_types()
|
||||
==================
|
||||
|
||||
For modules that create new types of pages that can be aliased with pathauto, a
|
||||
hook implementation is needed to allow the user to delete them all at once.
|
||||
|
||||
function hook_path_alias_types()
|
||||
|
||||
This hook returns an array whose keys match the beginning of the source paths
|
||||
(e.g.: "node/", "user/", etc.) and whose values describe the type of page (e.g.:
|
||||
"content", "users"). Like all displayed strings, these descriptionsshould be
|
||||
localized with t(). Use % to match interior pieces of a path; "user/%/track". This
|
||||
is a database wildcard, so be careful.
|
||||
|
||||
|
||||
==================
|
||||
Modules that extend node and/or taxonomy
|
||||
==================
|
||||
|
||||
NOTE: this is basically not true any more. If you feel you need this file an issue.
|
||||
|
||||
Many contributed Drupal modules extend the core node and taxonomy
|
||||
modules. To extend pathauto patterns to support their extensions, they
|
||||
may implement the pathauto_node and pathauto_taxonomy hooks.
|
||||
|
||||
To do so, implement the function <modulename>_pathauto_node (or _taxonomy),
|
||||
accepting the arguments $op and $node (or $term). Two operations are
|
||||
supported:
|
||||
|
||||
$op = 'placeholders' - return an array keyed on placeholder strings
|
||||
(e.g., t('[eventyyyy]')) valued with descriptions (e.g. t('The year the
|
||||
event starts.')).
|
||||
$op = 'values' - return an array keyed on placeholder strings, valued
|
||||
with the "clean" actual value for the passed node or category (e.g.,
|
||||
pathauto_cleanstring(date('M', $eventstart)));
|
||||
|
||||
See contrib/pathauto_node_event.inc for an example of extending node
|
||||
patterns.
|
|
@ -1,48 +0,0 @@
|
|||
**Installation:
|
||||
|
||||
Pathauto is an extension to the path module, which must be enabled.
|
||||
|
||||
Pathauto also relies on the Token module, which must be downloaded and
|
||||
enabled separately.
|
||||
|
||||
1. Unpack the Pathauto folder and contents in the appropriate modules
|
||||
directory of your Drupal installation.
|
||||
2. Enable the Pathauto module in the administration tools.
|
||||
3. If you're not using Drupal's default administrative account, make
|
||||
sure "administer pathauto" is enabled through access control administration.
|
||||
4. Visit the Pathauto settings page and make appropriate configurations
|
||||
For 5.x: Administer > Site configuration > Pathauto
|
||||
For 6.x: Administer > Site building > URL alias > Automated alias settings
|
||||
|
||||
**Transliteration support:
|
||||
If you desire transliteration support in the creation of URLs (e.g. the
|
||||
replacement of À with A) then you will need to rename the file
|
||||
i18n-ascii.example.txt to i18n-ascii.txt
|
||||
|
||||
You can then freely edit the i18n-ascii.txt without worrying that your changes
|
||||
will be over-written by upgrades of Pathauto.
|
||||
|
||||
For details on how to transliterate any UTF8 character, please see the full
|
||||
i18n-ascii-fill.txt file information at http://drupal.org/node/185664
|
||||
|
||||
**Upgrading from previous versions:
|
||||
If you are upgrading from Pathauto 5.x-1.x to 5.x-2.x (or 6.x-2.x) then you
|
||||
will probably need to change your patterns.
|
||||
|
||||
For content patterns:
|
||||
[user] is now [author-name]
|
||||
[cat] is now [term]
|
||||
|
||||
There may be other changes as well. Please review the pattern examples on
|
||||
Administration > Site Configuration > Pathauto
|
||||
|
||||
If you upgraded from Pathauto 5.x-1.x directly without enabling Token
|
||||
first then you will need to
|
||||
1) download/install the Token module
|
||||
2) disable the Pathauto module
|
||||
3) re-enable the Pathauto module
|
||||
|
||||
Upgrade to 6.x:
|
||||
Note that the settings page has moved so that it is more logically grouped with
|
||||
other URL alias related items under
|
||||
Administer > Site building > URL alias > Automated alias settings
|
|
@ -1,564 +0,0 @@
|
|||
; global transliteration
|
||||
[default]
|
||||
À = "A"
|
||||
Á = "A"
|
||||
 = "A"
|
||||
à = "A"
|
||||
Ä = "Ae"
|
||||
Å = "A"
|
||||
Æ = "A"
|
||||
Ā = "A"
|
||||
Ą = "A"
|
||||
Ă = "A"
|
||||
Ç = "C"
|
||||
Ć = "C"
|
||||
Č = "C"
|
||||
Ĉ = "C"
|
||||
Ċ = "C"
|
||||
Ď = "D"
|
||||
Đ = "D"
|
||||
È = "E"
|
||||
É = "E"
|
||||
Ê = "E"
|
||||
Ë = "E"
|
||||
Ē = "E"
|
||||
Ę = "E"
|
||||
Ě = "E"
|
||||
Ĕ = "E"
|
||||
Ė = "E"
|
||||
Ĝ = "G"
|
||||
Ğ = "G"
|
||||
Ġ = "G"
|
||||
Ģ = "G"
|
||||
Ĥ = "H"
|
||||
Ħ = "H"
|
||||
Ì = "I"
|
||||
Í = "I"
|
||||
Î = "I"
|
||||
Ï = "I"
|
||||
Ī = "I"
|
||||
Ĩ = "I"
|
||||
Ĭ = "I"
|
||||
Į = "I"
|
||||
İ = "I"
|
||||
IJ = "IJ"
|
||||
Ĵ = "J"
|
||||
Ķ = "K"
|
||||
Ľ = "L"
|
||||
Ĺ = "L"
|
||||
Ļ = "L"
|
||||
Ŀ = "L"
|
||||
Ł = "L"
|
||||
Ñ = "N"
|
||||
Ń = "N"
|
||||
Ň = "N"
|
||||
Ņ = "N"
|
||||
Ŋ = "N"
|
||||
Ò = "O"
|
||||
Ó = "O"
|
||||
Ô = "O"
|
||||
Õ = "O"
|
||||
Ö = "Oe"
|
||||
Ø = "O"
|
||||
Ō = "O"
|
||||
Ő = "O"
|
||||
Ŏ = "O"
|
||||
Œ = "OE"
|
||||
Ŕ = "R"
|
||||
Ř = "R"
|
||||
Ŗ = "R"
|
||||
Ś = "S"
|
||||
Ş = "S"
|
||||
Ŝ = "S"
|
||||
Ș = "S"
|
||||
Š = "S"
|
||||
Ť = "T"
|
||||
Ţ = "T"
|
||||
Ŧ = "T"
|
||||
Ț = "T"
|
||||
Ù = "U"
|
||||
Ú = "U"
|
||||
Û = "U"
|
||||
Ü = "Ue"
|
||||
Ū = "U"
|
||||
Ů = "U"
|
||||
Ű = "U"
|
||||
Ŭ = "U"
|
||||
Ũ = "U"
|
||||
Ų = "U"
|
||||
Ŵ = "W"
|
||||
Ŷ = "Y"
|
||||
Ÿ = "Y"
|
||||
Ý = "Y"
|
||||
Ź = "Z"
|
||||
Ż = "Z"
|
||||
Ž = "Z"
|
||||
à = "a"
|
||||
á = "a"
|
||||
â = "a"
|
||||
ã = "a"
|
||||
ä = "ae"
|
||||
ā = "a"
|
||||
ą = "a"
|
||||
ă = "a"
|
||||
å = "a"
|
||||
æ = "ae"
|
||||
ç = "c"
|
||||
ć = "c"
|
||||
č = "c"
|
||||
ĉ = "c"
|
||||
ċ = "c"
|
||||
ď = "d"
|
||||
đ = "d"
|
||||
è = "e"
|
||||
é = "e"
|
||||
ê = "e"
|
||||
ë = "e"
|
||||
ē = "e"
|
||||
ę = "e"
|
||||
ě = "e"
|
||||
ĕ = "e"
|
||||
ė = "e"
|
||||
ƒ = "f"
|
||||
ĝ = "g"
|
||||
ğ = "g"
|
||||
ġ = "g"
|
||||
ģ = "g"
|
||||
ĥ = "h"
|
||||
ħ = "h"
|
||||
ì = "i"
|
||||
í = "i"
|
||||
î = "i"
|
||||
ï = "i"
|
||||
ī = "i"
|
||||
ĩ = "i"
|
||||
ĭ = "i"
|
||||
į = "i"
|
||||
ı = "i"
|
||||
ij = "ij"
|
||||
ĵ = "j"
|
||||
ķ = "k"
|
||||
ĸ = "k"
|
||||
ł = "l"
|
||||
ľ = "l"
|
||||
ĺ = "l"
|
||||
ļ = "l"
|
||||
ŀ = "l"
|
||||
ñ = "n"
|
||||
ń = "n"
|
||||
ň = "n"
|
||||
ņ = "n"
|
||||
ʼn = "n"
|
||||
ŋ = "n"
|
||||
ò = "o"
|
||||
ó = "o"
|
||||
ô = "o"
|
||||
õ = "o"
|
||||
ö = "oe"
|
||||
ø = "o"
|
||||
ō = "o"
|
||||
ő = "o"
|
||||
ŏ = "o"
|
||||
œ = "oe"
|
||||
ŕ = "r"
|
||||
ř = "r"
|
||||
ŗ = "r"
|
||||
ś = "s"
|
||||
š = "s"
|
||||
ş = "s"
|
||||
ť = "t"
|
||||
ţ = "t"
|
||||
ù = "u"
|
||||
ú = "u"
|
||||
û = "u"
|
||||
ü = "ue"
|
||||
ū = "u"
|
||||
ů = "u"
|
||||
ű = "u"
|
||||
ŭ = "u"
|
||||
ũ = "u"
|
||||
ų = "u"
|
||||
ŵ = "w"
|
||||
ÿ = "y"
|
||||
ý = "y"
|
||||
ŷ = "y"
|
||||
ż = "z"
|
||||
ź = "z"
|
||||
ž = "z"
|
||||
ß = "ss"
|
||||
ſ = "ss"
|
||||
Α = "A"
|
||||
Ά = "A"
|
||||
Ἀ = "A"
|
||||
Ἁ = "A"
|
||||
Ἂ = "A"
|
||||
Ἃ = "A"
|
||||
Ἄ = "A"
|
||||
Ἅ = "A"
|
||||
Ἆ = "A"
|
||||
Ἇ = "A"
|
||||
ᾈ = "A"
|
||||
ᾉ = "A"
|
||||
ᾊ = "A"
|
||||
ᾋ = "A"
|
||||
ᾌ = "A"
|
||||
ᾍ = "A"
|
||||
ᾎ = "A"
|
||||
ᾏ = "A"
|
||||
Ᾰ = "A"
|
||||
Ᾱ = "A"
|
||||
Ὰ = "A"
|
||||
Ά = "A"
|
||||
ᾼ = "A"
|
||||
Β = "B"
|
||||
Γ = "G"
|
||||
Δ = "D"
|
||||
Ε = "E"
|
||||
Έ = "E"
|
||||
Ἐ = "E"
|
||||
Ἑ = "E"
|
||||
Ἒ = "E"
|
||||
Ἓ = "E"
|
||||
Ἔ = "E"
|
||||
Ἕ = "E"
|
||||
Έ = "E"
|
||||
Ὲ = "E"
|
||||
Ζ = "Z"
|
||||
Η = "I"
|
||||
Ή = "I"
|
||||
Ἠ = "I"
|
||||
Ἡ = "I"
|
||||
Ἢ = "I"
|
||||
Ἣ = "I"
|
||||
Ἤ = "I"
|
||||
Ἥ = "I"
|
||||
Ἦ = "I"
|
||||
Ἧ = "I"
|
||||
ᾘ = "I"
|
||||
ᾙ = "I"
|
||||
ᾚ = "I"
|
||||
ᾛ = "I"
|
||||
ᾜ = "I"
|
||||
ᾝ = "I"
|
||||
ᾞ = "I"
|
||||
ᾟ = "I"
|
||||
Ὴ = "I"
|
||||
Ή = "I"
|
||||
ῌ = "I"
|
||||
Θ = "TH"
|
||||
Ι = "I"
|
||||
Ί = "I"
|
||||
Ϊ = "I"
|
||||
Ἰ = "I"
|
||||
Ἱ = "I"
|
||||
Ἲ = "I"
|
||||
Ἳ = "I"
|
||||
Ἴ = "I"
|
||||
Ἵ = "I"
|
||||
Ἶ = "I"
|
||||
Ἷ = "I"
|
||||
Ῐ = "I"
|
||||
Ῑ = "I"
|
||||
Ὶ = "I"
|
||||
Ί = "I"
|
||||
Κ = "K"
|
||||
Λ = "L"
|
||||
Μ = "M"
|
||||
Ν = "N"
|
||||
Ξ = "KS"
|
||||
Ο = "O"
|
||||
Ό = "O"
|
||||
Ὀ = "O"
|
||||
Ὁ = "O"
|
||||
Ὂ = "O"
|
||||
Ὃ = "O"
|
||||
Ὄ = "O"
|
||||
Ὅ = "O"
|
||||
Ὸ = "O"
|
||||
Ό = "O"
|
||||
Π = "P"
|
||||
Ρ = "R"
|
||||
Ῥ = "R"
|
||||
Σ = "S"
|
||||
Τ = "T"
|
||||
Υ = "Y"
|
||||
Ύ = "Y"
|
||||
Ϋ = "Y"
|
||||
Ὑ = "Y"
|
||||
Ὓ = "Y"
|
||||
Ὕ = "Y"
|
||||
Ὗ = "Y"
|
||||
Ῠ = "Y"
|
||||
Ῡ = "Y"
|
||||
Ὺ = "Y"
|
||||
Ύ = "Y"
|
||||
Φ = "F"
|
||||
Χ = "X"
|
||||
Ψ = "PS"
|
||||
Ω = "O"
|
||||
Ώ = "O"
|
||||
Ὠ = "O"
|
||||
Ὡ = "O"
|
||||
Ὢ = "O"
|
||||
Ὣ = "O"
|
||||
Ὤ = "O"
|
||||
Ὥ = "O"
|
||||
Ὦ = "O"
|
||||
Ὧ = "O"
|
||||
ᾨ = "O"
|
||||
ᾩ = "O"
|
||||
ᾪ = "O"
|
||||
ᾫ = "O"
|
||||
ᾬ = "O"
|
||||
ᾭ = "O"
|
||||
ᾮ = "O"
|
||||
ᾯ = "O"
|
||||
Ὼ = "O"
|
||||
Ώ = "O"
|
||||
ῼ = "O"
|
||||
α = "a"
|
||||
ά = "a"
|
||||
ἀ = "a"
|
||||
ἁ = "a"
|
||||
ἂ = "a"
|
||||
ἃ = "a"
|
||||
ἄ = "a"
|
||||
ἅ = "a"
|
||||
ἆ = "a"
|
||||
ἇ = "a"
|
||||
ᾀ = "a"
|
||||
ᾁ = "a"
|
||||
ᾂ = "a"
|
||||
ᾃ = "a"
|
||||
ᾄ = "a"
|
||||
ᾅ = "a"
|
||||
ᾆ = "a"
|
||||
ᾇ = "a"
|
||||
ὰ = "a"
|
||||
ά = "a"
|
||||
ᾰ = "a"
|
||||
ᾱ = "a"
|
||||
ᾲ = "a"
|
||||
ᾳ = "a"
|
||||
ᾴ = "a"
|
||||
ᾶ = "a"
|
||||
ᾷ = "a"
|
||||
β = "b"
|
||||
γ = "g"
|
||||
δ = "d"
|
||||
ε = "e"
|
||||
έ = "e"
|
||||
ἐ = "e"
|
||||
ἑ = "e"
|
||||
ἒ = "e"
|
||||
ἓ = "e"
|
||||
ἔ = "e"
|
||||
ἕ = "e"
|
||||
ὲ = "e"
|
||||
έ = "e"
|
||||
ζ = "z"
|
||||
η = "i"
|
||||
ή = "i"
|
||||
ἠ = "i"
|
||||
ἡ = "i"
|
||||
ἢ = "i"
|
||||
ἣ = "i"
|
||||
ἤ = "i"
|
||||
ἥ = "i"
|
||||
ἦ = "i"
|
||||
ἧ = "i"
|
||||
ᾐ = "i"
|
||||
ᾑ = "i"
|
||||
ᾒ = "i"
|
||||
ᾓ = "i"
|
||||
ᾔ = "i"
|
||||
ᾕ = "i"
|
||||
ᾖ = "i"
|
||||
ᾗ = "i"
|
||||
ὴ = "i"
|
||||
ή = "i"
|
||||
ῂ = "i"
|
||||
ῃ = "i"
|
||||
ῄ = "i"
|
||||
ῆ = "i"
|
||||
ῇ = "i"
|
||||
θ = "th"
|
||||
ι = "i"
|
||||
ί = "i"
|
||||
ϊ = "i"
|
||||
ΐ = "i"
|
||||
ἰ = "i"
|
||||
ἱ = "i"
|
||||
ἲ = "i"
|
||||
ἳ = "i"
|
||||
ἴ = "i"
|
||||
ἵ = "i"
|
||||
ἶ = "i"
|
||||
ἷ = "i"
|
||||
ὶ = "i"
|
||||
ί = "i"
|
||||
ῐ = "i"
|
||||
ῑ = "i"
|
||||
ῒ = "i"
|
||||
ΐ = "i"
|
||||
ῖ = "i"
|
||||
ῗ = "i"
|
||||
κ = "k"
|
||||
λ = "l"
|
||||
μ = "m"
|
||||
ν = "n"
|
||||
ξ = "ks"
|
||||
ο = "o"
|
||||
ό = "o"
|
||||
ὀ = "o"
|
||||
ὁ = "o"
|
||||
ὂ = "o"
|
||||
ὃ = "o"
|
||||
ὄ = "o"
|
||||
ὅ = "o"
|
||||
ὸ = "o"
|
||||
ό = "o"
|
||||
π = "p"
|
||||
ρ = "r"
|
||||
ῤ = "r"
|
||||
ῥ = "r"
|
||||
σ = "s"
|
||||
ς = "s"
|
||||
τ = "t"
|
||||
υ = "y"
|
||||
ύ = "y"
|
||||
ϋ = "y"
|
||||
ΰ = "y"
|
||||
ὐ = "y"
|
||||
ὑ = "y"
|
||||
ὒ = "y"
|
||||
ὓ = "y"
|
||||
ὔ = "y"
|
||||
ὕ = "y"
|
||||
ὖ = "y"
|
||||
ὗ = "y"
|
||||
ὺ = "y"
|
||||
ύ = "y"
|
||||
ῠ = "y"
|
||||
ῡ = "y"
|
||||
ῢ = "y"
|
||||
ΰ = "y"
|
||||
ῦ = "y"
|
||||
ῧ = "y"
|
||||
φ = "f"
|
||||
χ = "x"
|
||||
ψ = "ps"
|
||||
ω = "o"
|
||||
ώ = "o"
|
||||
ὠ = "o"
|
||||
ὡ = "o"
|
||||
ὢ = "o"
|
||||
ὣ = "o"
|
||||
ὤ = "o"
|
||||
ὥ = "o"
|
||||
ὦ = "o"
|
||||
ὧ = "o"
|
||||
ᾠ = "o"
|
||||
ᾡ = "o"
|
||||
ᾢ = "o"
|
||||
ᾣ = "o"
|
||||
ᾤ = "o"
|
||||
ᾥ = "o"
|
||||
ᾦ = "o"
|
||||
ᾧ = "o"
|
||||
ὼ = "o"
|
||||
ώ = "o"
|
||||
ῲ = "o"
|
||||
ῳ = "o"
|
||||
ῴ = "o"
|
||||
ῶ = "o"
|
||||
ῷ = "o"
|
||||
¨ = ""
|
||||
΅ = ""
|
||||
᾿ = ""
|
||||
῾ = ""
|
||||
῍ = ""
|
||||
῝ = ""
|
||||
῎ = ""
|
||||
῞ = ""
|
||||
῏ = ""
|
||||
῟ = ""
|
||||
῀ = ""
|
||||
῁ = ""
|
||||
΄ = ""
|
||||
΅ = ""
|
||||
` = ""
|
||||
῭ = ""
|
||||
ͺ = ""
|
||||
᾽ = ""
|
||||
А = "A"
|
||||
Б = "B"
|
||||
В = "V"
|
||||
Г = "G"
|
||||
Д = "D"
|
||||
Е = "E"
|
||||
Ё = "E"
|
||||
Ж = "ZH"
|
||||
З = "Z"
|
||||
И = "I"
|
||||
Й = "I"
|
||||
К = "K"
|
||||
Л = "L"
|
||||
М = "M"
|
||||
Н = "N"
|
||||
О = "O"
|
||||
П = "P"
|
||||
Р = "R"
|
||||
С = "S"
|
||||
Т = "T"
|
||||
У = "U"
|
||||
Ф = "F"
|
||||
Х = "KH"
|
||||
Ц = "TS"
|
||||
Ч = "CH"
|
||||
Ш = "SH"
|
||||
Щ = "SHCH"
|
||||
Ы = "Y"
|
||||
Э = "E"
|
||||
Ю = "YU"
|
||||
Я = "YA"
|
||||
а = "A"
|
||||
б = "B"
|
||||
в = "V"
|
||||
г = "G"
|
||||
д = "D"
|
||||
е = "E"
|
||||
ё = "E"
|
||||
ж = "ZH"
|
||||
з = "Z"
|
||||
и = "I"
|
||||
й = "I"
|
||||
к = "K"
|
||||
л = "L"
|
||||
м = "M"
|
||||
н = "N"
|
||||
о = "O"
|
||||
п = "P"
|
||||
р = "R"
|
||||
с = "S"
|
||||
т = "T"
|
||||
у = "U"
|
||||
ф = "F"
|
||||
х = "KH"
|
||||
ц = "TS"
|
||||
ч = "CH"
|
||||
ш = "SH"
|
||||
щ = "SHCH"
|
||||
ы = "Y"
|
||||
э = "E"
|
||||
ю = "YU"
|
||||
я = "YA"
|
||||
Ъ = ""
|
||||
ъ = ""
|
||||
Ь = ""
|
||||
ь = ""
|
||||
|
||||
ð = "d"
|
||||
Ð = "D"
|
||||
þ = "th"
|
||||
Þ = "TH"
|
|
@ -1,830 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functionality tests for Pathauto.
|
||||
*
|
||||
* @ingroup pathauto
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper test class with some added functions for testing.
|
||||
*/
|
||||
class PathautoTestHelper extends DrupalWebTestCase {
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'path';
|
||||
$modules[] = 'token';
|
||||
$modules[] = 'pathauto';
|
||||
$modules[] = 'taxonomy';
|
||||
parent::setUp($modules);
|
||||
}
|
||||
|
||||
function assertToken($type, $object, $token, $expected) {
|
||||
$this->assertTokens($type, $object, array($token => $expected));
|
||||
}
|
||||
|
||||
function assertTokens($type, $object, array $tokens) {
|
||||
$values = pathauto_get_placeholders($type, $object);
|
||||
$values = $values['values'];
|
||||
foreach ($tokens as $token => $expected) {
|
||||
$this->assertIdentical($values[$token], $expected, t("Token value for [@token] was '@actual', expected value '@expected'.", array('@token' => $token, '@actual' => $values[$token], '@expected' => $expected)));
|
||||
}
|
||||
}
|
||||
|
||||
function saveAlias($source, $alias, $language = '') {
|
||||
path_set_alias($source, $alias, NULL, $language);
|
||||
return db_fetch_array(db_query_range("SELECT * FROM {url_alias} WHERE src = '%s' AND dst = '%s' AND language = '%s' ORDER BY pid DESC", $source, $alias, $language, 0, 1));
|
||||
}
|
||||
|
||||
function saveEntityAlias($entity_type, $entity, $alias, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
return $this->saveAlias($uri['path'], $alias, $language);
|
||||
}
|
||||
|
||||
function assertEntityAlias($entity_type, $entity, $expected_alias, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertAlias($uri['path'], $expected_alias, $language);
|
||||
}
|
||||
|
||||
function assertEntityAliasExists($entity_type, $entity) {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
return $this->assertAliasExists(array('source' => $uri['path']));
|
||||
}
|
||||
|
||||
function assertNoEntityAlias($entity_type, $entity, $language = '') {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertEntityAlias($entity_type, $entity, $uri['path'], $language);
|
||||
}
|
||||
|
||||
function assertNoEntityAliasExists($entity_type, $entity) {
|
||||
$uri = $this->entity_uri($entity_type, $entity);
|
||||
$this->assertNoAliasExists(array('source' => $uri['path']));
|
||||
}
|
||||
|
||||
function assertAlias($source, $expected_alias, $language = '') {
|
||||
drupal_clear_path_cache();
|
||||
$alias = drupal_get_path_alias($source, $language);
|
||||
$this->assertIdentical($alias, $expected_alias, t("Alias for %source with language '@language' was %actual, expected %expected.", array('%source' => $source, '%actual' => $alias, '%expected' => $expected_alias, '@language' => $language)));
|
||||
}
|
||||
|
||||
function assertAliasExists($conditions) {
|
||||
$path = $this->path_load($conditions);
|
||||
$this->assertTrue($path, t('Alias with conditions @conditions found.', array('@conditions' => var_export($conditions, TRUE))));
|
||||
return $path;
|
||||
}
|
||||
|
||||
function assertNoAliasExists($conditions) {
|
||||
$alias = $this->path_load($conditions);
|
||||
$this->assertFalse($alias, t('Alias with conditions @conditions not found.', array('@conditions' => var_export($conditions, TRUE))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport of Drupal 7's entity_uri() function.
|
||||
*/
|
||||
protected function entity_uri($entity_type, $entity) {
|
||||
$uri = array();
|
||||
|
||||
switch ($entity_type) {
|
||||
case 'node':
|
||||
$uri['path'] = 'node/' . $entity->nid;
|
||||
break;
|
||||
case 'taxonomy_term':
|
||||
$uri['path'] = taxonomy_term_path($entity);
|
||||
break;
|
||||
case 'user':
|
||||
$uri['path'] = 'user/' . $entity->uid;
|
||||
break;
|
||||
default:
|
||||
return $this->fail(t('Unknown entity @type.', array('@type' => $entity_type)));
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backport of Drupal 7's path_load() function.
|
||||
*/
|
||||
protected function path_load($conditions) {
|
||||
if (is_numeric($conditions)) {
|
||||
$conditions = array('pid' => $conditions);
|
||||
}
|
||||
elseif (is_string($conditions)) {
|
||||
$conditions = array('src' => $conditions);
|
||||
}
|
||||
|
||||
// Adjust for some D7 {url_alias} column name changes so we can keep
|
||||
// the test files in sync.
|
||||
if (isset($conditions['source'])) {
|
||||
$conditions['src'] = $conditions['source'];
|
||||
unset($conditions['source']);
|
||||
}
|
||||
if (isset($conditions['alias'])) {
|
||||
$conditions['dst'] = $conditions['alias'];
|
||||
unset($conditions['alias']);
|
||||
}
|
||||
|
||||
$args = array();
|
||||
$schema = drupal_get_schema_unprocessed('system', 'url_alias');
|
||||
foreach ($conditions as $field => $value) {
|
||||
$field_type = $schema['fields'][$field]['type'];
|
||||
if (is_array($value)) {
|
||||
$conditions[$field] = "$field = " . db_placeholders($value, $field_type);
|
||||
$args = array_merge($args, $value);
|
||||
}
|
||||
else {
|
||||
$placeholder = db_type_placeholder($field_type);
|
||||
$conditions[$field] = "$field = $placeholder";
|
||||
$args[] = $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM {url_alias} WHERE " . implode(' AND ', $conditions);
|
||||
return db_fetch_array(db_query_range($sql, $args, 0, 1));
|
||||
}
|
||||
|
||||
function deleteAllAliases() {
|
||||
db_query("DELETE FROM {url_alias}");
|
||||
drupal_clear_path_cache();
|
||||
}
|
||||
|
||||
function addVocabulary(array $vocabulary = array()) {
|
||||
$vocabulary += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'nodes' => array('story' => 'story'),
|
||||
);
|
||||
taxonomy_save_vocabulary($vocabulary);
|
||||
return (object) $vocabulary;
|
||||
}
|
||||
|
||||
function addTerm(stdClass $vocabulary, array $term = array()) {
|
||||
$term += array(
|
||||
'name' => drupal_strtolower($this->randomName(5)),
|
||||
'vid' => $vocabulary->vid,
|
||||
);
|
||||
taxonomy_save_term($term);
|
||||
return (object) $term;
|
||||
}
|
||||
|
||||
function addNodeType(array $type) {
|
||||
if (!isset($type['name'])) {
|
||||
$type['name'] = $this->randomName(8);
|
||||
}
|
||||
|
||||
$type += array(
|
||||
'type' => drupal_strtolower($type['name']),
|
||||
'module' => 'node',
|
||||
'description' => $this->randomName(40),
|
||||
'custom' => TRUE,
|
||||
'modified' => TRUE,
|
||||
'locked' => FALSE,
|
||||
'help' => '',
|
||||
'min_word_count' => '',
|
||||
);
|
||||
|
||||
$type = (object) _node_type_set_defaults($type);
|
||||
node_type_save($type);
|
||||
node_types_rebuild();
|
||||
return $type;
|
||||
}
|
||||
|
||||
function assertEntityPattern($entity_type, $bundle, $language = '', $expected) {
|
||||
$this->refreshVariables();
|
||||
$variables = array(
|
||||
"pathauto_{$entity_type}_{$bundle}_{$language}_pattern",
|
||||
"pathauto_{$entity_type}_{$bundle}_pattern",
|
||||
"pathauto_{$entity_type}_pattern",
|
||||
);
|
||||
$pattern = '';
|
||||
foreach ($variables as $variable) {
|
||||
if ($pattern = variable_get($variable, '')) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertIdentical($expected, $pattern);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for Pathauto functions.
|
||||
*/
|
||||
class PathautoUnitTestCase extends PathautoTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto unit tests',
|
||||
'description' => 'Unit tests for Pathauto functions.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
parent::setUp($modules);
|
||||
module_load_include('inc', 'pathauto');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _pathauto_get_schema_alias_maxlength().
|
||||
*/
|
||||
function testGetSchemaAliasMaxLength() {
|
||||
$this->assertIdentical(_pathauto_get_schema_alias_maxlength(), 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test pathauto_cleanstring().
|
||||
*/
|
||||
function testCleanString() {
|
||||
$tests = array();
|
||||
variable_set('pathauto_ignore_words', ', in, is,that, the , this, with, ');
|
||||
variable_set('pathauto_max_component_length', 35);
|
||||
|
||||
// Test the 'ignored words' removal.
|
||||
$tests['this'] = 'this';
|
||||
$tests['this with that'] = 'this-with-that';
|
||||
$tests['this thing with that thing'] = 'thing-thing';
|
||||
|
||||
// Test length truncation and duplicate separator removal.
|
||||
$tests[' - Pathauto is the greatest - module ever in Drupal history - '] = 'pathauto-greatest-module-ever-drupa';
|
||||
|
||||
// Test that HTML tags are removed.
|
||||
$tests['This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.'] = 'text-has-html-tags';
|
||||
$tests[check_plain('This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.')] = 'text-has-html-tags';
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = pathauto_cleanstring($input);
|
||||
$this->assertEqual($output, $expected, t("pathauto_cleanstring('@input') expected '@expected', actual '@output'", array('@input' => $input, '@expected' => $expected, '@output' => $output)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the feed alias functionality of pathauto_create_alias().
|
||||
*/
|
||||
function testFeedAliases() {
|
||||
variable_set('pathauto_node_pattern', '[title-raw]');
|
||||
variable_set('pathauto_node_applytofeeds', '');
|
||||
|
||||
// Create a node with an empty title, which should not create an alias.
|
||||
$node = $this->drupalCreateNode(array('title' => ''));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}"));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}/feed"));
|
||||
|
||||
// Add a title to the node. This should still not generate a feed alias.
|
||||
$node->title = 'Node title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'node-title'));
|
||||
$this->assertNoAliasExists(array('source' => "node/{$node->nid}/feed"));
|
||||
|
||||
// Enable feeds for nodes. A feed alias should now be generated.
|
||||
variable_set('pathauto_node_applytofeeds', ' feed ');
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}/feed", 'alias' => 'node-title/feed'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _pathauto_get_raw_tokens().
|
||||
*/
|
||||
function testGetRawTokens() {
|
||||
$raw_tokens = _pathauto_get_raw_tokens();
|
||||
$this->assertFalse(in_array('node-path', $raw_tokens), 'Non-raw tokens not included.');
|
||||
$this->assertTrue(in_array('node-path-raw', $raw_tokens), 'Token [catpath] has a matching raw token.');
|
||||
$this->assertFalse(in_array('node-url-raw', $raw_tokens), 'Token [catalias] does not have a matching raw token.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the different update actions in pathauto_create_alias().
|
||||
*/
|
||||
function testUpdateActions() {
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'insert'.
|
||||
variable_set('pathauto_update_action', 0);
|
||||
$node = $this->drupalCreateNode(array('title' => 'First title'));
|
||||
$this->assertEntityAlias('node', $node, 'content/first-title');
|
||||
|
||||
// Default action is PATHAUTO_UPDATE_ACTION_DELETE.
|
||||
variable_set('pathauto_update_action', 2);
|
||||
$node->title = 'Second title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/second-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/first-title'));
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_LEAVE.
|
||||
variable_set('pathauto_update_action', 1);
|
||||
$node->title = 'Third title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/third-title');
|
||||
$this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'content/second-title'));
|
||||
|
||||
variable_set('pathauto_update_action', 2);
|
||||
$node->title = 'Fourth title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fourth-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/third-title'));
|
||||
// The older second alias is not deleted yet.
|
||||
$older_path = $this->assertAliasExists(array('source' => "node/{$node->nid}", 'alias' => 'content/second-title'));
|
||||
path_set_alias(NULL, NULL, $older_path['pid']);
|
||||
|
||||
variable_set('pathauto_update_action', 0);
|
||||
$node->title = 'Fifth title';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fourth-title');
|
||||
$this->assertNoAliasExists(array('alias' => 'content/fith-title'));
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'update'.
|
||||
$this->deleteAllAliases();
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/fifth-title');
|
||||
|
||||
// Test PATHAUTO_UPDATE_ACTION_NO_NEW with unaliased node and 'bulkupdate'.
|
||||
$this->deleteAllAliases();
|
||||
$node->title = 'Sixth title';
|
||||
pathauto_node_update_alias($node, 'bulkupdate');
|
||||
$this->assertEntityAlias('node', $node, 'content/sixth-title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that pathauto_create_alias() will not create an alias for a pattern
|
||||
* that does not get any tokens replaced.
|
||||
*/
|
||||
function testNoTokensNoAlias() {
|
||||
$node = $this->drupalCreateNode(array('title' => ''));
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
$node->title = 'hello';
|
||||
pathauto_nodeapi($node, 'update');
|
||||
$this->assertEntityAlias('node', $node, 'content/hello');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the handling of path vs non-path tokens in pathauto_clean_token_values().
|
||||
*
|
||||
* @see PathautoBookTokenTestCase::testBookPathAlias()
|
||||
*/
|
||||
//function testPathTokens() {
|
||||
//}
|
||||
|
||||
function testEntityBundleRenamingDeleting() {
|
||||
// Create a vocabulary type.
|
||||
$vocabulary = $this->addVocabulary();
|
||||
variable_set('pathauto_taxonomy_pattern', 'base');
|
||||
variable_set('pathauto_taxonomy_' . $vocabulary->vid . '_pattern', 'bundle');
|
||||
$this->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'bundle');
|
||||
|
||||
// Delete the vocabulary, which should cause its pattern variable to also
|
||||
// be deleted.
|
||||
taxonomy_del_vocabulary($vocabulary->vid);
|
||||
$this->assertEntityPattern('taxonomy', $vocabulary->vid, '', 'base');
|
||||
|
||||
// Create a node type and test that it's pattern variable works.
|
||||
$type = $this->addNodeType(array('type' => 'old_name'));
|
||||
variable_set('pathauto_node_pattern', 'base');
|
||||
variable_set("pathauto_node_old_name_pattern", 'bundle');
|
||||
$this->assertEntityPattern('node', 'old_name', '', 'bundle');
|
||||
|
||||
// Rename the node type's machine name, which should cause its pattern
|
||||
// variable to also be renamed.
|
||||
$type->type = 'new_name';
|
||||
$type->old_type = 'old_name';
|
||||
node_type_save($type);
|
||||
node_types_rebuild();
|
||||
$this->assertEntityPattern('node', 'new_name', '', 'bundle');
|
||||
$this->assertEntityPattern('node', 'old_name', '', 'base');
|
||||
|
||||
// Delete the node type, which should cause its pattern variable to also
|
||||
// be deleted.
|
||||
node_type_delete($type->type);
|
||||
$this->assertEntityPattern('node', 'new_name', '', 'base');
|
||||
}
|
||||
|
||||
function testNoExistingPathAliases() {
|
||||
variable_set('pathauto_node_page_pattern', '[title-raw]');
|
||||
variable_set('pathauto_punctuation_period', 2); // Do not replace periods.
|
||||
|
||||
// Check that Pathauto does not create an alias of '/admin'.
|
||||
$node = $this->drupalCreateNode(array('title' => 'Admin', 'type' => 'page'));
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that Pathauto does not create an alias of '/modules'.
|
||||
$node->title = 'Modules';
|
||||
node_save($node);
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that Pathauto does not create an alias of '/index.php'.
|
||||
$node->title = 'index.php';
|
||||
node_save($node);
|
||||
$this->assertNoEntityAlias('node', $node);
|
||||
|
||||
// Check that a safe value gets an automatic alias. This is also a control
|
||||
// to ensure the above tests work properly.
|
||||
$node->title = 'Safe value';
|
||||
node_save($node);
|
||||
$this->assertEntityAlias('node', $node, 'safe-value');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper test class with some added functions for testing.
|
||||
*/
|
||||
class PathautoFunctionalTestHelper extends PathautoTestHelper {
|
||||
protected $admin_user;
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
parent::setUp($modules);
|
||||
|
||||
// Set pathauto settings we assume to be as-is in this test.
|
||||
variable_set('pathauto_node_page_pattern', 'content/[title-raw]');
|
||||
|
||||
// Allow other modules to add additional permissions for the admin user.
|
||||
$permissions = array(
|
||||
'administer pathauto',
|
||||
'administer url aliases',
|
||||
'create url aliases',
|
||||
'administer nodes',
|
||||
'administer users',
|
||||
);
|
||||
$args = func_get_args();
|
||||
if (isset($args[1]) && is_array($args[1])) {
|
||||
$permissions = array_merge($permissions, $args[1]);
|
||||
}
|
||||
$this->admin_user = $this->drupalCreateUser($permissions);
|
||||
|
||||
$this->drupalLogin($this->admin_user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic pathauto functionality.
|
||||
*/
|
||||
class PathautoFunctionalTestCase extends PathautoFunctionalTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto basic tests',
|
||||
'description' => 'Test basic pathauto functionality.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic functional testing of Pathauto.
|
||||
*/
|
||||
function testNodeEditing() {
|
||||
// Create node for testing.
|
||||
$random_title = $this->randomName(10);
|
||||
$title = ' Simpletest title ' . $random_title . ' [';
|
||||
$automatic_alias = 'content/simpletest-title-' . strtolower($random_title);
|
||||
$node = $this->drupalCreateNode(array('title' => $title, 'type' => 'page'));
|
||||
|
||||
// Look for alias generated in the form.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertFieldChecked('edit-pathauto-perform-alias');
|
||||
$this->assertFieldByName('path', $automatic_alias, 'Proper automated alias generated.');
|
||||
|
||||
// Check whether the alias actually works.
|
||||
$this->drupalGet($automatic_alias);
|
||||
$this->assertText($title, 'Node accessible through automatic alias.');
|
||||
|
||||
// Manually set the node's alias.
|
||||
$manual_alias = 'content/' . $node->nid;
|
||||
$edit = array(
|
||||
'pathauto_perform_alias' => FALSE,
|
||||
'path' => $manual_alias,
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText(t('@type @title has been updated', array('@type' => 'Page', '@title' => $title)));
|
||||
|
||||
// Check that the automatic alias checkbox is now unchecked by default.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertNoFieldChecked('edit-pathauto-perform-alias');
|
||||
$this->assertFieldByName('path', $manual_alias);
|
||||
|
||||
// Submit the node form with the default values.
|
||||
$this->drupalPost(NULL, array(), t('Save'));
|
||||
$this->assertText(t('@type @title has been updated', array('@type' => 'Page', '@title' => $title)));
|
||||
|
||||
// Test that the old (automatic) alias has been deleted and only accessible
|
||||
// through the new (manual) alias.
|
||||
$this->drupalGet($automatic_alias);
|
||||
$this->assertResponse(404, 'Node not accessible through automatic alias.');
|
||||
$this->drupalGet($manual_alias);
|
||||
$this->assertText($title, 'Node accessible through manual alias.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test node operations.
|
||||
*/
|
||||
function testNodeOperations() {
|
||||
$node1 = $this->drupalCreateNode(array('title' => 'node1'));
|
||||
$node2 = $this->drupalCreateNode(array('title' => 'node2'));
|
||||
|
||||
// Delete all current URL aliases.
|
||||
$this->deleteAllAliases();
|
||||
|
||||
$edit = array(
|
||||
'operation' => 'pathauto_update_alias',
|
||||
"nodes[{$node1->nid}]" => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/content/node', $edit, t('Update'));
|
||||
$this->assertText('Updated URL alias for 1 node.');
|
||||
|
||||
$this->assertEntityAlias('node', $node1, 'content/' . $node1->title);
|
||||
$this->assertEntityAlias('node', $node2, 'node/' . $node2->nid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user operations.
|
||||
*/
|
||||
function testUserOperations() {
|
||||
$account = $this->drupalCreateUser();
|
||||
|
||||
// Delete all current URL aliases.
|
||||
$this->deleteAllAliases();
|
||||
|
||||
$edit = array(
|
||||
'operation' => 'pathauto_update_alias',
|
||||
"accounts[{$account->uid}]" => TRUE,
|
||||
);
|
||||
$this->drupalPost('admin/user/user', $edit, t('Update'));
|
||||
$this->assertText('Updated URL alias for 1 user account.');
|
||||
|
||||
$this->assertEntityAlias('user', $account, 'users/' . drupal_strtolower($account->name));
|
||||
$this->assertEntityAlias('user', $this->admin_user, 'user/' . $this->admin_user->uid);
|
||||
}
|
||||
|
||||
function testSettingsValidation() {
|
||||
$edit = array();
|
||||
$edit['pathauto_max_length'] = 'abc';
|
||||
$edit['pathauto_max_component_length'] = 'abc';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length is not a valid number.');
|
||||
$this->assertText('The field Maximum component length is not a valid number.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '0';
|
||||
$edit['pathauto_max_component_length'] = '0';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length cannot be less than 1.');
|
||||
$this->assertText('The field Maximum component length cannot be less than 1.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '999';
|
||||
$edit['pathauto_max_component_length'] = '999';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The field Maximum alias length cannot be greater than 128.');
|
||||
$this->assertText('The field Maximum component length cannot be greater than 128.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_max_length'] = '50';
|
||||
$edit['pathauto_max_component_length'] = '50';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
}
|
||||
|
||||
function testPatternsValidation() {
|
||||
$edit = array();
|
||||
$edit['pathauto_node_pattern'] = '[title-raw]/[user-created-small]/[cat]/[term]';
|
||||
$edit['pathauto_node_page_pattern'] = 'page';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The Default path pattern (applies to all node types with blank patterns below) is using the following invalid tokens: [user-created-small], [cat].');
|
||||
$this->assertText('The Pattern for all Page paths should contain at least one token to ensure unique URL aliases are created.');
|
||||
$this->assertNoText('The configuration options have been saved.');
|
||||
|
||||
$edit['pathauto_node_pattern'] = '[title-raw]';
|
||||
$edit['pathauto_node_page_pattern'] = 'page/[title-raw]';
|
||||
$edit['pathauto_node_story_pattern'] = '';
|
||||
$this->drupalPost('admin/build/path/pathauto', $edit, 'Save configuration');
|
||||
$this->assertText('The configuration options have been saved.');
|
||||
}
|
||||
}
|
||||
|
||||
class PathautoLocaleTestCase extends PathautoFunctionalTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto localization tests',
|
||||
'description' => 'Test pathauto functionality with localization and translation.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'locale';
|
||||
$modules[] = 'translation';
|
||||
parent::setUp($modules, array('administer languages'));
|
||||
|
||||
// Add predefined French language and reset the locale cache.
|
||||
require_once './includes/locale.inc';
|
||||
locale_add_language('fr', NULL, NULL, LANGUAGE_LTR, '', 'fr');
|
||||
language_list('language', TRUE);
|
||||
drupal_init_language();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when an English node is updated, its old English alias is
|
||||
* updated and its newer French alias is left intact.
|
||||
*/
|
||||
function testLanguageAliases() {
|
||||
$node = array(
|
||||
'title' => 'English node',
|
||||
'language' => 'en',
|
||||
'path' => 'english-node',
|
||||
'pathauto_perform_alias' => FALSE,
|
||||
);
|
||||
$node = $this->drupalCreateNode($node);
|
||||
$english_alias = $this->path_load(array('alias' => 'english-node'));
|
||||
$this->assertTrue($english_alias, 'Alias created with proper language.');
|
||||
|
||||
// Also save a French alias that should not be left alone, even though
|
||||
// it is the newer alias.
|
||||
$this->saveEntityAlias('node', $node, 'french-node', 'fr');
|
||||
|
||||
// Add an alias with the soon-to-be generated alias, causing the upcoming
|
||||
// alias update to generate a unique alias with the '-0' suffix.
|
||||
$this->saveAlias('node/invalid', 'content/english-node', '');
|
||||
|
||||
// Update the node, triggering a change in the English alias.
|
||||
$node->pathauto_perform_alias = TRUE;
|
||||
pathauto_nodeapi($node, 'update');
|
||||
|
||||
// Check that the new English alias replaced the old one.
|
||||
$this->assertEntityAlias('node', $node, 'content/english-node-0', 'en');
|
||||
$this->assertEntityAlias('node', $node, 'french-node', 'fr');
|
||||
$this->assertAliasExists(array('pid' => $english_alias['pid'], 'alias' => 'content/english-node-0'));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit tests for the book tokens provided by Pathauto.
|
||||
*/
|
||||
class PathautoBookTokenTestCase extends PathautoTestHelper {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto book tokens',
|
||||
'description' => 'Unit tests for the book tokens provided by Pathauto.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'book';
|
||||
parent::setUp($modules);
|
||||
|
||||
variable_set('book_allowed_types', array('book', 'page'));
|
||||
variable_set('pathauto_node_book_pattern', '[bookpathalias]/[title-raw]');
|
||||
}
|
||||
|
||||
function testBookPathAlias() {
|
||||
// Add a non-book node.
|
||||
$non_book_node = $this->drupalCreateNode(array('type' => 'book'));
|
||||
$this->assertToken('node', $non_book_node, 'bookpathalias', '');
|
||||
|
||||
// Add a root book page.
|
||||
$parent_node = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Root',
|
||||
'book' => array('bid' => 'new') + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => '',
|
||||
);
|
||||
$this->assertTokens('node', $parent_node, $tokens);
|
||||
|
||||
// Add a first child page.
|
||||
$child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node1, $tokens);
|
||||
|
||||
// Add a second child page.
|
||||
$child_node2 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub page2',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $parent_node->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root',
|
||||
);
|
||||
$this->assertTokens('node', $child_node2, $tokens);
|
||||
|
||||
// Add a child page on an existing child page.
|
||||
$sub_child_node1 = $this->drupalCreateNode(array(
|
||||
'type' => 'book',
|
||||
'title' => 'Sub-sub Page1',
|
||||
'book' => array(
|
||||
'bid' => $parent_node->book['bid'],
|
||||
'plid' => $child_node1->book['mlid'],
|
||||
) + _book_link_defaults('new'),
|
||||
));
|
||||
$tokens = array(
|
||||
'bookpathalias' => 'root/sub-page1',
|
||||
);
|
||||
$this->assertTokens('node', $sub_child_node1, $tokens);
|
||||
|
||||
// Test that path tokens should not be altered.
|
||||
$this->saveEntityAlias('node', $child_node1, 'My Crazy/Alias/');
|
||||
pathauto_nodeapi($sub_child_node1, 'update');
|
||||
$this->assertEntityAlias('node', $sub_child_node1, 'My Crazy/Alias/sub-sub-page1');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Unit tests for the taxonomy tokens provided by Pathauto.
|
||||
*/
|
||||
class PathautoTaxonomyTokenTestCase extends PathautoFunctionalTestHelper {
|
||||
protected $vocab;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pathauto taxonomy tokens',
|
||||
'description' => 'Unit tests for the taxonomy tokens provided by Pathauto.',
|
||||
'group' => 'Pathauto',
|
||||
'dependencies' => array('token'),
|
||||
);
|
||||
}
|
||||
|
||||
function setUp(array $modules = array()) {
|
||||
$modules[] = 'taxonomy';
|
||||
parent::setUp($modules);
|
||||
|
||||
variable_set('pathauto_taxonomy_pattern', 'category/[vocab-raw]/[cat-raw]');
|
||||
// Reset the static taxonomy.module caches.
|
||||
taxonomy_vocabulary_load(0, TRUE);
|
||||
taxonomy_get_term(0, TRUE);
|
||||
$this->vocab = $this->addVocabulary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the [catpath] and [catalias] tokens.
|
||||
*/
|
||||
function testCatTokens() {
|
||||
$term1 = $this->addTerm($this->vocab);
|
||||
$tokens = array(
|
||||
'catpath' => $term1->name,
|
||||
'catalias' => "category/{$this->vocab->name}/{$term1->name}",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term1, $tokens);
|
||||
|
||||
// Change the term name to check that the alias is also changed.
|
||||
// Regression test for http://drupal.org/node/822174.
|
||||
$term1->oldname = $term1->name;
|
||||
$term1->name = drupal_strtolower($this->randomName());
|
||||
$form_values = (array) $term1;
|
||||
taxonomy_save_term($form_values);
|
||||
$tokens = array(
|
||||
'catpath' => $term1->name,
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term1, $tokens);
|
||||
|
||||
$term2 = $this->addTerm($this->vocab, array('parent' => $term1->tid));
|
||||
$tokens = array(
|
||||
'catpath' => "{$term1->name}/{$term2->name}",
|
||||
'catalias' => "category/{$this->vocab->name}/{$term2->name}",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term2, $tokens);
|
||||
|
||||
$term3 = $this->addTerm($this->vocab, array('parent' => $term2->tid, 'name' => ' foo/bar fer|zle '));
|
||||
$tokens = array(
|
||||
'catpath' => "{$term1->name}/{$term2->name}/foobar-ferzle",
|
||||
'catalias' => "category/{$this->vocab->name}/foobar-ferzle",
|
||||
);
|
||||
$this->assertTokens('taxonomy', $term3, $tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the [termpath] token.
|
||||
*/
|
||||
function testTermTokens() {
|
||||
$term1 = $this->addTerm($this->vocab, array('weight' => 5));
|
||||
$term2 = $this->addTerm($this->vocab, array('weight' => -5));
|
||||
$term3 = $this->addTerm($this->vocab, array('weight' => 0));
|
||||
|
||||
$node = $this->drupalCreateNode(array(
|
||||
'type' => 'story',
|
||||
'taxonomy' => array($term1->tid, $term2->tid, $term3->tid),
|
||||
));
|
||||
$tokens = array(
|
||||
'termpath' => $term2->name,
|
||||
'termalias' => "category/{$this->vocab->name}/{$term2->name}",
|
||||
);
|
||||
$this->assertTokens('node', $node, $tokens);
|
||||
$this->assertToken('node', $node, 'termpath', $term2->name);
|
||||
$this->assertToken('node', $node, 'termalias', "category/{$this->vocab->name}/{$term2->name}");
|
||||
|
||||
$non_term_node = $this->drupalCreateNode(array('type' => 'story'));
|
||||
$tokens = array(
|
||||
'termpath' => '',
|
||||
'termalias' => '',
|
||||
);
|
||||
$this->assertTokens('node', $non_term_node, $tokens);
|
||||
}
|
||||
}
|
Reference in a new issue