public function MerciBaseTestCase::createDummyProductDisplayContentType in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Create a dummy product display content type.
Parameters
$type: Machine name of the content type to create. Also used for human readable name to keep things simple.
$attach_product_reference_field: If TRUE, automatically add a product reference field to the new content type.
$field_name: Only used if $attach_product_reference_field is TRUE. Sets the name for the field instance to attach. Creates the field if it doesn't exist.
$cardinality_reference_field: Only used if $attach_product_reference_field is TRUE. Sets the cardinality for the field instance to attach.
Return value
An object for the content type.
See also
attachProductReferenceField()
3 calls to MerciBaseTestCase::createDummyProductDisplayContentType()
- MerciBaseTestCase::createDummyProductNodeBatch in merci_core/
tests/ merci_base.test - Create a full product node without worrying about the earlier steps in the process.
- MerciBaseTesterTestCase::_testTestCreateDummyProductDisplayAndRefField in merci_core/
tests/ merci_base.test - Test the creation of a product_display content type and add a product reference field to the content type.
- MerciBaseTesterTestCase::_testTestCreateDummyProductNode in merci_core/
tests/ merci_base.test - Test the createDummyProductNode function.
File
- merci_core/
tests/ merci_base.test, line 316 - Defines abstract base test class for the Merci module tests.
Class
- MerciBaseTestCase
- Abstract class for Merci testing. All Merci tests should extend this class.
Code
public function createDummyProductDisplayContentType($type = 'product_display', $attach_product_reference_field = TRUE, $field_name = 'field_product', $cardinality_reference_field = 1) {
// If the specified node type already exists, return it now.
if ($content_type = node_type_load($type)) {
return $content_type;
}
$content_type = array(
'type' => $type,
'name' => $type,
// Don't use a human readable name here to keep it simple.
'base' => 'node_content',
'description' => 'Use <em>product displays</em> to display products for sale to your customers.',
'custom' => 1,
'modified' => 1,
'locked' => 0,
);
$content_type = node_type_set_defaults($content_type);
node_type_save($content_type);
node_add_body_field($content_type);
$this
->pass("Created content type: {$type}");
if ($attach_product_reference_field) {
// Maybe $instance should be returned as well
$instance = $this
->attachProductReferenceField($type, $field_name, $cardinality_reference_field);
}
return $content_type;
}