Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
01d1f2eb
Commit
01d1f2eb
authored
12 years ago
by
Chris Leppanen
Browse files
Options
Downloads
Patches
Plain Diff
Add test for new mapping config.
parent
17269f88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/feeds_mapper_config.test
+115
-0
115 additions, 0 deletions
tests/feeds_mapper_config.test
with
115 additions
and
0 deletions
tests/feeds_mapper_config.test
0 → 100644
+
115
−
0
View file @
01d1f2eb
<?php
/**
* @file
* Test cases for Feeds mapping configuration form.
*/
/**
* Class for testing basic Feeds ajax mapping configurtaion form behavior.
*/
class
FeedsMapperConfigTestCase
extends
FeedsMapperTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Mapper: Config'
,
'description'
=>
'Test the mapper configuration UI.'
,
'group'
=>
'Feeds'
,
);
}
public
function
setUp
()
{
parent
::
setUp
(
array
(
'feeds_tests'
));
}
/**
* Basic test of mapping configuration.
*/
public
function
test
()
{
// Create importer configuration.
$this
->
createImporterConfiguration
();
$this
->
addMappings
(
'syndication'
,
array
(
array
(
'source'
=>
'url'
,
'target'
=>
'test_target'
,
),
));
// Click gear to get form.
$this
->
drupalPostAJAX
(
NULL
,
array
(),
'mapping_settings_edit_0'
);
// Set some settings.
$edit
=
array
(
'config[0][settings][checkbox]'
=>
1
,
'config[0][settings][textfield]'
=>
'Some text'
,
'config[0][settings][textarea]'
=>
'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff'
,
'config[0][settings][radios]'
=>
'option1'
,
'config[0][settings][select]'
=>
'option4'
,
);
$this
->
drupalPostAJAX
(
NULL
,
$edit
,
'mapping_settings_update_0'
);
// Click Save.
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
// Reload.
$this
->
drupalGet
(
'admin/structure/feeds/syndication/mapping'
);
// See if our settings were saved.
$this
->
assertText
(
'Checkbox active.'
);
$this
->
assertText
(
'Textfield value: Some text'
);
$this
->
assertText
(
'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff'
);
$this
->
assertText
(
'Radios value: Option 1'
);
$this
->
assertText
(
'Select value: Another One'
);
// Check that settings are in db.
$config
=
unserialize
(
db_query
(
"SELECT config FROM
{
feeds_importer
}
WHERE id='syndication'"
)
->
fetchField
());
$settings
=
$config
[
'processor'
][
'config'
][
'mappings'
][
0
];
$this
->
assertEqual
(
$settings
[
'checkbox'
],
1
);
$this
->
assertEqual
(
$settings
[
'textfield'
],
'Some text'
);
$this
->
assertEqual
(
$settings
[
'textarea'
],
'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff'
);
$this
->
assertEqual
(
$settings
[
'radios'
],
'option1'
);
$this
->
assertEqual
(
$settings
[
'select'
],
'option4'
);
// Check that form validation works.
// Click gear to get form.
$this
->
drupalPostAJAX
(
NULL
,
array
(),
'mapping_settings_edit_0'
);
// Set some settings.
$edit
=
array
(
// Required form item.
'config[0][settings][textfield]'
=>
''
,
);
$this
->
drupalPostAJAX
(
NULL
,
$edit
,
'mapping_settings_update_0'
);
$this
->
assertText
(
'A text field field is required.'
);
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
// Reload.
$this
->
drupalGet
(
'admin/structure/feeds/syndication/mapping'
);
// Value has not changed.
$this
->
assertText
(
'Textfield value: Some text'
);
// Check that multiple mappings work.
$this
->
addMappings
(
'syndication'
,
array
(
1
=>
array
(
'source'
=>
'url'
,
'target'
=>
'test_target'
,
),
));
$this
->
assertText
(
'Checkbox active.'
);
$this
->
assertText
(
'Checkbox inactive.'
);
// Click gear to get form.
$this
->
drupalPostAJAX
(
NULL
,
array
(),
'mapping_settings_edit_1'
);
// Set some settings.
$edit
=
array
(
'config[1][settings][textfield]'
=>
'Second mapping text'
,
);
$this
->
drupalPostAJAX
(
NULL
,
$edit
,
'mapping_settings_update_1'
);
// Click Save.
$this
->
drupalPost
(
NULL
,
array
(),
t
(
'Save'
));
// Reload.
$this
->
drupalGet
(
'admin/structure/feeds/syndication/mapping'
);
$this
->
assertText
(
'Checkbox active.'
);
$this
->
assertText
(
'Checkbox inactive.'
);
$this
->
assertText
(
'Second mapping text'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment