コード例 #1
0
 public function testTheAppView()
 {
     $this->artisan('db:seed');
     $this->be(User::first());
     $this->visit('/')->see('MyGains');
     $this->assertViewHas(["exercises", "workouts"]);
 }
コード例 #2
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('App\\Settings', function () {
         return User::first()->settings();
         //            return \Auth::user()->settings();
     });
 }
コード例 #3
0
ファイル: UserTest.php プロジェクト: mattvb91/website-laravel
 public function testFactory()
 {
     factory(User::class, 50)->create();
     $user = User::first();
     $this->assertInstanceOf(User::class, $user);
     $this->assertTrue($user->exists());
 }
コード例 #4
0
 public function test($id)
 {
     $user = \App\Models\User::findHashed('47ee991c-8500-42e7-b6ba-50f6c1edb729');
     $user->load('roles');
     return $user;
     return route('test', \App\Models\User::first());
     return $id;
 }
コード例 #5
0
 public function testDisplayCreateForm()
 {
     echo "\n\nINSTRUMENT CONTROLLER TEST\n\n";
     $url = URL::route('instrument.create');
     // Set the current user to admin
     $this->be(User::first());
     $this->visit($url)->see('name');
 }
コード例 #6
0
ファイル: LotControllerTest.php プロジェクト: echiteri/iBLIS
 /**
  * Testing Lot destroy funciton
  */
 public function testDelete()
 {
     $this->be(User::first());
     $this->runStore($this->input);
     $lot = new LotController();
     $lot->delete(1);
     $lotDeleted = Lot::withTrashed()->find(1);
     $this->assertNotNull($lotDeleted->deleted_at);
 }
コード例 #7
0
 /**
  * Tests the update function in the SupplierController
  * @depends testStore
  * @param void
  * @return void
  */
 public function testDelete()
 {
     $this->be(User::first());
     $this->runStore($this->input);
     $supplier = new SupplierController();
     $supplier->delete(1);
     $supplierDeleted = Supplier::withTrashed()->find(1);
     $this->assertNotNull($supplierDeleted->deleted_at);
 }
コード例 #8
0
 private function seedAcl()
 {
     Bouncer::seeder(function () {
         Bouncer::allow('admin')->to(['system.view', 'users.view', 'system.manage', 'users.manage']);
         Bouncer::allow('manager')->to(['system.view', 'system.manage']);
         Bouncer::allow('user')->to(['system.view']);
         Bouncer::assign('admin')->to(User::first());
         Bouncer::assign('manager')->to(User::where(['login' => 'manager'])->first());
     });
 }
コード例 #9
0
 /**
  * Tests the update function in the PatientController
  * @depends testStore
  * @param void
  * @return void
  */
 public function testDelete()
 {
     $this->be(User::first());
     $this->runStore($this->input);
     $patientSaved = Patient::orderBy('id', 'desc')->first();
     $patient = new PatientController();
     $patient->delete($patientSaved->id);
     $patientsDeleted = Patient::withTrashed()->find($patientSaved->id);
     $this->assertNotNull($patientsDeleted->deleted_at);
 }
コード例 #10
0
 /**
  * Tests the store function in the ChargeController
  * @param  void
  * @return int $testChargeId ID of Charge stored;used in testUpdate() to identify test for update
  */
 public function testStore()
 {
     echo "\n\nCHARGE CONTROLLER TEST\n\n";
     // Store the Charge
     $this->withoutMiddleware();
     $this->be(User::first());
     $this->call('POST', '/charge', $this->chargeData);
     $chargeStored = Charge::orderBy('id', 'desc')->first();
     $this->assertEquals($this->chargeData['test_id'], $chargeStored->test_id);
     $this->assertEquals($this->chargeData['current_amount'], $chargeStored->current_amount);
 }
コード例 #11
0
 public function test_passwords_delete()
 {
     $this->test_access_after_setup();
     $user = User::first();
     $folder = PasswordFolder::where('user_id', $user->id)->first();
     $password = factory(Password::class)->create(['folder_id' => $folder->id]);
     $this->actingAs($password->folder->user);
     $token = ['_token' => \Session::token()];
     $this->delete(route('passwords.destroy', [$password->id]), $token);
     $this->assertRedirectedToRoute('passwords.index');
 }
コード例 #12
0
 /**
  * Tests the store function in the PaymentController
  * @param  void
  * @return int $testPaymentId ID of Payment stored;used in testUpdate() to identify test for update
  */
 public function testStore()
 {
     echo "\n\nPAYMENT CONTROLLER TEST\n\n";
     // Store the Payment
     $this->withoutMiddleware();
     $this->be(User::first());
     $this->call('POST', '/payment', $this->paymentData);
     $paymentStored = Payment::orderBy('id', 'desc')->first();
     $this->assertEquals($this->paymentData['patient_id'], $paymentStored->patient_id);
     $this->assertEquals($this->paymentData['charge_id'], $paymentStored->charge_id);
     $this->assertEquals($this->paymentData['full_amount'], $paymentStored->full_amount);
     $this->assertEquals($this->paymentData['amount_paid'], $paymentStored->amount_paid);
 }
コード例 #13
0
ファイル: DrugControllerTest.php プロジェクト: echiteri/iBLIS
 /**
  * Tests the store function in the DrugController
  * @param  void
  * @return int $testDrugId ID of Drug stored;used in testUpdate() to identify test for update
  */
 public function testStore()
 {
     echo "\n\nDRUG CONTROLLER TEST\n\n";
     // Store the Drug
     $this->withoutMiddleware();
     $this->be(User::first());
     $response = $this->call('POST', '/drug', $this->drugData);
     // dd($response);
     $drugStored = Drug::orderBy('id', 'desc')->take(1)->get()->first();
     // dd($drugStored);
     // $drugSaved = Drug::find($drugStored->id);
     $this->assertEquals($this->drugData['name'], $drugStored->name);
     $this->assertEquals($this->drugData['description'], $drugStored->description);
 }
コード例 #14
0
 public function form($form)
 {
     $class = 'app\\forms\\' . $form;
     $form = new $class($this, array('user' => models\User::first('1 ORDER BY RAND()'), 'domain' => models\Domain::first('1 ORDER BY RAND()')));
     $content = '';
     if ($this->POST) {
         $content .= '<pre>VALIDATION: ' . ($form->validate($_POST) ? 'OK' : 'FAIL') . '</pre>';
         $content .= '<pre>' . print_r($form->errors(), 1) . '</pre>';
     }
     $content .= $form->render();
     $content .= '<pre>$_POST: ' . print_r($_POST, 1) . '</pre>';
     $content .= '<pre>&output: ' . print_r($form->output, 1) . '</pre>';
     $content .= '<pre>$form: ' . print_r($form, 1) . '</pre>';
     return $this->tpl->display(false, array('content' => $content));
 }
コード例 #15
0
ファイル: ProfileViewTest.php プロジェクト: khoparzi/PairUp
 /**
  * Checks that the message box sends an email
  *
  * (I believe Laravel has a feature for this, so an email is not actually sent)
  */
 public function testProfileSendEmail()
 {
     $faker = Faker\Factory::create();
     factory(App\Models\Profile::class, 'withAUser', 1)->create();
     $user = App\Models\User::first();
     $message = $faker->sentences(3);
     $this->visit(route('profile.view', ['name' => $user->username]))->type($message, 'message')->submitForm('Send');
     $mock = \Mockery::mock($this->app['mailer']->getSwiftMailer());
     $this->app['mailer']->setSwiftMailer($mock);
     $mock->shouldReceive('send')->withArgs([\Mockery::on(function ($message) {
         $this->assertEquals(trans('profile.message_subject', ['from' => Auth::user()->username]), $message->getSubject());
         $this->assertSame([$user->profile->email => null], $message->getTo());
         $this->assertContains(trans('profile.message_body'), $message->getBody());
         return true;
     }), \Mockery::any()])->once();
 }
コード例 #16
0
ファイル: BackupDB.php プロジェクト: mattvb91/website-laravel
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //Zip the database.
     $path = storage_path() . '/database.sqlite';
     $zip = new \ZipArchive();
     $zipPath = storage_path() . '/backup.zip';
     $zip->open($zipPath, \ZipArchive::CREATE);
     $zip->addFile($path);
     $zip->close();
     //Send email.
     $user = User::first();
     if (Mail::send(['email' => 'db'], [], function ($mail) use($user, $zipPath) {
         $mail->from(env('MAIL_ADDRESS'), 'Mavon.ie System');
         $mail->to($user->getEmail())->subject('Mavon.ie DB Backup ' . Carbon::now());
         $mail->attach($zipPath);
     })) {
         echo "Backup sent!" . PHP_EOL;
     }
     //Delete zip when finished.
     unlink($zipPath);
 }
コード例 #17
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videos = glob(public_path() . '/b/*');
     usort($videos, function ($a, $b) {
         $a = (int) basename($a, '.webm');
         $b = (int) basename($b, '.webm');
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $category = \App\Models\Category::where('shortname', '=', 'misc')->first();
     $user = \App\Models\User::first();
     foreach ($videos as $video) {
         $v = new \App\Models\Video();
         $v->user()->associate($user);
         $v->category()->associate($category);
         $v->hash = sha1_file($video);
         $v->file = basename($video);
         $v->save();
     }
 }
コード例 #18
0
 public function testStoreFailValidation()
 {
     // Set the current user to admin
     $this->be(User::first());
     $this->withoutMiddleware();
     //Check if it prevents blank name entries
     $facilityNameEmpty = '';
     $this->call('POST', '/facility', ['name' => $facilityNameEmpty]);
     $this->assertRedirectedToRoute('facility.index');
     // todo: Session can not be used with without middleware need to rethink this, yet we need to avoid the auth middleware(not yet implemented BTW) and the Illuminate\Session\TokenMismatchException while testing, or maybe instead of auth middleware we can use authorise in the form request. or have a trait for all of them lets see
     // $this->assertSessionHasErrors('name');
     // todo: the above just won't do, below is the best I can do for now
     $this->assertSessionHasErrors();
     $this->withoutMiddleware();
     //Check if it prevents duplicate name entries
     $facilityNameDuplicate = Facility::find(1)->name;
     $this->call('POST', '/facility', ['name' => $facilityNameDuplicate]);
     $this->assertRedirectedToRoute('facility.index');
     // $this->assertSessionHasErrors('name');
     // todo: the above just won't do, below is the best I can do for now
     $this->assertSessionHasErrors();
 }
コード例 #19
0
ファイル: Auth.php プロジェクト: SharkIng/ss-panel
 /**
  * @return User|void
  */
 public static function getUser()
 {
     if (Helper::isTesting()) {
         $user = User::first();
         $user->isLogin = true;
         return $user;
     }
     $sid = Cookie::get('sid');
     $value = self::getCache()->get($sid);
     if ($value == null || !$value) {
         $user = new User();
         $user->isLogin = false;
         return $user;
     }
     $uid = $value;
     $user = User::find($uid);
     if ($user == null) {
         $user = new User();
         $user->isLogin = false;
         return $user;
     }
     $user->isLogin = true;
     return $user;
 }
コード例 #20
0
ファイル: AuthTest.php プロジェクト: SharkIng/ss-panel
 protected function getExistEmail()
 {
     return User::first()->email;
 }
コード例 #21
0
ファイル: UsersController.php プロジェクト: EHER/monopolis
 public function view()
 {
     $user = User::first($this->request->id);
     return compact('user');
 }
コード例 #22
0
ファイル: HomeController.php プロジェクト: kimmykuang/MFFBC
 public function user()
 {
     View::render(View::make('home.user')->withTitle('User Page')->with('userinfo', \App\Models\User::first()));
 }
コード例 #23
0
ファイル: AuthTest.php プロジェクト: TFidryForks/spira
 public function testRefreshPlainHeader()
 {
     $user = User::first();
     $jwtAuth = $this->app->make('Tymon\\JWTAuth\\JWTAuth');
     $token = $jwtAuth->fromUser($user, ['method' => 'password']);
     $options = ['headers' => ['authorization' => 'Bearer ' . $token]];
     $client = new Client(['base_url' => sprintf('http://%s:%s', getenv('WEBSERVER_HOST'), getenv('WEBSERVER_PORT'))]);
     $res = $client->get('/auth/jwt/refresh', $options);
     $array = $res->json();
     $this->assertEquals(200, $res->getStatusCode());
     $this->assertNotEquals($token, $array['token']);
     $this->assertEquals('password', $array['decodedTokenBody']['method']);
 }