function ServicesEntityBasic::testPropertyFetchingFromFields in Services Entity API 7
File
- tests/
services_entity.test, line 163
Class
Code
function testPropertyFetchingFromFields() {
// Simple text property (non translatable, cardinality 1).
$cases['field_text_single'] = array(
'field' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => 0,
),
);
$cases['field_text_single']['expected'][] = array(
'content' => array(),
'result' => NULL,
);
$cases['field_text_single']['expected'][] = array(
'content' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content',
),
),
),
'result' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => 0,
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content',
),
),
),
);
// Simple text property (translatable, cardinality 1).
$cases['field_text_single_translatable'] = array(
'field' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => 1,
),
);
$cases['field_text_single_translatable']['expected'][] = array(
'content' => array(),
'result' => NULL,
);
$cases['field_text_single_translatable']['expected'][] = array(
'content' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
),
),
'result' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => 1,
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
),
),
);
$cases['field_text_single_translatable']['expected'][] = array(
'content' => array(
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
),
),
'result' => array(
'type' => 'text',
'cardinality' => 1,
'translatable' => 1,
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
),
),
);
// Simple text property (translatable, cardinality 2).
$cases['field_text_double_translatable'] = array(
'field' => array(
'type' => 'text',
'cardinality' => 2,
'translatable' => 1,
),
);
$cases['field_text_double_translatable']['expected'][] = array(
'content' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
1 => array(
'value' => 'Test content bis (fr)',
),
),
),
'result' => array(
'type' => 'text',
'cardinality' => 2,
'translatable' => 1,
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
1 => array(
'value' => 'Test content bis (fr)',
),
),
),
);
// Simple text property (translatable, cardinality -1).
$cases['field_text_infinite_translatable'] = array(
'field' => array(
'type' => 'text',
'cardinality' => -1,
'translatable' => 1,
),
);
$cases['field_text_infinite_translatable']['expected'][] = array(
'content' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
1 => array(
'value' => 'Test content bis (und)',
),
2 => array(
'value' => 'Test content ter (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
1 => array(
'value' => 'Test content bis (fr)',
),
),
),
'result' => array(
'type' => 'text',
'cardinality' => -1,
'translatable' => 1,
LANGUAGE_NONE => array(
0 => array(
'value' => 'Test content (und)',
),
1 => array(
'value' => 'Test content bis (und)',
),
2 => array(
'value' => 'Test content ter (und)',
),
),
'fr' => array(
0 => array(
'value' => 'Test content (fr)',
),
1 => array(
'value' => 'Test content bis (fr)',
),
),
),
);
$this
->assertFieldPropertyFetching($cases);
}