function bibcite_entity_test_install in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/tests/bibcite_entity_test/bibcite_entity_test.install \bibcite_entity_test_install()
Implements hook_install().
Create test content.
File
- modules/
bibcite_entity/ tests/ bibcite_entity_test/ bibcite_entity_test.install, line 17 - Module installation hooks.
Code
function bibcite_entity_test_install() {
$keywords_data = [
[
'name' => 'Ancient artwork',
],
[
'name' => 'Renaissance literature',
],
];
$keywords = [];
foreach ($keywords_data as $data) {
$keyword_entity = Keyword::create($data);
$keyword_entity
->save();
$keywords[] = $keyword_entity;
}
$contributors_data = [
[
'first_name' => 'John',
'last_name' => 'Doe',
],
[
'first_name' => 'Mark',
'last_name' => 'Twain',
],
];
$contributors = [];
foreach ($contributors_data as $data) {
$contributor_entity = Contributor::create($data);
$contributor_entity
->save();
$contributors[] = $contributor_entity;
}
$reference_data = [
[
'title' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'type' => 'journal_article',
'keyword' => reset($keywords),
'author' => reset($contributors),
'bibcite_year' => '1992',
'bibcite_issue' => '1',
'bibcite_volume' => '5',
'bibcite_pages' => '1-13',
'bibcite_publisher' => 'Journal',
],
[
'title' => 'Proin ut laoreet purus. Maecenas sed scelerisque leo.',
'type' => 'journal_article',
'keyword' => $keywords,
'author' => $contributors,
'bibcite_year' => '2001',
'bibcite_issue' => '15',
'bibcite_volume' => '2',
'bibcite_pages' => '5-8',
'bibcite_publisher' => 'Journal',
],
];
$reference = [];
foreach ($reference_data as $data) {
$reference_entity = Reference::create($data);
$reference_entity
->save();
$reference[] = $reference_entity;
}
}