public function indexReturnsAllFollowers(FunctionalTester $I) { $user = User::findFirst(); $I->sendGet($this->endpoint . '/' . $user->id); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->assertEquals(count($user->getFollowers()), count(json_decode($I->grabResponse())->items)); $I->seeResponseContainsJson($user->getFollowers()->toArray()); }
public function deleteSuccessful(FunctionalTester $I) { $user = User::findFirst(); // We send get $I->sendDELETE($this->endpoint . '/' . $user->id); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->dontSeeRecord('App\\Models\\User', $user); }
public function updateReponseWithErrors(FunctionalTester $I) { $id = 1; $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendPUT('/api/v1/users/' . $id, 'email=' . User::findFirst(2)->email); $I->seeResponseCodeIs(409); $I->seeResponseIsJson(); $I->seeResponseContains('messages'); $I->seeResponseContains('email'); $I->assertGreaterThan(0, count(json_decode($I->grabResponse())->messages)); }
public function updateUnsuccessfulReturnErrors(FunctionalTester $I) { $id = 1; $original_name = User::findFirst($id)->name; $updated_param = ['name' => '']; $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendPUT($this->endpoint . '/' . $id, 'name=' . $updated_param['name']); $I->seeResponseCodeIs(409); $I->seeResponseIsJson(); $json_response = json_decode($I->grabResponse()); $I->assertGreaterThan(0, count($json_response->messages)); $I->assertEquals($original_name, User::findFirst($id)->name); }
public function initialize() { // Авторизация if ($this->session->has('login') || $this->cookies->has('login')) { if (!$this->session->has('user-name')) { $login = $this->session->has('login') ? $this->session->get('login') : $this->cookies->get('login'); $user = User::findFirst(["name = '" . $login . "'"]); $this->session->set('user-name', $user->name); $this->session->set('user-id', $user->id); } } elseif ($this->router->getControllerName() != 'auth') { return $this->response->redirect('auth/login'); } if ($this->request->isAjax()) { $this->view->disable(); $this->_isJsonResponse = true; $this->response->setContentType('application/json', 'UTF-8'); } }
public function loginAction() { if ($this->request->isPost()) { if ($this->security->checkToken()) { $login = $this->request->getPost('login'); $password = $this->request->getPost('password'); $remembe = $this->request->getPost('remembe'); $user = User::findFirst(["name = '" . $login . "'"]); if (!empty($user) && $this->security->checkHash($password, $user->pass)) { $this->session->set('login', $user->name); if ($remembe == 'on') { $this->cookies->set('login', $user->name, time() + 15 * 86400); } return $this->response->redirect('index'); } else { } } } }
public function _before(FunctionalTester $I) { $this->relationship = ['user_id' => User::findFirst()->id, 'follower_id' => User::findFirst(["email = '" . UserSeeder::DbSeeds()[1]['email'] . "'"])->id]; $I->haveRecord('App\\Models\\Relationships\\Follower', $this->relationship); }
public function rrppIdMustBeUnique(FunctionalTester $I) { $this->model->rrpp_id = User::findFirst('rrpp_id IS NOT NULL')->rrpp_id; $I->assertFalse($this->model->save()); }