當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth::shouldReceive方法代碼示例

本文整理匯總了PHP中Auth::shouldReceive方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::shouldReceive方法的具體用法?PHP Auth::shouldReceive怎麽用?PHP Auth::shouldReceive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Auth的用法示例。


在下文中一共展示了Auth::shouldReceive方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_add_categoria

 /**
  * A basic test example.
  *
  * @return void
  */
 public function test_add_categoria()
 {
     $this->flushSession();
     $this->withoutMiddleware();
     $credenciales = array('name' => 'elver.galarga', 'password' => 'Elver.Galarga');
     Auth::shouldReceive('attempt')->once()->with($credenciales)->andReturn(true);
     $response = $this->call('POST', '/login', $credenciales);
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['fails' => 'true']));
     //$this->assertEquals(500, $response->getStatusCode());
     //$crawler = $this->followRedirects();
     //$this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response);
     $this->assertEquals($this->baseUrl . '/mi_contenido', $response->getTargetUrl());
     //$this->assertResponseStatus(302);
     //$this->assertTrue($response->isRedirection());
     //$this->assertRedirectedTo('/mi_contenido');
     //$crawler = $this->followRedirect();
     //$this->assertRedirectedTo('/mi_contenido');
     //App::instance('Illuminate\Auth\Manager', $this->getAuthMock(true));
     //$this->assertRedirectedToRoute('mi_contenido');
     //$this->assertRedirectedToAction('contenidosController@create');
     //Auth::shouldReceive('user')->andReturn($user = m::mock('StdClass'));
     /*$faker = Faker\Factory::create();
       $user = new User(['name' => 'elver.galarga']);
       $this->be($user);
       $this->visit('/mi_contenido')
            ->press('Agregar categoría nueva')
            ->type($faker->word, 'txtcategoria')
            ->type($faker->text, 'txtdescripcion')
            ->press('Guardar')
            ->seePageIs('http://app-isw.net/mi_contenido#');*/
 }
開發者ID:elotgamu,項目名稱:app-isw,代碼行數:36,代碼來源:agregar_nueva_categoria_Test.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     // Test question
     $questionDescription = 'Lorem ipsum dolor sit amet, consectetur
         adipisicing elit, sed do eiusmod tempor incididunt ut labore et
         dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
         exercitation ullamco laboris nisi ut aliquip ex ea commodo
         consequat. Duis aute irure dolor in reprehenderit in voluptate
         velit esse cillum dolore eu fugiat nulla pariatur.';
     $this->question = new Question();
     $this->question->forceFill(['id' => 1, 'title' => 'Fallen eyebrow driving gloves cardinal richelieu
                           gentleman trophy face broom swaggy leaf crash?', 'description' => $questionDescription, 'folder_id' => 1, 'user_id' => 1, 'user' => ['id' => 1], 'folder' => ['title' => 'Eyebrows']]);
     $this->answer = new Answer(['id' => 2, 'description' => $questionDescription]);
     $this->user = new User(['id' => 1]);
     $this->folder = new Folder();
     $this->folder->forceFill(['id' => 1]);
     $this->tag = new Tag();
     $this->vote = new Vote(['id' => 1, 'q_and_a_id' => 1, 'user_id' => 1]);
     $this->questionRepo = m::mock('App\\Repositories\\Repositories\\QuestionRepositoryEloquent');
     $this->answerRepo = m::mock('App\\Repositories\\Repositories\\AnswerRepositoryEloquent');
     $this->folderRepo = m::mock('App\\Repositories\\Repositories\\FolderRepositoryEloquent');
     $this->tagRepo = m::mock('App\\Repositories\\Repositories\\TagRepositoryEloquent');
     $this->voteRepo = m::mock('App\\Repositories\\Repositories\\VoteRepositoryEloquent');
     $this->commentRepo = m::mock('App\\Repositories\\Repositories\\CommentRepositoryEloquent');
     $this->questionService = new QuestionService($this->questionRepo, $this->answerRepo, $this->folderRepo, $this->tagRepo, $this->voteRepo, $this->commentRepo);
     $this->tagRepo->shouldReceive('pushCriteria')->andReturn($this->tagRepo);
     $this->tagRepo->shouldReceive('all')->andReturn([]);
     $this->tagRepo->shouldReceive('create')->andReturn($this->tag);
     $this->tagRepo->shouldReceive('createSeveral')->andReturn([$this->tag]);
     $this->questionRepo->shouldReceive('relationsAdd');
     $this->voteRepo->shouldReceive('findWhere')->andReturn($this->vote);
     $this->answerRepo->shouldReceive('withRelationCount')->andReturn($this->answerRepo);
     Auth::shouldReceive('user')->andReturn($this->user);
 }
開發者ID:a1ex7,項目名稱:asciit,代碼行數:35,代碼來源:QuestionServiceTest.php

示例3: testMessagesSendRequestOk

 /**
  * A basic functional test example.
  *
  * @return void
  */
 public function testMessagesSendRequestOk()
 {
     Auth::shouldReceive('user')->once()->andReturn((object) ['id' => 1]);
     $this->call('POST', '/v1/messages/send', ['recipient_id' => '1', 'payload' => 'daljsdsakj']);
     $this->assertCount(1, Message::all());
     $this->assertResponseOk();
 }
開發者ID:nilove,項目名稱:motibubackend,代碼行數:12,代碼來源:MessagesControllerTest.php

示例4: test_it_updates_an_existing_status

 public function test_it_updates_an_existing_status()
 {
     Auth::shouldReceive('id')->andReturn(2);
     $status = 'Lorem ipsum dolor site amet.';
     $result = $this->repository->storeOrUpdate($status, 1);
     $this->assertInstanceOf('Illuminate\\Database\\Eloquent\\Model', $result);
     $this->seeInDatabase('statuses', ['body' => $status]);
 }
開發者ID:jaytyrrell13,項目名稱:sample-app,代碼行數:8,代碼來源:EloquentStatusesRepositoryTest.php

示例5: testAuthLoged

 /**
  * Tests the variant when user is loged
  */
 public function testAuthLoged()
 {
     // set the user is loged
     \Auth::shouldReceive("check")->once()->andReturn(true);
     // setupt he authed user
     \Auth::shouldReceive("user")->once()->andReturn(new GenericUser(["id" => 1]));
     $this->assertEquals($this->mock->revisionUserId(), 1);
 }
開發者ID:pionl,項目名稱:revision,代碼行數:11,代碼來源:RevisionsTraitTest.php

示例6: test_Should_ThrowWException_When_RollbackProcedureFails

 /**
  * @expectedException InvalidArgumentException
  */
 public function test_Should_ThrowWException_When_RollbackProcedureFails()
 {
     $this->mockAuthGuard->shouldReceive('user')->andReturn(new App\Models\User());
     Auth::shouldReceive('guard')->andReturn($this->mockAuthGuard);
     $this->mockDeploymentForm->shouldReceive('save')->once()->andReturn(false);
     $this->mockDeploymentForm->shouldReceive('errors')->once()->andReturn(new Illuminate\Support\MessageBag());
     $jsonRpc = new JsonRpc($this->mockProjectRepository, $this->mockDeploymentForm);
     $jsonRpc->rollback(1);
 }
開發者ID:ngmy,項目名稱:webloyer,代碼行數:12,代碼來源:JsonRpcTest.php

示例7: testHandleLoginFailedAttempt

 public function testHandleLoginFailedAttempt()
 {
     Input::replace($input = array('email' => 'chris@theantichris.com', 'password' => 'test'));
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(array('fails' => false)));
     Auth::shouldReceive('attempt')->once()->andReturn(false);
     $this->call('POST', '/login', $input);
     $this->assertRedirectedTo('/login');
     $this->assertSessionHasErrors('invalid');
 }
開發者ID:theantichris,項目名稱:Retext,代碼行數:9,代碼來源:LoginControllerTest.php

示例8: testServiceGetLogged

 /**
  * Tests if the service get admin
  * method interacts correctly.
  */
 public function testServiceGetLogged()
 {
     $fakeUser = m::mock('App\\Models\\User');
     $fakeAdmin = m::mock('App\\Mdodels\\Administrator');
     \Auth::shouldReceive('user')->once()->andReturn($fakeUser);
     $this->fakeAdministratorsRepo->shouldReceive('getAdministrator')->withArgs([m::type('App\\Models\\User')])->once()->andReturn($fakeAdmin);
     $admin = $this->service->getLogged();
     $this->assertEquals($fakeAdmin, $admin);
 }
開發者ID:TiagoMaiaL,項目名稱:Tournament-Manager,代碼行數:13,代碼來源:AdministratorsServiceUnitTest.php

示例9: test_non_admin_cannot_remove_comment

 public function test_non_admin_cannot_remove_comment()
 {
     \Auth::shouldReceive('user')->once()->andReturn(DummyUser::where(['is_admin' => 0])->first());
     $comment = Comment::where(['body' => 'My Comment 1'])->first();
     $this->assertEquals($comment->body, 'My Comment 1');
     $result = \Mural::remove($comment->id);
     $comment = Comment::where(['body' => 'My Comment 1'])->first();
     $this->assertEquals($comment->body, 'My Comment 1');
     $this->assertEquals($result, false);
 }
開發者ID:laravolt,項目名稱:mural,代碼行數:10,代碼來源:MuralTest.php

示例10: it_creates_a_game_and_triggers_an_event_to_invite_the_selected_friend

 /** @test **/
 public function it_creates_a_game_and_triggers_an_event_to_invite_the_selected_friend()
 {
     $this->withoutMiddleware();
     $this->expectsEvents(GameCreated::class);
     $request = Mockery::mock(Request::class);
     $request->username = 'jaggy';
     $this->instance(Request::class, $request);
     $game = Mockery::mock(Game::class);
     Auth::shouldReceive('user->challenge')->once()->andReturn($game);
     $this->route('POST', 'games.store');
     $this->assertRedirectedToRoute('dashboard');
 }
開發者ID:salpakan,項目名稱:salpakan,代碼行數:13,代碼來源:GamesControllerTest.php

示例11: testStoreSuccess

 public function testStoreSuccess()
 {
     Input::replace(Factory::attributesFor($this->factory));
     Auth::shouldReceive('user')->andReturn((object) array('id' => 1));
     $this->mock->shouldReceive('create')->once()->andReturn($this->mock);
     $this->mock->shouldReceive('slug')->andReturn('foo');
     $this->mock->shouldReceive('highestSeriesOrder')->once()->andReturn(1);
     $this->mock->shouldReceive('uniqueExcept')->twice();
     $this->mock->shouldReceive('identify')->once();
     $this->mock->shouldReceive('saveRelations')->twice()->andReturn(array(1, 2, 3));
     $this->mock->shouldReceive('categories', 'tags')->once()->andReturn($this->mock);
     $this->mock->shouldReceive('sync')->twice()->andReturn($this->mock);
     $this->post($this->url);
     $this->assertRedirectedToRoute($this->route . '.index');
 }
開發者ID:sorora,項目名稱:bms,代碼行數:15,代碼來源:PostsControllerTest.php

示例12: it_redirects_to_the_dashboard_page_given_valid_credentials

 /** @test **/
 function it_redirects_to_the_dashboard_page_given_valid_credentials()
 {
     $findResponse = Mockery::mock(User::class);
     $findResponse->shouldReceive('getAttribute')->with('is_active')->once()->andReturn(true);
     $user = Mockery::mock(User::class);
     $user->shouldReceive('where->first')->once()->andReturn($findResponse);
     $this->instance(User::class, $user);
     $request = Mockery::mock(AuthRequest::class);
     $request->shouldReceive('only')->once()->andReturn($this->factory);
     $this->instance(AuthRequest::class, $request);
     Auth::shouldReceive('validate')->once()->andReturn(true);
     Auth::shouldReceive('login')->once()->andReturn(true);
     $this->route('POST', 'sessions.store');
     $this->assertRedirectedToRoute('dashboard');
 }
開發者ID:salpakan,項目名稱:salpakan,代碼行數:16,代碼來源:SessionsControllerTest.php

示例13: testPostLoginFailed

 public function testPostLoginFailed()
 {
     $input = ['username' => 'foo.bar', 'password' => 'asdfg', 'captcha' => 'asdf'];
     $userFaker = factory(Model::class)->create();
     $request = Mockery::mock('Suitcoda\\Http\\Requests\\AuthRequest');
     $request->shouldReceive('only');
     $request->shouldReceive('has');
     \Auth::shouldReceive('attempt')->andReturn(false);
     $auth = new AuthController();
     $result = $auth->postLogin($request);
     $error = $this->app['session.store']->get('errors')->get('username');
     $this->assertInstanceOf('Illuminate\\Http\\RedirectResponse', $result);
     $this->assertEquals($this->app['url']->to('login'), $result->headers->get('Location'));
     $this->assertContains('These credentials do not match our records.', $error);
 }
開發者ID:richan-fongdasen,項目名稱:suitcoda,代碼行數:15,代碼來源:AuthControllerTest.php

示例14: test_post_reauthenticate_returns_redirect

 public function test_post_reauthenticate_returns_redirect()
 {
     $user = new TestUser();
     $user->password = bcrypt('test');
     Auth::shouldReceive('user')->once()->andReturn($user);
     Session::set('url.intended', 'http://reauthenticate.app/auth/reauthenticate');
     $request = \Illuminate\Http\Request::create('http://reauthenticate.app/auth/reauthenticate', 'POST', ['password' => 'test']);
     $request->setSession(app('session.store'));
     $controller = new TestController();
     /** @var Illuminate\Http\RedirectResponse $response */
     $response = $controller->postReauthenticate($request);
     $this->assertInstanceOf(Illuminate\Http\RedirectResponse::class, $response);
     $this->assertEquals('http://reauthenticate.app/auth/reauthenticate', $response->getTargetUrl());
     $this->assertTrue(Session::has('reauthenticate.life'));
     $this->assertTrue(Session::has('reauthenticate.authenticated'));
     $this->assertTrue(Session::get('reauthenticate.authenticated'));
 }
開發者ID:JamesForks,項目名稱:reauthenticate,代碼行數:17,代碼來源:ReauthenticateControllerTest.php

示例15: testCallback

 public function testCallback()
 {
     \Auth::shouldReceive('attempt')->once()->andReturn(true);
     $this->client->request('GET', 'auth/callback');
     $this->assertTrue($this->client->getResponse()->isRedirect());
 }
開發者ID:k-kurikuri,項目名稱:Laravel.JpRecipe,代碼行數:6,代碼來源:AuthenticateControllerTest.php


注:本文中的Auth::shouldReceive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。