/** * Drop `test` table after the last test */ public static function tearDownAfterClass() { Db::delete('test')->where('id IN (?)', [1, 2, 3, 4])->execute(); Db::delete('test')->where('email = ?', '*****@*****.**')->execute(); self::resetGlobals(); self::resetApp(); }
/** * generate action with token * * @param int $userId * @param string $action * @param int $expired in days * @param array $params * @return Row */ public function generate($userId, $action, $expired = 5, $params = []) { // remove previously generated tokens Db::delete($this->table)->where('userId = ?', $userId)->andWhere('action = ?', $action)->execute(); // create new row $actionRow = new Row(); $actionRow->userId = $userId; $actionRow->action = $action; $random = range('a', 'z', rand(1, 5)); shuffle($random); $actionRow->code = md5($userId . $action . join('', $random) . time()); $actionRow->expired = date('Y-m-d H:i:s', strtotime("+{$expired} day")); $actionRow->params = $params; $actionRow->save(); return $actionRow; }
/** * tearDown */ public function tearDown() { parent::tearDown(); Proxy\Db::delete('test')->where('email = ?', '*****@*****.**')->execute(); }
protected function tearDown() { Db::delete('users')->where('id IN (?)', [1, 2])->execute(); Messages::popAll(); }
<?php /** * Delete image from redactor * * @author Anton Shevchuk * @created 19.06.13 18:18 */ /** * @namespace */ namespace Application; use Bluz\Proxy\Db; return function ($path) { $this->useJson(); /** * @var Users\Row $user */ if (!$this->user()) { throw new Exception('User not found'); } $userId = $this->user()->id; $result = Db::delete('media')->where('type LIKE (?)', 'image/%')->andWhere('file = ?', $path)->andWhere('userId = ?', $userId)->execute(); return $result; };
/** * Drop photo after the test */ public static function tearDownAfterClass() { Db::delete('media')->where('userId', [1])->execute(); $path = Config::getModuleData('media', 'upload_path') . '/1'; Tools\Cleaner::delete($path); }
* @accept HTML * @accept JSON * @privilege Management * * @param int $id * @return bool * @throws Exception */ return function ($id) { /** * @var Controller $this */ $user = Users\Table::findRow($id); if (!$user) { throw new Exception('User ID is incorrect'); } if (Request::isPost()) { $roles = Request::getParam('roles'); // update roles Db::delete('acl_users_roles')->where('userId = ?', $user->id)->execute(); foreach ($roles as $role) { Db::insert('acl_users_roles')->set('userId', $user->id)->set('roleId', $role)->execute(); } // clean cache Cache::delete('user:'******'User roles was updated'); return false; } $this->assign('user', $user); $this->assign('roles', Roles\Table::getInstance()->getRoles()); };
/** * delete dish */ private function deleteTestDish() { Db::delete('dishes')->where('title=?', $this->validData['title'])->execute(); }
/** * Drop `test` table after the last test */ public static function tearDownAfterClass() { Db::delete('musician')->execute(); }