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_get_number_of_tickets_sold() { $e = EE_Event::new_instance(); $e->save(); $d_now = EE_Datetime::new_instance(array('EVT_ID' => $e->ID(), 'DTT_EVT_start' => time() - 100, 'DTT_EVT_end' => time() - 50, 'DTT_sold' => 5)); $d_now->save(); $d_exp = EE_Datetime::new_instance(array('EVT_ID' => $e->ID(), 'DTT_EVT_start' => time() - 10, 'DTT_EVT_end' => time() - 5, 'DTT_sold' => 15)); $d_exp->save(); $this->assertEquals(20, $e->get_number_of_tickets_sold()); $e->_remove_relation_to($d_now, 'Datetime'); $this->assertEquals(15, $e->get_number_of_tickets_sold()); }
function test_finalize() { $t = EE_Transaction::new_instance(array('STS_ID' => EEM_Transaction::complete_status_code)); $t->save(); $e = EE_Event::new_instance(); $e->save(); $tkt = EE_Ticket::new_instance(); $tkt->save(); $d = EE_Datetime::new_instance(array('EVT_ID' => $e->ID())); $d->save(); $tkt->_add_relation_to($d, 'Datetime'); /** @type EE_Registration_Processor $registration_processor */ $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); $reg_url = $registration_processor->generate_reg_url_link(1, EE_Line_Item::new_instance(array('LIN_name' => $tkt->name(), 'LIN_desc' => $tkt->description(), 'LIN_unit_price' => $tkt->price(), 'LIN_quantity' => 1, 'LIN_is_taxable' => $tkt->taxable(), 'LIN_order' => 0, 'LIN_total' => $tkt->price(), 'LIN_type' => EEM_Line_Item::type_line_item, 'OBJ_ID' => $tkt->ID(), 'OBJ_type' => 'Ticket'))); $r = EE_REgistration::new_instance(array('EVT_ID' => $e->ID(), 'TXN_ID' => $t->ID(), 'TKT_ID' => $tkt->ID(), 'STS_ID' => EEM_Registration::status_id_pending_payment, 'REG_url_link' => $reg_url)); $r->set_reg_code($registration_processor->generate_reg_code($r)); $registration_processor->update_registration_after_checkout_or_payment($r); $this->assertNotNull($r->reg_code()); $this->assertEquals(EEM_Registration::status_id_approved, $r->status_ID()); }
public function test_insert_and_update_and_delete() { $term1 = EE_Term::new_instance(array('name' => 'monkey1', 'slug' => 'monkey1')); $term2 = EE_Term::new_instance(array('name' => 'monkey2', 'slug' => 'monkey2')); $term1->save(); $term2->save(); $tt_1 = EE_Term_Taxonomy::new_instance(array('taxonomy' => 'whatever', 'term_id' => $term1->ID())); $tt_1->save(); $tt_2 = EE_Term_Taxonomy::new_instance(array('taxonomy' => 'whatever', 'term_id' => $term2->ID())); $tt_2->save(); $e = EE_Event::new_instance(array('EVT_name' => 'for_term_1')); $e->save(); //ok done setup //test INSERT $this->assertEquals(0, $tt_1->count()); $new_tr_id = EEM_Term_Relationship::instance()->insert(array('term_taxonomy_id' => $tt_1->ID(), 'object_id' => $e->ID())); $this->assertNotNull($new_tr_id); //refresh out term_taxonomy objects, as the database has changed $tt_1 = EEM_Term_Taxonomy::reset()->get_one_by_ID($tt_1->ID()); $tt_2 = EEM_Term_Taxonomy::instance()->get_one_by_ID($tt_2->ID()); $this->assertEquals(1, $tt_1->count()); $this->assertEquals(0, $tt_2->count()); //test UPDATE... except we can't update term_relationship because there's no Primary Key //on it. This should be fixed at some point //@todo: fix this test // $updated = EEM_Term_Relationship::instance()->update_by_ID(array('term_taxonomy_id'=>$tt_2->ID() ), $new_tr_id ); // //refresh out term_taxonomy objects, as the database has changed // $tt_1 = EEM_Term_Taxonomy::reset()->get_one_by_ID( $tt_1->ID() ); // $tt_2 = EEM_Term_Taxonomy::instance()->get_one_by_ID($tt_2->ID() ); // $this->assertEquals( 0, $tt_1->count() ); // $this->assertEquals(1,$tt_2->count() ); //test DELETE //@todo: fix this test too. see above // $count_deleted = EEM_Term_Relationship::instance()->delete_by_ID($new_tr_id); // $this->assertNotEmpty( $count_deleted ); // //refresh out term_taxonomy objects, as the database has changed // $tt_1 = EEM_Term_Taxonomy::reset()->get_one_by_ID( $tt_1->ID() ); // $tt_2 = EEM_Term_Taxonomy::instance()->get_one_by_ID($tt_2->ID() ); // $this->assertEquals( 0, $tt_1->count() ); // $this->assertEquals(0,$tt_2->count() ); }
public function test_delete() { $e1 = EE_Event::new_instance(); $e1->save(); $e2 = EE_Event::new_instance(); $e2->save(); $e3 = EE_Event::new_instance(); $e3->save(); //now assert things are as they should be: the items are in teh Db and the entity map $this->assertEquals(EEM_Event::instance()->get_one_by_ID($e1->ID()), $e1); $this->assertEquals(EEM_Event::instance()->get_one_by_ID($e2->ID()), $e2); $this->assertEquals(EEM_Event::instance()->get_one_by_ID($e3->ID()), $e3); $this->assertEquals(EEM_Event::instance()->get_from_entity_map($e1->ID()), $e1); $this->assertEquals(EEM_Event::instance()->get_from_entity_map($e2->ID()), $e2); $this->assertEquals(EEM_Event::instance()->get_from_entity_map($e3->ID()), $e3); //now run a delete query that should have deleted $e1 and $e2 EEM_Event::instance()->delete_permanently(array(array('EVT_ID' => array('<=', $e2->ID())))); //check $e1 and $e2 don't exist in the DB anymore $this->assertEmpty(EEM_Event::instance()->get_one_by_ID($e1->ID())); $this->assertEmpty(EEM_Event::instance()->get_one_by_ID($e2->ID())); $this->assertEquals(EEM_Event::instance()->get_one_by_ID($e3->ID()), $e3); //and now chekc $e1 and $e2 don't exist in the entity map either $this->assertEmpty(EEM_Event::instance()->get_from_entity_map($e1->ID())); $this->assertEmpty(EEM_Event::instance()->get_from_entity_map($e2->ID())); $this->assertEquals(EEM_Event::instance()->get_from_entity_map($e3->ID()), $e3); }
/** * used by factory to create event object * * @since 4.3.0 * * @param array $args Incoming field values to set on the new object * * @return EE_Event|false */ public function create_object($args) { $event = EE_Event::new_instance($args); $evtID = $event->save(); return $evtID ? $event : false; }
function test_parent() { $e = EE_Event::new_instance(array('parent' => 12)); $this->assertEquals($e->parent(), 12); }
function test_set_and_get_extra_meta() { $e = EE_Event::new_instance(); $e->save(); $e->update_extra_meta('monkey', 'baboon'); $this->assertEquals('baboon', $e->get_extra_meta('monkey', TRUE)); $e->update_extra_meta('monkey', 'chimp'); $this->assertEquals('chimp', $e->get_extra_meta('monkey', TRUE)); }