$result = $wpdb->query($query); if (false === $result) { return false; } if (!($journal_entry->id > 0)) { $journal_entry->id = $wpdb->insert_id; } return true; } protected function mk_entry($row) { if (is_null($row)) { return null; } $row = (array) $row; // Replace timestamps with DateTime objects foreach (array('created_at', 'updated_at') as $col) { $row[$col] = SimpleDateTime::fromGmtTimestamp($row[$col]); } return new CSM_JournalEntry($row); } protected function mk_row($entry) { return array('id' => $entry->id, 'shift_slug' => $entry->shift_slug, 'shift_duration' => $entry->shift_duration->seconds(), 'volunteer_slug' => $entry->volunteer_slug, 'volunteers_count' => $entry->volunteers_count, 'is_frozen' => $entry->is_frozen, 'created_at' => $entry->created_at->gmtTimestamp(), 'updated_at' => $entry->updated_at->gmtTimestamp()); } } CSM_Singleton::register(new CSM_Journal()); add_action('csm_migrate_db', function () { $journal = CSM_Singleton::get('CSM_Journal'); $journal->migrate(); });
function test_register_triggers_error_if_class_name_not_registered() { $this->expectError(); $this->assertNull(CSM_Singleton::get('NotRegistered')); }
function setUp() { parent::setUp(); $this->journal = CSM_Singleton::get('CSM_Journal'); }