protected function setUp() { parent::setUp(); Db::insert('users')->setArray(['id' => 1, 'login' => 'Donatello', 'email' => '*****@*****.**', 'status' => 'pending'])->execute(); Db::insert('users')->setArray(['id' => 2, 'login' => 'Bill', 'email' => '*****@*****.**', 'status' => 'active'])->execute(); Auth::setIdentity(new \Application\Users\Row()); }
/** * Setup `test` table before the first test */ public static function setUpBeforeClass() { Db::insert('test')->setArray(['id' => 1, 'name' => 'Donatello', 'email' => '*****@*****.**'])->execute(); Db::insert('test')->setArray(['id' => 2, 'name' => 'Leonardo', 'email' => '*****@*****.**'])->execute(); Db::insert('test')->setArray(['id' => 3, 'name' => 'Michelangelo', 'email' => '*****@*****.**'])->execute(); Db::insert('test')->setArray(['id' => 4, 'name' => 'Raphael', 'email' => '*****@*****.**'])->execute(); }
protected function setUp() { parent::setUp(); $this->hybridAuthMock = $this->getMockBuilder('\\Hybrid_Auth')->setMethods(['authenticate'])->disableOriginalConstructor()->getMock(); $this->authAdapterMock = $this->getMockBuilder('\\Hybrid_Provider_Adapter')->setMethods(['getUserProfile'])->disableOriginalConstructor()->getMock(); Db::insert('users')->setArray(['id' => 2, 'login' => 'Bill', 'email' => '*****@*****.**', 'status' => 'active'])->execute(); Db::insert('auth')->setArray(['provider' => 'facebook', 'userId' => 2, 'foreignKey' => 112233])->execute(); Auth::setIdentity(new \Application\Users\Row()); }
* @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()); };
/** * create dish */ private function createTestDish() { return Db::insert('dishes')->setArray($this->validData)->execute(); }
/** * Can not update row because of validation problem */ public function testUpdateValidationError() { Db::insert('musician')->setArray(['id' => 3, 'nickname' => 'testupdate', 'group' => 'test2', 'concertDate' => '2015-11-10', 'alias' => 'test3', 'image' => '56kj898f3f39.jpg'])->execute(); Db::insert('musician')->setArray(['id' => 9, 'nickname' => 'testUpdate', 'group' => 'test9', 'concertDate' => '2015-11-10', 'alias' => 'test9', 'image' => '5sdgf3f39.jpg'])->execute(); $this->dispatchRouter('/musician/crud/', ['id' => 3, 'alias' => 'test9'], Http\Request::METHOD_PUT); $row = Table::getInstance()->getByAlias('test9'); // $count = Db::fetchOne('SELECT count(*) FROM musician WHERE alias = ?', ['test9']); $this->assertEquals($row ? 1 : 0, 1); }