/** * [saveModel] * @param boolean $reminder [description] * @return [type] [description] */ protected function saveModel($reminder = false) { if (Input::get('id')) { $reminder = Reminder::find(Input::get('id')); } if (!$reminder) { $reminder = new Reminder(); } //$load_company_model = $project->company; $reminder->project_id = Input::get('project_id'); $reminder->user_id = Input::get('user_id'); $reminder->description = Input::get('description'); $reminder->save(); return $reminder; }
public function testAddTable() { $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); $m = new WeNeedReminders1(); $m->up(); $result = Reminder::create(array('content' => 'hello world', 'remind_at' => '2005-01-01 11:10:01')); $this->assertInstanceOf('Reminder', $result); $this->assertEquals('hello world', Reminder::find('first')->content); $m->down(); $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); }
public function testMigratorGoingDownDueToVersionTarget() { $dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/fixtures/migrations/'; Mad_Model_Migration_Migrator::up($dir, 1); Mad_Model_Migration_Migrator::down($dir, 0); $user = new User(); $columns = $user->columnNames(); $this->assertFalse(in_array('last_name', $columns)); $e = null; try { $this->_conn->selectValues("SELECT * FROM reminders"); } catch (Exception $e) { } $this->assertInstanceOf('Horde_Db_Exception', $e); Mad_Model_Migration_Migrator::up($dir); $user->resetColumnInformation(); $columns = $user->columnNames(); $this->assertTrue(in_array('last_name', $columns)); $result = Reminder::create(array('content' => 'hello world', 'remind_at' => '2005-01-01 02:22:23')); $reminder = Reminder::find('first'); $this->assertEquals('hello world', $reminder->content); }