first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
// $Id: nodereference.devel_generate.inc,v 1.1 2010/01/28 21:06:42 weitzman Exp $
function node_reference_devel_generate($object, $field, $instance, $bundle) {
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_CUSTOM) {
return devel_generate_multiple('_node_reference_devel_generate', $object, $field, $instance, $bundle);
}
else {
return _node_reference_devel_generate($object, $field, $instance, $bundle);
}
}
function _node_reference_devel_generate($object, $field, $instance, $bundle) {
$object_field = array();
$allowed_values = node_reference_potential_references($field);
// unset($allowed_values[0]);
if (!empty($allowed_values)) {
// Just pick one of the specified allowed values.
$object_field['nid'] = array_rand($allowed_values);
}
return $object_field;
}

View File

@@ -0,0 +1,15 @@
name = Node Reference
description = Defines a field type for referencing one node from another.
package = Fields
core = 7.x
dependencies[] = field
dependencies[] = references
dependencies[] = options
files[] = node_reference.test
; Information added by drupal.org packaging script on 2011-12-22
version = "7.x-2.0"
core = "7.x"
project = "references"
datestamp = "1324596643"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,100 @@
<?php
/**
* @file
* Initial node_reference tests
*/
/**
* Unit tests for referenceability of node types in entity forms.
*/
class NodeReferenceFormTest extends FieldTestCase {
public static function getInfo() {
return array(
'name' => 'Node reference',
'description' => 'Make sure nodes are referenceable in entity forms.',
'group' => 'References',
);
}
function setUp() {
parent::setUp(array('node_reference', 'field_test'));
$this->langcode = LANGUAGE_NONE;
$this->field_name = 'test_node_reference';
$this->field = array(
'field_name' => $this->field_name,
'type' => 'node_reference',
'cardinality' => 1,
'settings' => array(
'referenceable_types' => array_keys(node_type_get_names()),
),
);
$this->field = field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'widget' => array(
'type' => 'options_buttons',
),
);
$this->instance = field_create_instance($this->instance);
$this->nodes = array();
foreach (node_type_get_names() as $type_name => $type_title) {
$this->nodes[$type_name] = $this->drupalCreateNode(array(
'type' => $type_name,
'title' => $this->randomName(8),
));
$this->pass(t('Created %type node %nid: %title', array(
'%type' => $type_name,
'%nid' => $this->nodes[$type_name]->nid,
'%title' => $this->nodes[$type_name]->title,
)), 'destination creation');
}
}
function runReferenceableNodeTest($allowed, $group) {
field_update_field(array(
'field_name' => $this->field_name,
'settings' => array('referenceable_types' => array_keys($allowed)),
));
$entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity);
$options = $form[$this->field_name][$this->langcode]['#options'];
$this->assertTrue(isset($options['_none']), t('Empty choice offered for reference'), $group);
unset($options['_none']);
foreach ($this->nodes as $node) {
if (isset($allowed[$node->type])) {
$this->assertTrue(isset($options[$node->nid]),
t('Node of type @type is referenceable', array('@type' => $node->type)),
$group);
}
else {
$this->assertFalse(isset($options[$node->nid]),
t('Node of type @type is not referenceable', array('@type' => $node->type)),
$group);
}
unset($options[$node->nid]);
}
$this->assertTrue(empty($options), t('No extra choice is referenceable'), $group);
}
/**
* Test unlimited referencing
*/
function testReferenceableNodeTypesAll() {
$allowed = node_type_get_names();
$this->runReferenceableNodeTest($allowed, t('Unimited referencing'));
}
/**
* Test referencing a limited list of node types
*/
function testReferenceableNodeTypesOne() {
$allowed = array_slice(node_type_get_names(), 0, 1, TRUE);
$this->runReferenceableNodeTest($allowed, t('Limited referencing'));
}
}