Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
link
Commits
601d0f11
Commit
601d0f11
authored
Nov 14, 2019
by
damienmckenna
Committed by
Damien McKenna
Nov 14, 2019
Browse files
Issue #3094307 by DamienMcKenna: Clean up tests a bit.
parent
16bc1bac
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
156 deletions
+86
-156
tests/link.attribute.test
tests/link.attribute.test
+8
-8
tests/link.crud.test
tests/link.crud.test
+6
-7
tests/link.crud_browser.test
tests/link.crud_browser.test
+10
-22
tests/link.entity_token.test
tests/link.entity_token.test
+6
-3
tests/link.multilingual.test
tests/link.multilingual.test
+8
-8
tests/link.test
tests/link.test
+2
-4
tests/link.token.test
tests/link.token.test
+5
-6
tests/link.validate.test
tests/link.validate.test
+41
-98
No files found.
tests/link.attribute.test
View file @
601d0f11
...
...
@@ -35,11 +35,15 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setup
()
{
parent
::
setup
(
'field_ui'
,
'link'
);
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'
,
...
...
@@ -236,7 +240,6 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'@content_type_friendly'
=>
$content_type_friendly
,
'@title'
=>
$node_title
,
)));
}
/**
...
...
@@ -332,11 +335,8 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
/**
* Formatter URL.
*
* @codingStandardsIgnoreStart
*/
public
function
testFormatterURL
()
{
// @codingStandardsIgnoreEnd
public
function
testFormatterUrl
()
{
$content_type_friendly
=
$this
->
randomName
(
20
);
$content_type_machine
=
strtolower
(
$this
->
randomName
(
10
));
...
...
tests/link.crud.test
View file @
601d0f11
...
...
@@ -25,10 +25,12 @@ class LinkContentCrudTest extends DrupalWebTestCase {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
()
{
parent
::
setUp
(
'field_ui'
,
'link'
);
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'field_ui'
;
$modules
[]
=
'link'
;
parent
::
setUp
(
$modules
);
}
/**
...
...
@@ -36,11 +38,8 @@ class LinkContentCrudTest extends DrupalWebTestCase {
*
* All we're doing here is creating a content type, creating a simple link
* field on that content type.
*
* @codingStandardsIgnoreStart
*/
public
function
testLinkCreateFieldAPI
()
{
// @codingStandardsIgnoreEnd
public
function
testLinkCreateFieldApi
()
{
$content_type_friendly
=
$this
->
randomName
(
20
);
$content_type_machine
=
strtolower
(
$this
->
randomName
(
10
));
...
...
tests/link.crud_browser.test
View file @
601d0f11
...
...
@@ -8,7 +8,7 @@
/**
* Testing that users can not input bad URLs or labels.
*/
class
LinkU
I
Test
extends
DrupalWebTestcase
{
class
LinkU
i
Test
extends
DrupalWebTestcase
{
/**
* Link supposed to be good.
...
...
@@ -37,10 +37,12 @@ class LinkUITest extends DrupalWebTestcase {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
()
{
parent
::
setUp
(
'field_ui'
,
'link'
);
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'field_ui'
;
$modules
[]
=
'link'
;
parent
::
setUp
(
$modules
);
}
/**
...
...
@@ -191,7 +193,6 @@ class LinkUITest extends DrupalWebTestcase {
* title actually displays <strong>.
*/
public
function
testStaticLinkCreate
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -248,11 +249,8 @@ class LinkUITest extends DrupalWebTestcase {
*
* Testing that if you have the title but no url, the title is not sanitized
* twice.
*
* @codingStandardsIgnoreStart
*/
public
function
testCRUDTitleOnlyTitleNoLink
()
{
// @codingStandardsIgnoreEnd
public
function
testCrudTitleOnlyTitleNoLink
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -309,12 +307,8 @@ class LinkUITest extends DrupalWebTestcase {
*
* 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.
*
* @codingStandardsIgnoreStart
*/
public
function
testCRUDCreateFieldDefaults
()
{
// @codingStandardsIgnoreEnd
public
function
testCrudCreateFieldDefaults
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -361,11 +355,8 @@ class LinkUITest extends DrupalWebTestcase {
*
* 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.
*
* @codingStandardsIgnoreStart
*/
public
function
testCRUDCreateFieldWithClass
()
{
// @codingStandardsIgnoreEnd
public
function
testCrudCreateFieldWithClass
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -443,11 +434,8 @@ class LinkUITest extends DrupalWebTestcase {
*
* 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.
*
* @codingStandardsIgnoreStart
*/
public
function
testCRUDCreateFieldWithTwoClasses
()
{
// @codingStandardsIgnoreEnd
public
function
testCrudCreateFieldWithTwoClasses
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
tests/link.entity_token.test
View file @
601d0f11
...
...
@@ -23,10 +23,13 @@ class LinkEntityTokenTest extends LinkBaseTestClass {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
(
$modules
=
array
())
{
parent
::
setUp
(
array
(
'token'
,
'entity'
,
'entity_token'
));
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'token'
;
$modules
[]
=
'entity'
;
$modules
[]
=
'entity_token'
;
parent
::
setUp
(
$modules
);
}
/**
...
...
tests/link.multilingual.test
View file @
601d0f11
...
...
@@ -9,18 +9,17 @@
*/
class
LinkMultilingualTestCase
extends
LinkBaseTestClass
{
public
function
setUp
()
{
$modules
=
func_get_args
();
$modules
=
(
isset
(
$modules
[
0
])
&&
is_array
(
$modules
[
0
])
?
$modules
[
0
]
:
$modules
);
$modules
=
array_merge
(
$modules
,
array
(
'locale'
,
'locale_test'
,
'translation'
,
));
/**
* {@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
);
}
...
...
@@ -188,4 +187,5 @@ class LinkMultilingualPathTest extends LinkMultilingualTestCase {
$this
->
assertEqual
(
$relative_result
,
$relative_expected
,
"Relative alias-url output ('"
.
$relative_result
.
"') looks as expected ('"
.
$relative_expected
.
"')"
);
}
}
}
tests/link.test
View file @
601d0f11
...
...
@@ -23,11 +23,9 @@ class LinkBaseTestClass extends DrupalWebTestCase {
);
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
()
{
$modules
=
func_get_args
();
$modules
=
(
isset
(
$modules
[
0
])
&&
is_array
(
$modules
[
0
])
?
$modules
[
0
]
:
$modules
);
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'field_ui'
;
$modules
[]
=
'link'
;
parent
::
setUp
(
$modules
);
...
...
tests/link.token.test
View file @
601d0f11
...
...
@@ -23,10 +23,11 @@ class LinkTokenTest extends LinkBaseTestClass {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
(
$modules
=
array
())
{
parent
::
setUp
(
array
(
'token'
));
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'token'
;
parent
::
setUp
(
$modules
);
}
/**
...
...
@@ -77,7 +78,6 @@ class LinkTokenTest extends LinkBaseTestClass {
* Creates a node with a link and checks the title value.
*/
public
function
testStaticTokenLinkCreate
()
{
// Create field.
$name
=
$this
->
randomName
();
$settings
=
array
(
...
...
@@ -122,7 +122,6 @@ class LinkTokenTest extends LinkBaseTestClass {
* same.
*/
public
function
testStaticTokenLinkCreate2
()
{
// Create field.
$name
=
$this
->
randomName
();
$settings
=
array
(
...
...
@@ -163,7 +162,6 @@ class LinkTokenTest extends LinkBaseTestClass {
* @codingStandardsIgnoreStart
*/
public
function
_test_Link_With_Title_Attribute_token_url_form
()
{
// @codingStandardsIgnoreEnd
/* $this->loginWithPermissions($this->permissions);
$this->acquireContentTypes(1);
$field_settings = array(
...
...
@@ -190,6 +188,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$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'])));*/
// @codingStandardsIgnoreEnd
$name
=
$this
->
randomName
();
$settings
=
array
(
'instance[settings][attributes][rel]'
=>
'nofollow'
,
...
...
tests/link.validate.test
View file @
601d0f11
...
...
@@ -22,13 +22,9 @@ class LinkValidateTestCase extends LinkBaseTestClass {
}
/**
* Takes a url, and sees if it can validate that the url is valid.
*
* @codingStandardsIgnoreStart
* Takes a URL, sees if it can validate that the URL is valid.
*/
protected
function
link_test_validate_url
(
$url
)
{
// @codingStandardsIgnoreEnd
protected
function
linkTestValidateUrl
(
$url
)
{
$field_name
=
$this
->
createLinkField
();
$label
=
$this
->
randomName
();
...
...
@@ -71,21 +67,15 @@ class LinkValidateTest extends LinkValidateTestCase {
/**
* Validate basic URL.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_validate_basic_url
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'http://www.example.com'
);
public
function
testLinkValidateBasicUrl
()
{
$this
->
linkTestValidateUrl
(
'http://www.example.com'
);
}
/**
* Test if we're stopped from posting a bad url on default validation.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_validate_bad_url_validate_default
()
{
// @codingStandardsIgnoreEnd
public
function
testLinkValidateBadUrlValidateDefault
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -134,11 +124,8 @@ class LinkValidateTest extends LinkValidateTestCase {
/**
* Test if we're stopped from posting a bad url with validation on.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_validate_bad_url_validate_on
()
{
// @codingStandardsIgnoreEnd
public
function
testLinkValidateBadUrlValidateOn
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -188,11 +175,8 @@ class LinkValidateTest extends LinkValidateTestCase {
/**
* Test if we can post a bad url if the validation is expressly turned off.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_validate_bad_url_validate_off
()
{
// @codingStandardsIgnoreEnd
public
function
testLinkValidateBadUrlValidateOff
()
{
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
'administer fields'
,
...
...
@@ -249,11 +233,8 @@ class LinkValidateTest extends LinkValidateTestCase {
*
* Test if a bad url can sneak through un-filtered if we play with the
* validation...
*
* @codingStandardsIgnoreStart
*/
public
function
x_test_link_validate_switching_between_validation_status
()
{
// @codingStandardsIgnoreEnd
public
function
_testLinkValidateSwitchingBetweenValidationStatus
()
{
$this
->
acquireContentTypes
(
1
);
$this
->
web_user
=
$this
->
drupalCreateUser
(
array
(
'administer content types'
,
...
...
@@ -324,58 +305,43 @@ class LinkValidateTest extends LinkValidateTestCase {
/**
* Validate that '<front>' is a valid url.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_front_url
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'<front>'
);
public
function
testLinkFrontUrl
()
{
$this
->
linkTestValidateUrl
(
'<front>'
);
}
/**
* Validate that an internal url would be accepted.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_internal_url
()
{
// @codingStandardsIgnoreEnd
public
function
testLinkInternalUrl
()
{
// Create the content first.
$node
=
$this
->
drupalCreateNode
();
$link
=
'node/'
.
$node
->
nid
;
$this
->
link
_t
est
_v
alidate
_u
rl
(
$link
);
$this
->
link
T
est
V
alidate
U
rl
(
$link
);
$type
=
link_url_type
(
$link
);
$this
->
assertEqual
(
LINK_INTERNAL
,
$type
,
'Test '
.
$link
.
' is an internal link.'
);
}
/**
* Validate a simple mailto.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_mailto
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'mailto:jcfiala@gmail.com'
);
public
function
testLinkMailto
()
{
$this
->
linkTestValidateUrl
(
'mailto:jcfiala@gmail.com'
);
}
/**
* Check link external https.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_external_https
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'https://www.example.com/'
);
public
function
testLinkExternalHttps
()
{
$this
->
linkTestValidateUrl
(
'https://www.example.com/'
);
}
/**
* Check link FTP.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_ftp
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'ftp://www.example.com/'
);
public
function
testLinkFtp
()
{
$this
->
linkTestValidateUrl
(
'ftp://www.example.com/'
);
}
}
...
...
@@ -398,22 +364,16 @@ class LinkValidateTestNews extends LinkValidateTestCase {
/**
* Validate a news link to a message group.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_news
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'news:comp.infosystems.www.misc'
);
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.
*
* @codingStandardsIgnoreStart
*/
public
function
test_link_news_message
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'news:hj0db8$vrm$1@news.eternal-september.org'
);
public
function
testLinkNewsMessage
()
{
$this
->
linkTestValidateUrl
(
'news:hj0db8$vrm$1@news.eternal-september.org'
);
}
}
...
...
@@ -436,65 +396,47 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
/**
* Lets throw in a lot of umlouts for testing!
*
* @codingStandardsIgnoreStart
*/
public
function
test_umlout_url
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'http://üÜü.exämple.com/nöde'
);
public
function
testUmloutUrl
()
{
$this
->
linkTestValidateUrl
(
'http://üÜü.exämple.com/nöde'
);
}
/**
* Check umlout mailto.
*
* @codingStandardsIgnoreStart
*/
public
function
test_umlout_mailto
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'mailto:Üser@exÅmple.com'
);
public
function
testUmloutMailto
()
{
$this
->
linkTestValidateUrl
(
'mailto:Üser@exÅmple.com'
);
}
/**
* Check german b in url.
*
* @codingStandardsIgnoreStart
* Check German b in URL, aka Eszett.
*/
public
function
test_german_b_url
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'http://www.test.com/ßstuff'
);
public
function
testGermanEszettUrl
()
{
$this
->
linkTestValidateUrl
(
'http://www.test.com/ßstuff'
);
}
/**
* Check Special in url.
*
* @codingStandardsIgnoreStart
* Check Spanish ñ in URL.
*/
public
function
test_special_n_url
()
{
// @codingStandardsIgnoreEnd
$this
->
link_test_validate_url
(
'http://www.testÑñ.com/'
);
public
function
testSpecialNUrl
()
{
$this
->
linkTestValidateUrl
(
'http://www.testÑñ.com/'
);
}
/**
* Curly Brackets in query.
*
* @codingStandardsIgnoreStart
* Curly brackets in query.
*/
public
function
test_curly_brackets_in_query
()
{
// @codingStandardsIgnoreEnd
$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}'
);
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.
*
* Basically, trying to test http://drupal.org/node/376818
*
* @codingStandardsIgnoreStart
*/
public
function
testLinkURLFieldIsBig
()
{
// @codingStandardsIgnoreEnd
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
_t
est
_v
alidate
_u
rl
(
$long_url
);
$this
->
link
T
est
V
alidate
U
rl
(
$long_url
);
}
}
...
...
@@ -521,10 +463,11 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
}
/**
*
Setup.
*
{@inheritdoc}
*/
public
function
setUp
()
{
parent
::
setUp
(
'link'
);
public
function
setUp
(
array
$modules
=
array
())
{
$modules
[]
=
'link'
;
parent
::
setUp
(
$modules
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment