mapping.test in Feeds Paragraphs 7
Contains MappingTestCase.
File
tests/mapping.testView source
<?php
/**
* @file
* Contains MappingTestCase.
*/
/**
* Tests mapping a single value to a Paragraphs field.
*/
class FeedsParaMapperMappingTestCase extends FeedsParaMapperWebTestCase {
/**
* Lets SimpleTest knows about this test class.
*/
public static function getInfo() {
return array(
'name' => 'Single Value Mapping Test',
'description' => 'Insures that mapping a single value to a Paragraphs field works correctly',
'group' => 'Paragraphs Mapper',
);
}
/**
* Test the user can see paragraphs fields in fields mapping.
*/
public function testFieldsAvailable() {
foreach ($this->bundles[0]['fields'] as $field) {
$bundle_field = $field['name'];
$this
->drupalGet('admin/structure/feeds/' . $this->importer . '/mapping');
$message = format_string("The Paragraphs bundle field @field is found", array(
"@field" => $bundle_field,
));
$this
->assertText($bundle_field, $message, "Mapping");
}
}
}
/**
* Tests mapping to a nested Paragraphs field.
*/
class FeedsParaMapperNestedMappingTestCase extends FeedsParaMapperWebTestCase {
/**
* Lets SimpleTest knows about this test class.
*/
public static function getInfo() {
return array(
'name' => 'Nested Mapping Test',
'description' => 'Insures that mapping to a nested Paragraphs field works correctly',
'group' => 'Paragraphs Mapper',
);
}
/**
* Prepares the test environment.
*/
public function setUp() {
parent::setUp(NULL, NULL, TRUE);
}
/**
* Test the user can see paragraphs fields in fields mapping.
*/
public function testFieldsAvailable() {
foreach ($this->bundles[0]['fields'] as $field) {
$bundle_field = 'field_' . $field['name'];
$this
->drupalGet('admin/structure/feeds/' . $this->importer . '/mapping');
$message = format_string("The Paragraphs bundle field @field is found.", array(
"@field" => $bundle_field,
));
$this
->assertText($bundle_field, $message, "Mapping");
}
}
}
/**
* Tests mapping to a multi-valued Paragraphs field.
*/
class FeedsParaMapperMultiValuedMappingTestCase extends FeedsParaMapperWebTestCase {
/**
* Lets SimpleTest knows about this test class.
*/
public static function getInfo() {
return array(
'name' => 'Multi-valued Mapping Test',
'description' => 'Insures that mapping to a multi-valued Paragraphs field works correctly',
'group' => 'Paragraphs Mapper',
);
}
/**
* Prepares the test environment.
*/
public function setUp() {
parent::setUp(TRUE, TRUE);
}
/**
* Test the user can see paragraphs fields in fields mapping.
*
* 1- Checks if the paragraphs bundles fields are visible.
* 2- Checks if a multi valued field has the settings.
*/
public function testSettingsAvailable() {
$target = 'field_' . $this->bundles[0]['fields'][0]['name'];
$this
->drupalGet('admin/structure/feeds/' . $this->importer . '/mapping');
$targets = array(
'text' => $target,
);
$this
->map($targets);
// Click the gear button so it shows the configuration form:
$button_name = "mapping_settings_edit_0";
$this
->drupalPostAJAX(NULL, array(), $button_name);
$message = "Maximum Values field exists";
$this
->assertField('config[0][settings][max_values]', $message);
}
}
Classes
Name | Description |
---|---|
FeedsParaMapperMappingTestCase | Tests mapping a single value to a Paragraphs field. |
FeedsParaMapperMultiValuedMappingTestCase | Tests mapping to a multi-valued Paragraphs field. |
FeedsParaMapperNestedMappingTestCase | Tests mapping to a nested Paragraphs field. |