public function test_events()
 {
     $a = EE_Attendee::new_instance();
     $a->save();
     $this->assertNotEquals($a->ID(), 0);
     $e1 = EE_Event::new_instance(array('EVT_name' => '1'));
     $e1->save();
     $this->assertNotEquals($e1->ID(), 0);
     $e2 = EE_Event::new_instance(array('EVT_name' => '2'));
     $e2->save();
     $this->assertNotEquals($e2->ID(), 0);
     $e3 = EE_Event::new_instance(array('EVT_name' => '3'));
     $e3->save();
     $this->assertNotEquals($e3->ID(), 0);
     $r1 = EE_Registration::new_instance(array('EVT_ID' => $e1->ID(), 'ATT_ID' => $a->ID()));
     $r1->save();
     $this->assertNotEquals($r1->ID(), 0);
     $r2 = EE_Registration::new_instance(array('EVT_ID' => $e2->ID(), 'ATT_ID' => $a->ID()));
     $r2->save();
     $this->assertNotEquals($r2->ID(), 0);
     $events = $a->events();
     $this->assertArrayContains($e1, $events);
     $this->assertArrayContains($e2, $events);
     $this->assertArrayDoesNotContain($e3, $events);
 }
 function test_post_type()
 {
     $e = EE_Event::new_instance(array('EVT_name' => 'e1'));
     $this->assertEquals('espresso_events', $e->post_type());
     $e->save();
     $this->assertEquals('espresso_events', $e->post_type());
     $a = EE_Attendee::new_instance(array('ATT_fname' => 'mr', 'ATT_lname' => 'perfect'));
     $this->assertEquals('espresso_attendees', $a->post_type());
     $a->save();
     $this->assertEquals('espresso_attendees', $a->post_type());
 }
 public function test_soft_delete()
 {
     $a1 = EE_Attendee::new_instance(array('ATT_fname' => 'tim', 'ATT_lname' => 'bob', 'ATT_email' => '*****@*****.**'));
     $a1->save();
     $a2 = EE_Attendee::new_instance(array('ATT_fname' => 'update-me', 'ATT_lname' => 'man', 'ATT_email' => '*****@*****.**'));
     $a2->save();
     //and isnert another attendee NOT using the models system
     $new_attendee_id = wp_insert_post(array('post_name' => 'update-me-abnormal-man', 'post_content' => 'the man', 'post_status' => 'publish', 'post_type' => 'espresso_attendees'), TRUE);
     $this->assertNotEmpty($new_attendee_id);
     $this->assertFalse(is_array($new_attendee_id));
     global $wpdb;
     $wpdb->insert($wpdb->prefix . "esp_attendee_meta", array('ATT_ID' => $new_attendee_id, 'ATT_fname' => 'update-me-abnormal', 'ATT_lname' => 'man', 'ATT_email' => 'few@fewd.v4'), array('%d', '%s', '%s', '%s'));
     $this->assertNotEmpty($wpdb->insert_id);
     //soft delete 'update-me' and 'update-me-abnormal'
     $att_model = EE_Registry::instance()->load_model('Attendee');
     $att_model->delete(array(array('ATT_lname' => 'man')));
     $this->assertNotEquals(EEM_CPT_Base::post_status_trashed, $a1->status());
     $this->assertEquals(EEM_CPT_Base::post_status_trashed, $a2->status());
     $abnormal_attendee = $att_model->get_one_by_ID($new_attendee_id);
     $this->assertInstanceOf('EE_Attendee', $abnormal_attendee);
     $this->assertEquals(EEM_CPT_Base::post_status_trashed, $abnormal_attendee->status());
 }
 /**
  *    create_new_attendee
  *
  * @param EE_Registration $registration
  * @param array           $attendee_data
  * @return \EE_Attendee
  */
 private function _create_new_attendee(EE_Registration $registration, $attendee_data = array())
 {
     // create new attendee object
     $new_attendee = EE_Attendee::new_instance($attendee_data);
     // set author to event creator
     $new_attendee->set('ATT_author', $registration->event()->wp_user());
     $new_attendee->save();
     return $new_attendee;
 }
 /**
  * Determines if the attendee class has been extended by teh mock extension
  * @return boolean
  */
 private function _class_has_been_extended($throw_error = FALSE)
 {
     try {
         $a = EE_Attendee::new_instance();
         $a->foobar();
         return TRUE;
     } catch (EE_Error $e) {
         if ($throw_error) {
             throw $e;
         }
         return FALSE;
     }
 }
 /**
  * This just returns an array of dummy attendee objects that we'll use to attach to events for our preview data
  *
  * @access private
  * @return array an array of attendee objects
  */
 private function _get_some_attendees()
 {
     //let's just setup a dummy array of various attendee details
     $dummy_attendees = array(0 => array('Luke', 'Skywalker', '*****@*****.**', '804 Bantha Dr.', 'Complex 8', 'Mos Eisley', 32, 'US', 'f0r3e', '222-333-4763', FALSE, '999999991'), 1 => array('Princess', 'Leia', '*****@*****.**', '1456 Valley Way Boulevard', 'Suite 9', 'Alderaan', 15, 'US', 'c1h2c', '78-123-111-1111', FALSE, '999999992'), 2 => array('Yoda', 'I Am', '*****@*****.**', '4th Tree', '5th Knot', 'Marsh', 22, 'US', 'l18n', '999-999-9999', FALSE, '999999993'));
     //let's generate the attendee objects
     $attendees = array();
     $var_array = array('fname', 'lname', 'email', 'address', 'address2', 'city', 'staid', 'cntry', 'zip', 'phone', 'deleted', 'attid');
     EE_Registry::instance()->load_class('Attendee', array(), FALSE, TRUE, TRUE);
     foreach ($dummy_attendees as $dummy) {
         $att = array_combine($var_array, $dummy);
         extract($att);
         $attendees[$attid] = EE_Attendee::new_instance(array('ATT_fname' => $fname, 'ATT_lname' => $lname, 'ATT_address' => $address, 'ATT_address2' => $address2, 'ATT_city' => $city, 'STA_ID' => $staid, 'CNT_ISO' => $cntry, 'ATT_zip' => $zip, 'ATT_email' => $email, 'ATT_phone' => $phone, 'ATT_ID' => $attid));
     }
     return $attendees;
 }
 /**
  * create_attendee_from_billing_form_data
  * uses info from the billing form to create a new attendee
  * @return \EE_Attendee
  */
 public function create_attendee_from_billing_form_data()
 {
     // grab billing form data
     $data = $this->valid_data();
     return EE_Attendee::new_instance(array('ATT_fname' => !empty($data['first_name']) ? $data['first_name'] : '', 'ATT_lname' => !empty($data['last_name']) ? $data['last_name'] : '', 'ATT_email' => !empty($data['email']) ? $data['email'] : '', 'ATT_address' => !empty($data['address']) ? $data['address'] : '', 'ATT_address2' => !empty($data['address2']) ? $data['address2'] : '', 'ATT_city' => !empty($data['city']) ? $data['city'] : '', 'STA_ID' => !empty($data['state']) ? $data['state'] : '', 'CNT_ISO' => !empty($data['country']) ? $data['country'] : '', 'ATT_zip' => !empty($data['zip']) ? $data['zip'] : '', 'ATT_phone' => !empty($data['phone']) ? $data['phone'] : ''));
 }
 /**
  *
  */
 public function test_update__keeps_model_objs_in_sync()
 {
     $att1 = EE_Attendee::new_instance(array('ATT_fname' => 'one'));
     $att2 = EE_Attendee::new_instance(array('ATT_fname' => 'two'));
     $att3 = EE_Attendee::new_instance(array('ATT_fname' => 'three'));
     $att1->save();
     $att2->save();
     $att3->save();
     //test taht when do perform an update, the model objects are updated also
     $attm = EE_Registry::instance()->load_model('EEM_Attendee');
     $attm->update(array('ATT_fname' => 'win'), array(array('ATT_fname' => 'two')));
     $this->assertEquals('one', $att1->fname());
     $this->assertEquals('win', $att2->fname());
     $this->assertEquals('three', $att3->fname());
     //now test doing an update that should be more efficient wehre we DON'T update
     //model objects
     $attm->update(array('ATT_fname' => 'win_again'), array(array('ATT_fname' => 'one')), FALSE);
     $this->assertEquals('one', $att1->fname());
     $this->assertEquals('win', $att2->fname());
     $this->assertEquals('three', $att3->fname());
     global $wpdb;
     $name_in_db = $wpdb->get_var("select ATT_fname FROM " . $wpdb->prefix . "esp_attendee_meta WHERE ATT_ID = " . $att1->ID());
     $this->assertEquals('win_again', $name_in_db);
     //also test to make sure there are no errors when there was nothing to update in the entity map
     $att4 = EEM_Attendee::instance()->insert(array('ATT_fname' => 'four'));
     $wpdb->last_error = NULL;
     EEM_Attendee::instance()->update(array('ATT_fname' => 'lose'), array(array('ATT_fname' => 'four')));
     $this->assertEmpty($wpdb->last_error);
     //and that there are no errors when nothing at all is updated
     EEM_Attendee::instance()->update(array('ATT_fname' => 'lose_again'), array(array('ATT_fname' => 'nonexistent')));
     $this->assertEmpty($wpdb->last_error);
 }
 /**
  * create_attendee_from_request_data
  * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
  * @return \EE_Attendee
  */
 protected function _create_attendee_from_request_data()
 {
     // get State ID
     $STA_ID = !empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
     if (!empty($STA_ID)) {
         // can we get state object from name ?
         EE_Registry::instance()->load_model('State');
         $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
         $STA_ID = is_array($state) && !empty($state) ? reset($state) : $STA_ID;
     }
     // get Country ISO
     $CNT_ISO = !empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
     if (!empty($CNT_ISO)) {
         // can we get country object from name ?
         EE_Registry::instance()->load_model('Country');
         $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO');
         $CNT_ISO = is_array($country) && !empty($country) ? reset($country) : $CNT_ISO;
     }
     // grab attendee data
     $attendee_data = array('ATT_fname' => !empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', 'ATT_lname' => !empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', 'ATT_email' => !empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', 'ATT_address' => !empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', 'ATT_address2' => !empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', 'ATT_city' => !empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'ATT_zip' => !empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', 'ATT_phone' => !empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '');
     // validate the email address since it is the most important piece of info
     if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) {
         EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
     }
     // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
     if (!empty($attendee_data['ATT_fname']) && !empty($attendee_data['ATT_lname']) && !empty($attendee_data['ATT_email'])) {
         $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array('ATT_fname' => $attendee_data['ATT_fname'], 'ATT_lname' => $attendee_data['ATT_lname'], 'ATT_email' => $attendee_data['ATT_email']));
         if ($existing_attendee instanceof EE_Attendee) {
             return $existing_attendee;
         }
     }
     // no existing attendee? kk let's create a new one
     // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
     $attendee_data['ATT_fname'] = !empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
     $attendee_data['ATT_lname'] = !empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
     return EE_Attendee::new_instance($attendee_data);
 }
 /**
  * Test the filter callback for get_edit_post_link
  *
  * @since 4.3.0
  * @depends test_loading_admin
  */
 function test_modify_edit_post_link()
 {
     //add contact post
     $attendee = EE_Attendee::new_instance(array('ATT_full_name' => 'Test Dude'));
     $attendee->save();
     $id = $attendee->ID();
     //dummy link for testing
     $orig_link = 'http://testdummylink.com';
     EE_Registry::instance()->load_helper('URL');
     $expected_link = EEH_URL::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $id), admin_url('admin.php?page=espresso_registrations'));
     //first test that if the id given doesn't match our post type that the original link is returned.
     $notmodified = EE_Admin::instance()->modify_edit_post_link($orig_link, 5555, '');
     $this->assertEquals($orig_link, $notmodified);
     //next test that if the id given matches our post type that the expected link is generated
     $ismodified = EE_Admin::instance()->modify_edit_post_link($orig_link, $id, '');
     $this->assertEquals($expected_link, $ismodified);
 }
 /**
  * used by factory to create attendee object.
  *
  * @since 4.3.0
  *
  * @param array $args Incoming field values to set on the new object
  *
  * @return EE_Attendee|false
  */
 public function create_object($args)
 {
     $attendee = EE_Attendee::new_instance($args);
     $attendeeID = $attendee->save();
     $attendee = $this->_maybe_chained($attendee, $args);
     $attendee->save();
     return $attendeeID ? $attendee : false;
 }
 /**
  * 	_process_attendee_information
  *
  * 	@access 	private
  * @return mixed
  */
 private function _process_attendee_information()
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     $success = TRUE;
     // empty container
     $valid_data = array();
     if (EE_Registry::instance()->REQ->is_set('qstn')) {
         $valid_data = apply_filters('FHEE__EE_Single_Page_Checkout__process_attendee_information__REQ', EE_Registry::instance()->REQ->get('qstn'));
         // loop through post data and sanitize all elements
         array_walk_recursive($valid_data, array(EE_Registry::instance()->REQ, 'sanitize_text_field_for_array_walk'));
     }
     // if we don't have any $valid_data then something went TERRIBLY WRONG !!! AHHHHHHHH!!!!!!!
     if (!empty($valid_data)) {
         if (isset($valid_data['custom_questions'])) {
             if (!$this->_reg_url_link) {
                 EE_Registry::instance()->SSN->set_session_data(array('custom_questions' => $valid_data['custom_questions']));
             }
             unset($valid_data['custom_questions']);
         }
         $primary_attendee = array();
         $primary_attendee_obj = NULL;
         $primary_attendee['line_item_id'] = NULL;
         if (isset($valid_data['primary_attendee'])) {
             $primary_attendee['line_item_id'] = !empty($valid_data['primary_attendee']) ? $valid_data['primary_attendee'] : FALSE;
             unset($valid_data['primary_attendee']);
         }
         //			printr( $valid_data, '$valid_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         //			printr( $this->_transaction, '$this->_transaction  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
         // attendee counter
         $att_nmbr = 0;
         if ($this->_continue_reg) {
             if ($this->_transaction instanceof EE_Transaction && $this->_continue_reg) {
                 $registrations = $this->_transaction->registrations(array(), TRUE);
                 if (!empty($registrations)) {
                     EE_Registry::instance()->load_model('Attendee');
                     $primary_attendee_obj = NULL;
                     // grab the saved registrations from the transaction
                     foreach ($registrations as $registration) {
                         // verify EE_Registration object
                         if ($registration instanceof EE_Registration) {
                             // if event is sold out but this is NOT a revisit
                             if ($this->_revisit || !$this->_revisit && !($registration->event()->is_sold_out() || $registration->event()->is_sold_out(TRUE))) {
                                 // EITHER a) first time thru SPCO so process ALL registrations
                                 // OR b) primary registrant is editing info, so process ALL registrations
                                 // OR b) another registrant is editing info, so ONLY process their registration
                                 if (!$this->_revisit || $this->_primary_revisit || $this->_revisit && $this->_reg_url_link == $registration->reg_url_link()) {
                                     // reg_url_link / line item ID exists ?
                                     if ($line_item_id = $registration->reg_url_link()) {
                                         //										echo '<h5 style="color:#2EA2CC;">$line_item_id : <span style="color:#E76700">' . $line_item_id . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                                         // Houston, we have a registration!
                                         $att_nmbr++;
                                         // grab related answer objects
                                         $answers = $registration->answers();
                                         //										printr( $answers, '$answers  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                         $attendee_data = array();
                                         // do we need to copy basic info from primary attendee ?
                                         $copy_primary = isset($valid_data[$line_item_id]['additional_attendee_reg_info']) && absint($valid_data[$line_item_id]['additional_attendee_reg_info']) === 0 ? TRUE : FALSE;
                                         //										echo '<h5 style="color:#2EA2CC;">$copy_primary : <span style="color:#E76700">' . $copy_primary . '</span><br/><span style="font-size:9px;font-weight:normal;color:#666">' . __FILE__ . '</span>    <b style="font-size:10px;color:#333">  ' . __LINE__ . ' </b></h5>';
                                         unset($valid_data[$line_item_id]['additional_attendee_reg_info']);
                                         if (isset($valid_data[$line_item_id])) {
                                             // filter form input data for this registration
                                             $valid_data[$line_item_id] = apply_filters('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', $valid_data[$line_item_id]);
                                             //									printr( $valid_data[ $line_item_id ], '$valid_data[ $line_item_id ]  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                             // now loop through our array of valid post data && process attendee reg forms
                                             foreach ($valid_data[$line_item_id] as $form_input => $input_value) {
                                                 // check for critical inputs
                                                 if (empty($input_value)) {
                                                     switch ($form_input) {
                                                         case 'fname':
                                                             EE_Error::add_error(__('First Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                                                             $success = FALSE;
                                                             break;
                                                         case 'lname':
                                                             EE_Error::add_error(__('Last Name is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                                                             $success = FALSE;
                                                             break;
                                                         case 'email':
                                                             EE_Error::add_error(__('Email Address is a required value.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                                                             $success = FALSE;
                                                             break;
                                                     }
                                                 } elseif ($form_input == 'email') {
                                                     // clean the email address
                                                     $valid_email = sanitize_email($input_value);
                                                     // check if it matches
                                                     if ($input_value != $valid_email) {
                                                         // whoops!!!
                                                         EE_Error::add_error(__('Please enter a valid email address.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                                                         $success = FALSE;
                                                     }
                                                 }
                                                 // store a bit of data about the primary attendee
                                                 if ($att_nmbr == 1 && $line_item_id == $primary_attendee['line_item_id'] && !empty($input_value)) {
                                                     $primary_attendee[$form_input] = $input_value;
                                                 } else {
                                                     if ($copy_primary && isset($primary_attendee[$form_input]) && $input_value == NULL) {
                                                         $input_value = $primary_attendee[$form_input];
                                                     }
                                                 }
                                                 // $answer_cache_id is the key used to find the EE_Answer we want
                                                 $answer_cache_id = $this->_reg_url_link ? $form_input : $form_input . '-' . $line_item_id;
                                                 $answer_is_obj = isset($answers[$answer_cache_id]) && $answers[$answer_cache_id] instanceof EE_Answer ? TRUE : FALSE;
                                                 //rename a couple of form_inputs
                                                 switch ($form_input) {
                                                     case 'state':
                                                         $form_input = 'STA_ID';
                                                         $attendee_property = TRUE;
                                                         break;
                                                     case 'country':
                                                         $form_input = 'CNT_ISO';
                                                         $attendee_property = TRUE;
                                                         break;
                                                     default:
                                                         $attendee_property = EEM_Attendee::instance()->has_field('ATT_' . $form_input) ? TRUE : FALSE;
                                                         $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
                                                 }
                                                 //		echo '<h4>$answer_cache_id : ' . $answer_cache_id . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                                                 //		echo '<h4>attendee_property: ' . $attendee_property . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                                                 //		echo '<h4>$answer_is_obj : ' . $answer_is_obj . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                                                 //		echo '<h4>' . $form_input . ': ' . ( is_array( $input_value ) ? implode( ', ', $input_value ) : $input_value ) . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                                                 $saved = FALSE;
                                                 // if this form input has a corresponding attendee property
                                                 if ($attendee_property) {
                                                     $attendee_data[$form_input] = $input_value;
                                                     if ($answer_is_obj) {
                                                         // and delete the corresponding answer since we won't be storing this data in that object
                                                         $registration->_remove_relation_to($answers[$answer_cache_id], 'Answer');
                                                     }
                                                     $saved = TRUE;
                                                 } elseif ($answer_is_obj) {
                                                     // save this data to the answer object
                                                     $answers[$answer_cache_id]->set_value($input_value);
                                                     $saved = TRUE;
                                                 } else {
                                                     foreach ($answers as $answer) {
                                                         if ($answer instanceof EE_Answer && $answer->question_ID() == $answer_cache_id) {
                                                             $answer->set_value($input_value);
                                                             $saved = TRUE;
                                                         }
                                                     }
                                                 }
                                                 if (!$saved) {
                                                     EE_Error::add_error(sprintf(__('Unable to save registration form data for the form input: %s', 'event_espresso'), $form_input), __FILE__, __FUNCTION__, __LINE__);
                                                     $success = FALSE;
                                                 }
                                             }
                                             // end of foreach ( $valid_data[ $line_item_id ] as $form_input => $input_value )
                                         }
                                         /*else {
                                         			EE_Error::add_error( sprintf( __( 'It appears that no form data, or invalid data, for attendee #%s was received while attempting to process the registration form.', 'event_espresso' ), $att_nmbr ), __FILE__, __FUNCTION__, __LINE__ );
                                         			$success = FALSE;
                                         		}*/
                                         //											printr( $attendee_data, '$attendee_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                         //											printr( $answers, '$answers  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                         // this registration does not require additional attendee information ?
                                         if ($copy_primary && $att_nmbr > 1) {
                                             //										echo '<h1>$copy_primary && $att_nmbr > 1  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h1>';
                                             // add relation to new attendee
                                             $registration->_add_relation_to($primary_attendee_obj, 'Attendee');
                                             $registration->set_attendee_id($primary_attendee_obj->ID());
                                             $registration->update_cache_after_object_save('Attendee', $primary_attendee_obj);
                                             //										echo '$copy_primary attendee: '. $primary_attendee_obj->ID() . '<br/>';
                                         } else {
                                             // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
                                             $ATT_fname = isset($attendee_data['ATT_fname']) && !empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : '';
                                             $ATT_lname = isset($attendee_data['ATT_lname']) && !empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : '';
                                             $ATT_email = isset($attendee_data['ATT_email']) && !empty($attendee_data['ATT_email']) ? $attendee_data['ATT_email'] : '';
                                             // but only if those have values
                                             if ($ATT_fname && $ATT_lname && $ATT_email) {
                                                 $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array('ATT_fname' => $ATT_fname, 'ATT_lname' => $ATT_lname, 'ATT_email' => $ATT_email));
                                             } else {
                                                 $existing_attendee = NULL;
                                             }
                                             //										printr( $existing_attendee, '$existing_attendee  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                             $existing_attendee = apply_filters('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', $existing_attendee, $registration);
                                             // did we find an already existing record for this attendee ?
                                             if ($existing_attendee instanceof EE_Attendee) {
                                                 //												echo '<h1>$existing_attendee instanceof EE_Attendee  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h1>';
                                                 // update attendee data in case it has changed since last time they registered for an event
                                                 // first remove fname, lname, and email from attendee data
                                                 unset($attendee_data['ATT_fname']);
                                                 unset($attendee_data['ATT_lname']);
                                                 unset($attendee_data['ATT_email']);
                                                 // now loop thru what's left and add to attendee CPT
                                                 foreach ($attendee_data as $property_name => $property_value) {
                                                     if (EEM_Attendee::instance()->has_field($property_name)) {
                                                         $existing_attendee->set($property_name, $property_value);
                                                     }
                                                 }
                                                 // better save that now
                                                 $existing_attendee->save();
                                                 // add relation to existing attendee
                                                 $registration->_add_relation_to($existing_attendee, 'Attendee');
                                                 $registration->set_attendee_id($existing_attendee->ID());
                                                 $registration->update_cache_after_object_save('Attendee', $existing_attendee);
                                             } else {
                                                 // ensure critical details are set for additional attendees
                                                 if ($att_nmbr > 1) {
                                                     $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
                                                     $critical_attendee_details = apply_filters('FHEE__EE_Single_Page_Checkout__process_attendee_information__critical_attendee_details', $critical_attendee_details);
                                                     foreach ($critical_attendee_details as $critical_attendee_detail) {
                                                         if (!isset($attendee_data[$critical_attendee_detail]) || empty($attendee_data[$critical_attendee_detail])) {
                                                             $attendee_data[$critical_attendee_detail] = $primary_attendee_obj->get($critical_attendee_detail);
                                                         }
                                                     }
                                                 }
                                                 // set author to event creator
                                                 $attendee_data['ATT_author'] = $registration->event()->wp_user();
                                                 // create new attendee object
                                                 $new_attendee = EE_Attendee::new_instance($attendee_data);
                                                 $new_attendee->save();
                                                 //												echo '<h1>$new_attendee  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h1>';
                                                 // add relation to new attendee
                                                 $registration->_add_relation_to($new_attendee, 'Attendee');
                                                 $registration->set_attendee_id($new_attendee->ID());
                                                 $registration->update_cache_after_object_save('Attendee', $new_attendee);
                                             }
                                             // who's the man ?
                                             if ($att_nmbr == 1) {
                                                 $primary_attendee_obj = $registration->get_first_related('Attendee');
                                                 //												printr( $primary_attendee_obj, '$primary_attendee_obj  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                             }
                                         }
                                     } else {
                                         EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                                         $success = FALSE;
                                         // remove malformed data
                                         unset($valid_data[$line_item_id]);
                                     }
                                     if (!$registration->attendee() instanceof EE_Attendee) {
                                         EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $line_item_id), __FILE__, __FUNCTION__, __LINE__);
                                         $success = FALSE;
                                     }
                                     //									printr( $registration->attendee(), '$registration->attendee()  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                                 }
                                 // end of if ( ! $this->_revisit || $this->_primary_revisit || ( $this->_revisit && $this->_reg_url_link == $registration->reg_url_link() )) {
                             } else {
                                 EE_Error::add_error(apply_filters('FHEE__Single_Page_Checkout___process_attendee_information__sold_out_events_msg', __('It appears that the event you are attempting to register for has just sold out. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
                                 $success = FALSE;
                             }
                             // end of if ( $registration instanceof EE_Registration )
                         } else {
                             EE_Error::add_error(__('An invalid Registration object was discovered when attempting to process your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                             $success = FALSE;
                         }
                         //							printr( $registration, '$registration  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                     }
                     // end of foreach ( $this->_transaction->registrations()  as $registration )
                     if (!$this->_reg_url_link) {
                         EE_Registry::instance()->SSN->set_session_data(array('transaction' => $this->_transaction));
                     }
                 } else {
                     EE_Error::add_error(__('Your form data could not be applied to any valid registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                     $success = FALSE;
                 }
             } else {
                 EE_Error::add_error(__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
                 $success = FALSE;
             }
         }
     } else {
         EE_Error::add_error(__('No valid question responses were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
         $success = FALSE;
     }
     // grab any errors
     if ($success) {
         EE_Error::add_success(__('Attendee information submitted successfully.', 'event_espresso'));
     }
     //this might be called while in admin and if it is then we don't want to do our normal steps.
     if (is_admin() && !EE_Registry::instance()->REQ->front_ajax) {
         return $success;
     }
     //do action in case a plugin wants to do something with the data submitted in step 1.
     //passes EE_Single_Page_Checkout, and it's posted data
     do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
     //		printr( $registration->answers(), '$registration->answers()  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     //		die();
     $this->go_to_next_step(__FUNCTION__);
     return TRUE;
 }
 public function test_delete_permanently_with_extra_meta()
 {
     $attendee = EE_Attendee::new_instance(array('ATT_fname' => 'bob', 'ATT_lname' => 'deleteme', 'ATT_email' => '*****@*****.**'));
     $attendee->save();
     $attendee->add_extra_meta('shouldnt_prevent_deletion', 'no_sirry');
     $this->assertEquals('no_sirry', $attendee->get_extra_meta('shouldnt_prevent_deletion', TRUE));
     $attendee->delete_permanently();
     //if that didn't throw an error, we're good
 }
 function test_register_mock_addon_success()
 {
     $this->assertFalse($this->_class_has_been_extended());
     $this->assertFalse($this->_model_has_been_extended());
     $this->_pretend_addon_hook_time();
     EE_Register_Model_Extensions::register($this->_model_group, $this->_reg_args);
     $att_model = EE_Registry::instance()->reset_model('Attendee');
     //verify they still haven't been extended
     $this->assertTrue($this->_class_has_been_extended(TRUE));
     $this->assertTrue($this->_model_has_been_extended(TRUE));
     //and that we can still use EEM_Attendee
     $a = EE_Attendee::new_instance();
     EEM_Attendee::instance()->get_all();
     EE_Registry::instance()->load_model('Attendee')->get_all();
     //now deregister it
     EE_Register_Model_Extensions::deregister($this->_model_group);
     $this->assertFalse($this->_class_has_been_extended());
     $this->assertFalse($this->_model_has_been_extended());
     EE_Registry::instance()->reset_model('Attendee');
     //and EEM_Attendee still works right? both ways of instantiating it?
     $a2 = EE_Attendee::new_instance();
     EEM_Attendee::instance()->get_all();
     EE_Registry::instance()->load_model('Attendee')->get_all();
 }