public function testCreate() { $user = User::_create(array('name' => 'test')); $this->assertTrue(User::$callback_tests['before_create']); $this->assertTrue(User::$callback_tests['after_create']); $this->assertTrue(User::$callback_tests['before_validation']); $this->assertTrue(User::$callback_tests['after_validation']); }
public static function create_pearfarm_user() { foreach (array('pearfarm', 'dev', 'www', 'blog') as $user) { $u = User::_create(array('username' => $user, 'password' => 'mmm_pears', 'email' => '*****@*****.**')); } $u->active = true; $u->save(); }
public static function create_users() { $u = User::_create(array('username' => 'bob', 'password' => 'password', 'email' => '*****@*****.**')); $u->active = true; $u->save(); User::_create(array('username' => 'joe', 'password' => 'password', 'email' => '*****@*****.**')); User::_create(array('username' => 'jim', 'password' => 'password', 'email' => '*****@*****.**')); $u = User::_create(array('username' => 'steve', 'password' => 'password', 'email' => '*****@*****.**')); $u->active = true; $u->save(); }
function load_test_data() { $users = array('Tim', 'Steve', 'Joe', 'Bob', 'John', 'Scott', 'Randy', 'Jessica', 'Julie'); Photo::truncate(); User::truncate(); foreach ($users as $user) { $_user = User::_create(array('name' => $user, 'my_int' => '')); foreach (range(0, 100) as $i) { Photo::_create(array('user_id' => $_user->id, 'title' => 'photo_' . $i)); } } }
public function testUpdateFails() { $user = User::_create($this->user_data); $u = User::update($user->id, array('name' => NULL)); $this->assertFalse($u->test_before_create); $this->assertFalse($u->test_after_create); $this->assertFalse($u->test_before_save); $this->assertFalse($u->test_after_save); $this->assertTrue($u->test_before_validations); $this->assertTrue($u->test_after_validations); $this->assertFalse($u->test_before_update); $this->assertFalse($u->test_after_update); }
function testCreateNewUserWithPhotos() { $user = User::_create(array('name' => 'bob2')); $id = $user->id; $this->assertTrue(!empty($id) && is_numeric($id)); $this->assertTrue($user->saved); foreach (range(0, 100) as $i) { $photo = Photo::_create(array('user_id' => $id, 'title' => 'my photo ' . $i)); $id2 = $photo->id; $this->assertTrue(!empty($id2) && is_numeric($id2)); $this->assertTrue($photo->saved); } }
function create() { if (isset($_POST['save'])) { $user_password = trim($this->input->post('password')); $salt = "bU-View9*-ixFaNzatj"; $user_password .= $salt; $user_password = sha1($user_password); $data = array('fullname' => trim($this->input->post('fullname')), 'password' => $user_password, 'useremail' => trim($this->input->post('useremail')), 'state' => trim($this->input->post('state')), 'user_type_id' => trim($this->input->post('user_type_id')), 'created_date' => date('Y-m-d h:m:s'), 'changed_date' => date('Y-m-d h:m:s')); $dataIn = $this->crud_model->insertData('user', $data); if ($dataIn) { $this->admintemp->write('message', 'User Saved Successfully'); if ($this->input->post('user_type_id') == 3) { redirect('user/golfusers'); } else { redirect('user'); } } else { $this->admintemp->write('error', 'An error occured while inserting the section.'); User::index(); } } else { User::_create(); } }
function create_users() { foreach (range(1, 10) as $i) { User::_create(array('name' => 'names' . $i, 'my_int' => $i)); } }
public function testMassDeleteManyArgs() { $start = User::count(array('cache' => false)); $users = array(); foreach (range(0, 3) as $i) { $users[] = $u = User::_create(array('name' => 'test_name' . $i, 'my_int' => 12 + $i)); $this->assertTrue($u->saved); unset($u); } $this->assertEquals(User::count(array('cache' => false)), $start + 4); $ids = collect(function ($u) { return $u->id; }, $users); call_user_func_array(array('User', 'delete'), $ids); try { User::find($ids); } catch (NimbleRecordNotFound $e) { $this->assertTrue(is_a($e, 'NimbleRecordNotFound')); $this->assertEquals(User::count(array('cache' => false)), $start); } }