|  | @@ -22,7 +22,7 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |     * @returns
 | 
	
		
			
				|  |  |     *   Returns an array where each item to be tested has the paramaters
 | 
	
		
			
				|  |  |     *   needed for initializeWidgetClass(). Specfically, $bundle_name,
 | 
	
		
			
				|  |  | -   *   $field_name, $widget_name, $entity_id.
 | 
	
		
			
				|  |  | +   *   $field_name, $widget_name, $entity_ids, $expect.
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  |    public function provideEntities() {
 | 
	
		
			
				|  |  |       $data = [];
 | 
	
	
		
			
				|  | @@ -51,18 +51,20 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |         // Create some entities so that we know there are some available to find.
 | 
	
		
			
				|  |  |         if ($bundle_details->type_column == 'type_id') {
 | 
	
		
			
				|  |  | -         factory('chado.'. $base_table, 2)->create(['type_id' => $bundle_details->type_id]);
 | 
	
		
			
				|  |  | +         $chado_records = factory('chado.'. $base_table, 2)->create(['type_id' => $bundle_details->type_id]);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         else {
 | 
	
		
			
				|  |  | -         factory('chado.'. $base_table, 2)->create();
 | 
	
		
			
				|  |  | +         $chado_records = factory('chado.'. $base_table, 2)->create();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // Then publish them so we have entities.
 | 
	
		
			
				|  |  |         $this->publish($base_table);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -       // Find an entity from the above bundle.
 | 
	
		
			
				|  |  | -       // @todo find a way to create a fake entity for use here.
 | 
	
		
			
				|  |  | -       $entity_id = db_query('SELECT id FROM tripal_entity WHERE bundle=:bundle LIMIT 1',
 | 
	
		
			
				|  |  | -         array(':bundle' => $bundle_name))->fetchField();
 | 
	
		
			
				|  |  | +       // Find our fake entities from the above bundle.
 | 
	
		
			
				|  |  | +       $entity_ids = [];
 | 
	
		
			
				|  |  | +       $entity_ids[] = db_query('SELECT entity_id FROM chado_'.$bundle_name.' WHERE record_id=:chado_id',
 | 
	
		
			
				|  |  | +         array(':chado_id' => $chado_records[0]->{$base_table.'_id'}))->fetchField();
 | 
	
		
			
				|  |  | +       $entity_ids[] = db_query('SELECT entity_id FROM chado_'.$bundle_name.' WHERE record_id=:chado_id',
 | 
	
		
			
				|  |  | +         array(':chado_id' => $chado_records[1]->{$base_table.'_id'}))->fetchField();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |         // set variables to guide testing.
 | 
	
		
			
				|  |  |         $expect = [
 | 
	
	
		
			
				|  | @@ -80,7 +82,7 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |           $expect['object_key'] = 'object_project_id';
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -       $data[] = [$bundle_name, $field_name, $widget_name, $entity_id, $expect];
 | 
	
		
			
				|  |  | +       $data[] = [$bundle_name, $field_name, $widget_name, $entity_ids, $expect];
 | 
	
		
			
				|  |  |       }
 | 
	
		
			
				|  |  |       return $data;
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -93,7 +95,8 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |     * @group widget
 | 
	
		
			
				|  |  |     * @group sbo__relationship
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function testWidgetClassInitialization($bundle_name, $field_name, $widget_name, $entity_id, $expect) {
 | 
	
		
			
				|  |  | +  public function testWidgetClassInitialization($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +    $entity_id = $entity_ids[0];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Load the entity.
 | 
	
		
			
				|  |  |      $entity = entity_load('TripalEntity', [$entity_id]);
 | 
	
	
		
			
				|  | @@ -135,10 +138,11 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |     * @group widget
 | 
	
		
			
				|  |  |     * @group sbo__relationship
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function testWidgetForm($bundle_name, $field_name, $widget_name, $entity_id, $expect) {
 | 
	
		
			
				|  |  | +  public function testWidgetForm($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +    $entity_id = $entity_ids[0];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Load the entity.
 | 
	
		
			
				|  |  | -    $entity = entity_load('TripalEntity', [$entity_id]);
 | 
	
		
			
				|  |  | +    $entity = entity_load('TripalEntity', [$entity_ids]);
 | 
	
		
			
				|  |  |      $entity = $entity[$entity_id];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
	
		
			
				|  | @@ -192,158 +196,216 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    /**
 | 
	
		
			
				|  |  | -   * DataProvider: Provides datasets to validate.
 | 
	
		
			
				|  |  | +   * Case: WidgetValidate on existing relationship.
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @dataProvider provideEntities()
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @group widget
 | 
	
		
			
				|  |  | +   * @group sbo__relationship
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function provideThings2Validate() {
 | 
	
		
			
				|  |  | -    $data = [];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    foreach (['organism', 'stock', 'project'] as $base_table) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      $base_table = $base_table;
 | 
	
		
			
				|  |  | -      $field_name = 'sbo__relationship';
 | 
	
		
			
				|  |  | -      $widget_name = 'sbo__relationship_widget';
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      // Find a bundle which stores it's data in the given base table.
 | 
	
		
			
				|  |  | -      // This will work on Travis since Tripal creates matching bundles by default.
 | 
	
		
			
				|  |  | -      $bundle_details = db_query("
 | 
	
		
			
				|  |  | -        SELECT bundle_id, type_column, type_id
 | 
	
		
			
				|  |  | -        FROM chado_bundle b
 | 
	
		
			
				|  |  | -        WHERE data_table=:table AND type_linker_table=''
 | 
	
		
			
				|  |  | -        ORDER BY bundle_id ASC LIMIT 1",
 | 
	
		
			
				|  |  | -          array(':table' => $base_table))->fetchObject();
 | 
	
		
			
				|  |  | -      if (isset($bundle_details->bundle_id)) {
 | 
	
		
			
				|  |  | -        $bundle_id = $bundle_details->bundle_id;
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -      else {
 | 
	
		
			
				|  |  | -        continue;
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -      $bundle_name = 'bio_data_'.$bundle_id;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      // set variables to guide testing.
 | 
	
		
			
				|  |  | -      $expect = [
 | 
	
		
			
				|  |  | -        'has_rank' => TRUE,
 | 
	
		
			
				|  |  | -        'has_value' => FALSE,
 | 
	
		
			
				|  |  | -        'subject_key' => 'subject_id',
 | 
	
		
			
				|  |  | -        'object_key' => 'object_id',
 | 
	
		
			
				|  |  | -        'base_table' => $base_table,
 | 
	
		
			
				|  |  | -        'relationship_table' => $base_table.'_relationship',
 | 
	
		
			
				|  |  | -      ];
 | 
	
		
			
				|  |  | -      if ($base_table == 'organism') { $expect['has_rank'] = FALSE; }
 | 
	
		
			
				|  |  | -      if ($base_table == 'stock') { $expect['has_value'] = TRUE; }
 | 
	
		
			
				|  |  | -      if ($base_table == 'project') {
 | 
	
		
			
				|  |  | -        $expect['subject_key'] = 'subject_project_id';
 | 
	
		
			
				|  |  | -        $expect['object_key'] = 'object_project_id';
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      // Create 5 fake records and publish them.
 | 
	
		
			
				|  |  | -      if ($bundle_details->type_column == 'type_id') {
 | 
	
		
			
				|  |  | -        factory('chado.'. $base_table, 5)->create(['type_id' => $bundle_details->type_id]);
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -      else {
 | 
	
		
			
				|  |  | -        factory('chado.'. $base_table, 5)->create();
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -      // Then publish them so we have entities.
 | 
	
		
			
				|  |  | -      $this->publish($base_table);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      $cvterm = factory('chado.cvterm')->create();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      // Find an entity from the above bundle.
 | 
	
		
			
				|  |  | -      $ids = db_query('SELECT id FROM {tripal_entity} WHERE bundle=:bundle LIMIT 2',
 | 
	
		
			
				|  |  | -        array(':bundle' => $bundle_name))->fetchCol();
 | 
	
		
			
				|  |  | -        $entities = entity_load('TripalEntity', $ids);
 | 
	
		
			
				|  |  | -        $entity = array_pop($entities);
 | 
	
		
			
				|  |  | -        $entity2 = array_pop($entities);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -      // Now Build our test cases for this base table.
 | 
	
		
			
				|  |  | -      foreach (['user_create', 'existing', 'no_subject', 'no_object', 'no_type'] as $case) {
 | 
	
		
			
				|  |  | -        $expect['test_case'] = $case;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // First assume "existing" (later we will modify based on case).
 | 
	
		
			
				|  |  | -        $values = [
 | 
	
		
			
				|  |  | -          'subject_name' => $entity2->chado_record->name,
 | 
	
		
			
				|  |  | -          'type_name' => $cvterm->name,
 | 
	
		
			
				|  |  | -          'vocabulary' => $cvterm->cv_id,
 | 
	
		
			
				|  |  | -          'object_name' => $entity->chado_record->name,
 | 
	
		
			
				|  |  | -          // Both the form and load set the chado values
 | 
	
		
			
				|  |  | -          // so we will set them here as well.
 | 
	
		
			
				|  |  | -          'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => $entity2->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | -          'chado-'.$base_table.'_relationship__type_id' => $cvterm->cvterm_id,
 | 
	
		
			
				|  |  | -          'chado-'.$base_table.'_relationship__'.$expect['object_key'] => $entity->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | -        ];
 | 
	
		
			
				|  |  | -        if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | -          $values['subject_name'] = $entity2->chado_record->species;
 | 
	
		
			
				|  |  | -          $values['object_name'] = $entity->chado_record->species;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        $expect['num_errors'] = 0;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        // Now modify based on the case.
 | 
	
		
			
				|  |  | -        switch ($case) {
 | 
	
		
			
				|  |  | -          case 'user_create':
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__'.$expect['subject_key'] ] = NULL;
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__type_id' ] = NULL;
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__'.$expect['object_key'] ] = NULL;
 | 
	
		
			
				|  |  | -            break;
 | 
	
		
			
				|  |  | -          case 'no_subject':
 | 
	
		
			
				|  |  | -            $values['subject_name'] = '';
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__'.$expect['subject_key'] ] = NULL;
 | 
	
		
			
				|  |  | -            $expect['num_errors'] = 1;
 | 
	
		
			
				|  |  | -            break;
 | 
	
		
			
				|  |  | -          case 'no_object':
 | 
	
		
			
				|  |  | -            $values['object_name'] = '';
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__'.$expect['object_key'] ] = NULL;
 | 
	
		
			
				|  |  | -            $expect['num_errors'] = 1;
 | 
	
		
			
				|  |  | -            break;
 | 
	
		
			
				|  |  | -          case 'no_type':
 | 
	
		
			
				|  |  | -            $values['type_name'] = '';
 | 
	
		
			
				|  |  | -            $values['vocabulary'] = NULL;
 | 
	
		
			
				|  |  | -            $values[ 'chado-'.$base_table.'_relationship__type_id' ] = NULL;
 | 
	
		
			
				|  |  | -            $expect['num_errors'] = 1;
 | 
	
		
			
				|  |  | -            break;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        $data[] = [
 | 
	
		
			
				|  |  | -          [
 | 
	
		
			
				|  |  | -            'field_name' => $field_name,
 | 
	
		
			
				|  |  | -            'widget_name' => $widget_name,
 | 
	
		
			
				|  |  | -            'bundle_id' => $bundle_id,
 | 
	
		
			
				|  |  | -            'bundle_name' => $bundle_name,
 | 
	
		
			
				|  |  | -          ],
 | 
	
		
			
				|  |  | -          $entity,
 | 
	
		
			
				|  |  | -          $values,
 | 
	
		
			
				|  |  | -          $expect,
 | 
	
		
			
				|  |  | -        ];
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | +  public function testWidgetValidate_existing($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Load the entities.
 | 
	
		
			
				|  |  | +    $entities = entity_load('TripalEntity', $entity_ids);
 | 
	
		
			
				|  |  | +    $entity1 = $entities[$entity_ids[0]];
 | 
	
		
			
				|  |  | +    $entity2 = $entities[$entity_ids[1]];
 | 
	
		
			
				|  |  | +    $base_table = $entity1->chado_table;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
		
			
				|  |  | +    $machine_names = array(
 | 
	
		
			
				|  |  | +      'field_name' => $field_name,
 | 
	
		
			
				|  |  | +      'widget_name' => $widget_name,
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $field_info = field_info_field($field_name);
 | 
	
		
			
				|  |  | +    $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
 | 
	
		
			
				|  |  | +    $helper = new \TripalFieldTestHelper($bundle_name, $machine_names, $entity1, $field_info, $instance_info);
 | 
	
		
			
				|  |  | +    $widget_class = $helper->getInitializedClass();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Set some initial values.
 | 
	
		
			
				|  |  | +    $cvterm = factory('chado.cvterm')->create();
 | 
	
		
			
				|  |  | +    $initial_values = [
 | 
	
		
			
				|  |  | +      'subject_name' => $entity2->chado_record->name,
 | 
	
		
			
				|  |  | +      'type_name' => $cvterm->name,
 | 
	
		
			
				|  |  | +      'vocabulary' => $cvterm->cv_id,
 | 
	
		
			
				|  |  | +      'object_name' => $entity1->chado_record->name,
 | 
	
		
			
				|  |  | +      // Both the form and load set the chado values
 | 
	
		
			
				|  |  | +      // so we will set them here as well.
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => $entity2->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id' => $cvterm->cvterm_id,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'] => $entity1->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | +      $initial_values['subject_name'] = $entity2->chado_record->species;
 | 
	
		
			
				|  |  | +      $initial_values['object_name'] = $entity1->chado_record->species;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    return $data;
 | 
	
		
			
				|  |  | +    // Mock objects.
 | 
	
		
			
				|  |  | +    $delta = 1;
 | 
	
		
			
				|  |  | +    $langcode = LANGUAGE_NONE;
 | 
	
		
			
				|  |  | +    $widget = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form = $helper->mockForm($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form_state = $helper->mockFormState($delta, $langcode, $initial_values);
 | 
	
		
			
				|  |  | +    $element = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $widget_class->validate($element, $form, $form_state, $langcode, $delta);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // @debug print_r($form_state['values'][$field_name][$langcode][$delta]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Ensure the chado-table__column entries are there.
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the subject_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the subject.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the object_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the object.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id',
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the type_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the type.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Check for errors.
 | 
	
		
			
				|  |  | +    $errors = form_get_errors();
 | 
	
		
			
				|  |  | +    // @debug print "Errors: " . print_r($errors, TRUE)."\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $this->assertEmpty($errors,
 | 
	
		
			
				|  |  | +      "There should be no form errors when subject and object are pre-existing and both are supplied. Initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Clean up after ourselves by removing any errors we logged.
 | 
	
		
			
				|  |  | +    form_clear_error();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    /**
 | 
	
		
			
				|  |  | -   * Test sbo__relationship_widget->validate().
 | 
	
		
			
				|  |  | +   * Case: WidgetValidate on new relationship filled out properly.
 | 
	
		
			
				|  |  |     *
 | 
	
		
			
				|  |  | -   * @dataProvider provideThings2Validate()
 | 
	
		
			
				|  |  | +   * @dataProvider provideEntities()
 | 
	
		
			
				|  |  |     *
 | 
	
		
			
				|  |  | -   * @group lacey-wip
 | 
	
		
			
				|  |  |     * @group widget
 | 
	
		
			
				|  |  |     * @group sbo__relationship
 | 
	
		
			
				|  |  |     */
 | 
	
		
			
				|  |  | -  public function testWidgetValidate($info, $entity, $initial_values, $expect) {
 | 
	
		
			
				|  |  | +  public function testWidgetValidate_create($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    $base_table = $entity->chado_table;
 | 
	
		
			
				|  |  | +    // Load the entities.
 | 
	
		
			
				|  |  | +    $entities = entity_load('TripalEntity', $entity_ids);
 | 
	
		
			
				|  |  | +    $entity1 = $entities[$entity_ids[0]];
 | 
	
		
			
				|  |  | +    $entity2 = $entities[$entity_ids[1]];
 | 
	
		
			
				|  |  | +    $base_table = $entity1->chado_table;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
		
			
				|  |  |      $machine_names = array(
 | 
	
		
			
				|  |  | -      'field_name' => $info['field_name'],
 | 
	
		
			
				|  |  | -      'widget_name' => $info['widget_name'],
 | 
	
		
			
				|  |  | +      'field_name' => $field_name,
 | 
	
		
			
				|  |  | +      'widget_name' => $widget_name,
 | 
	
		
			
				|  |  |      );
 | 
	
		
			
				|  |  | -    $field_info = field_info_field($info['field_name']);
 | 
	
		
			
				|  |  | -    $instance_info = field_info_instance('TripalEntity', $info['field_name'], $info['bundle_name']);
 | 
	
		
			
				|  |  | -    $helper = new \TripalFieldTestHelper($info['bundle_name'], $machine_names, $entity, $field_info, $instance_info);
 | 
	
		
			
				|  |  | +    $field_info = field_info_field($field_name);
 | 
	
		
			
				|  |  | +    $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
 | 
	
		
			
				|  |  | +    $helper = new \TripalFieldTestHelper($bundle_name, $machine_names, $entity1, $field_info, $instance_info);
 | 
	
		
			
				|  |  |      $widget_class = $helper->getInitializedClass();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // Set some initial values.
 | 
	
		
			
				|  |  | +    $cvterm = factory('chado.cvterm')->create();
 | 
	
		
			
				|  |  | +    $initial_values = [
 | 
	
		
			
				|  |  | +      'subject_name' => $entity2->chado_record->name,
 | 
	
		
			
				|  |  | +      'type_name' => $cvterm->name,
 | 
	
		
			
				|  |  | +      'vocabulary' => $cvterm->cv_id,
 | 
	
		
			
				|  |  | +      'object_name' => $entity1->chado_record->name,
 | 
	
		
			
				|  |  | +      // These are not set on the creation form.
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => NULL,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id' => NULL,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'] => NULL,
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | +      $initial_values['subject_name'] = $entity2->chado_record->species;
 | 
	
		
			
				|  |  | +      $initial_values['object_name'] = $entity1->chado_record->species;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Mock objects.
 | 
	
		
			
				|  |  | +    $delta = 1;
 | 
	
		
			
				|  |  | +    $langcode = LANGUAGE_NONE;
 | 
	
		
			
				|  |  | +    $widget = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form = $helper->mockForm($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form_state = $helper->mockFormState($delta, $langcode, $initial_values);
 | 
	
		
			
				|  |  | +    $element = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $widget_class->validate($element, $form, $form_state, $langcode, $delta);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // @debug print_r($form_state['values'][$field_name][$langcode][$delta]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Ensure the chado-table__column entries are there.
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the subject_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the subject.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the object_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the object.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id',
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the type_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the type.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Check for errors.
 | 
	
		
			
				|  |  | +    $errors = form_get_errors();
 | 
	
		
			
				|  |  | +    // @debug print "Errors: " . print_r($errors, TRUE)."\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $this->assertEmpty($errors,
 | 
	
		
			
				|  |  | +      "There should be no form errors when subject and object are pre-existing and both are supplied. Initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Clean up after ourselves by removing any errors we logged.
 | 
	
		
			
				|  |  | +    form_clear_error();
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  /**
 | 
	
		
			
				|  |  | +   * Case: WidgetValidate on new relationship missing subject.
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @dataProvider provideEntities()
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @group widget
 | 
	
		
			
				|  |  | +   * @group sbo__relationship
 | 
	
		
			
				|  |  | +   */
 | 
	
		
			
				|  |  | +  public function testWidgetValidate_nosubject($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Load the entities.
 | 
	
		
			
				|  |  | +    $entities = entity_load('TripalEntity', $entity_ids);
 | 
	
		
			
				|  |  | +    $entity1 = $entities[$entity_ids[0]];
 | 
	
		
			
				|  |  | +    $entity2 = $entities[$entity_ids[1]];
 | 
	
		
			
				|  |  | +    $base_table = $entity1->chado_table;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
		
			
				|  |  | +    $machine_names = array(
 | 
	
		
			
				|  |  | +      'field_name' => $field_name,
 | 
	
		
			
				|  |  | +      'widget_name' => $widget_name,
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $field_info = field_info_field($field_name);
 | 
	
		
			
				|  |  | +    $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
 | 
	
		
			
				|  |  | +    $helper = new \TripalFieldTestHelper($bundle_name, $machine_names, $entity1, $field_info, $instance_info);
 | 
	
		
			
				|  |  | +    $widget_class = $helper->getInitializedClass();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Set some initial values.
 | 
	
		
			
				|  |  | +    $cvterm = factory('chado.cvterm')->create();
 | 
	
		
			
				|  |  | +    $initial_values = [
 | 
	
		
			
				|  |  | +      'subject_name' => '',
 | 
	
		
			
				|  |  | +      'type_name' => $cvterm->name,
 | 
	
		
			
				|  |  | +      'vocabulary' => $cvterm->cv_id,
 | 
	
		
			
				|  |  | +      'object_name' => $entity1->chado_record->name,
 | 
	
		
			
				|  |  | +      // Both the form and load set the chado values
 | 
	
		
			
				|  |  | +      // so we will set them here as well.
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => NULL,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id' => $cvterm->cvterm_id,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'] => $entity1->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | +      $initial_values['object_name'] = $entity1->chado_record->species;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // Mock objects.
 | 
	
		
			
				|  |  | -    $field_name = $info['field_name'];
 | 
	
		
			
				|  |  |      $delta = 1;
 | 
	
		
			
				|  |  |      $langcode = LANGUAGE_NONE;
 | 
	
		
			
				|  |  |      $widget = $helper->mockElement($delta, $langcode);
 | 
	
	
		
			
				|  | @@ -376,16 +438,177 @@ class sbo__relationship_widgetTest extends TripalTestCase {
 | 
	
		
			
				|  |  |      $errors = form_get_errors();
 | 
	
		
			
				|  |  |      // @debug print "Errors: " . print_r($errors, TRUE)."\n";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if ($expect['num_errors'] === 0) {
 | 
	
		
			
				|  |  | -      $this->assertEmpty($errors,
 | 
	
		
			
				|  |  | -        "There should be no form errors for the following initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +    $this->assertNotEmpty($errors,
 | 
	
		
			
				|  |  | +      "There should be form errors when subject is not supplied. Initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Clean up after ourselves by removing any errors we logged.
 | 
	
		
			
				|  |  | +    form_clear_error();
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  /**
 | 
	
		
			
				|  |  | +   * Case: WidgetValidate on new relationship missing object.
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @dataProvider provideEntities()
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @group widget
 | 
	
		
			
				|  |  | +   * @group sbo__relationship
 | 
	
		
			
				|  |  | +   */
 | 
	
		
			
				|  |  | +  public function testWidgetValidate_noobject($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Load the entities.
 | 
	
		
			
				|  |  | +    $entities = entity_load('TripalEntity', $entity_ids);
 | 
	
		
			
				|  |  | +    $entity1 = $entities[$entity_ids[0]];
 | 
	
		
			
				|  |  | +    $entity2 = $entities[$entity_ids[1]];
 | 
	
		
			
				|  |  | +    $base_table = $entity1->chado_table;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
		
			
				|  |  | +    $machine_names = array(
 | 
	
		
			
				|  |  | +      'field_name' => $field_name,
 | 
	
		
			
				|  |  | +      'widget_name' => $widget_name,
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $field_info = field_info_field($field_name);
 | 
	
		
			
				|  |  | +    $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
 | 
	
		
			
				|  |  | +    $helper = new \TripalFieldTestHelper($bundle_name, $machine_names, $entity1, $field_info, $instance_info);
 | 
	
		
			
				|  |  | +    $widget_class = $helper->getInitializedClass();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Set some initial values.
 | 
	
		
			
				|  |  | +    $cvterm = factory('chado.cvterm')->create();
 | 
	
		
			
				|  |  | +    $initial_values = [
 | 
	
		
			
				|  |  | +      'subject_name' => $entity2->chado_record->name,
 | 
	
		
			
				|  |  | +      'type_name' => $cvterm->name,
 | 
	
		
			
				|  |  | +      'vocabulary' => $cvterm->cv_id,
 | 
	
		
			
				|  |  | +      'object_name' => '',
 | 
	
		
			
				|  |  | +      // Both the form and load set the chado values
 | 
	
		
			
				|  |  | +      // so we will set them here as well.
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => $entity2->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id' => $cvterm->cvterm_id,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'] => NULL,
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | +      $initial_values['subject_name'] = $entity2->chado_record->species;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    else {
 | 
	
		
			
				|  |  | -      $this->assertEquals($expect['num_errors'], sizeof($errors),
 | 
	
		
			
				|  |  | -        "The number of errors didn't match what we expected for the following initial values: ".print_r($initial_values,TRUE)." Here are the errors: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Mock objects.
 | 
	
		
			
				|  |  | +    $delta = 1;
 | 
	
		
			
				|  |  | +    $langcode = LANGUAGE_NONE;
 | 
	
		
			
				|  |  | +    $widget = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form = $helper->mockForm($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form_state = $helper->mockFormState($delta, $langcode, $initial_values);
 | 
	
		
			
				|  |  | +    $element = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $widget_class->validate($element, $form, $form_state, $langcode, $delta);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // @debug print_r($form_state['values'][$field_name][$langcode][$delta]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Ensure the chado-table__column entries are there.
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the subject_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the subject.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the object_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the object.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id',
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the type_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the type.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Check for errors.
 | 
	
		
			
				|  |  | +    $errors = form_get_errors();
 | 
	
		
			
				|  |  | +    // @debug print "Errors: " . print_r($errors, TRUE)."\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $this->assertNotEmpty($errors,
 | 
	
		
			
				|  |  | +      "There should be form errors when the object is not supplied. Initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Clean up after ourselves by removing any errors we logged.
 | 
	
		
			
				|  |  | +    form_clear_error();
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  /**
 | 
	
		
			
				|  |  | +   * Case: WidgetValidate on new relationship missing type.
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @dataProvider provideEntities()
 | 
	
		
			
				|  |  | +   *
 | 
	
		
			
				|  |  | +   * @group widget
 | 
	
		
			
				|  |  | +   * @group sbo__relationship
 | 
	
		
			
				|  |  | +   */
 | 
	
		
			
				|  |  | +  public function testWidgetValidate_notype($bundle_name, $field_name, $widget_name, $entity_ids, $expect) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Load the entities.
 | 
	
		
			
				|  |  | +    $entities = entity_load('TripalEntity', $entity_ids);
 | 
	
		
			
				|  |  | +    $entity1 = $entities[$entity_ids[0]];
 | 
	
		
			
				|  |  | +    $entity2 = $entities[$entity_ids[1]];
 | 
	
		
			
				|  |  | +    $base_table = $entity1->chado_table;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Initialize the widget class via the TripalFieldTestHelper class.
 | 
	
		
			
				|  |  | +    $machine_names = array(
 | 
	
		
			
				|  |  | +      'field_name' => $field_name,
 | 
	
		
			
				|  |  | +      'widget_name' => $widget_name,
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $field_info = field_info_field($field_name);
 | 
	
		
			
				|  |  | +    $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
 | 
	
		
			
				|  |  | +    $helper = new \TripalFieldTestHelper($bundle_name, $machine_names, $entity1, $field_info, $instance_info);
 | 
	
		
			
				|  |  | +    $widget_class = $helper->getInitializedClass();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Set some initial values.
 | 
	
		
			
				|  |  | +    $initial_values = [
 | 
	
		
			
				|  |  | +      'subject_name' => $entity2->chado_record->name,
 | 
	
		
			
				|  |  | +      'type_name' => '',
 | 
	
		
			
				|  |  | +      'vocabulary' => NULL,
 | 
	
		
			
				|  |  | +      'object_name' => $entity1->chado_record->name,
 | 
	
		
			
				|  |  | +      // Both the form and load set the chado values
 | 
	
		
			
				|  |  | +      // so we will set them here as well.
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'] => $entity2->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id' => NULL,
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'] => $entity1->chado_record->{$base_table.'_id'},
 | 
	
		
			
				|  |  | +    ];
 | 
	
		
			
				|  |  | +    if ($base_table == 'organism') {
 | 
	
		
			
				|  |  | +      $initial_values['subject_name'] = $entity2->chado_record->species;
 | 
	
		
			
				|  |  | +      $initial_values['object_name'] = $entity1->chado_record->species;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // Mock objects.
 | 
	
		
			
				|  |  | +    $delta = 1;
 | 
	
		
			
				|  |  | +    $langcode = LANGUAGE_NONE;
 | 
	
		
			
				|  |  | +    $widget = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form = $helper->mockForm($delta, $langcode);
 | 
	
		
			
				|  |  | +    $form_state = $helper->mockFormState($delta, $langcode, $initial_values);
 | 
	
		
			
				|  |  | +    $element = $helper->mockElement($delta, $langcode);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $widget_class->validate($element, $form, $form_state, $langcode, $delta);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // @debug print_r($form_state['values'][$field_name][$langcode][$delta]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Ensure the chado-table__column entries are there.
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['subject_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the subject_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the subject.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__'.$expect['object_key'],
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the object_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the object.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +    $this->assertArrayHasKey(
 | 
	
		
			
				|  |  | +      'chado-'.$base_table.'_relationship__type_id',
 | 
	
		
			
				|  |  | +      $form_state['values'][$field_name][$langcode][$delta],
 | 
	
		
			
				|  |  | +      'Failed to find the type_id in the processed values (Base: '.$base_table.'). This implies the validate function was not able to validate the type.'
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // Check for errors.
 | 
	
		
			
				|  |  | +    $errors = form_get_errors();
 | 
	
		
			
				|  |  | +    // @debug print "Errors: " . print_r($errors, TRUE)."\n";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $this->assertNotEmpty($errors,
 | 
	
		
			
				|  |  | +      "There should be form errors when type is not supplied. Initial values: ".print_r($initial_values,TRUE)." But these were registered: ".print_r($errors, TRUE));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // Clean up after ourselves by removing any errors we logged.
 | 
	
		
			
				|  |  |      form_clear_error();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |