当前位置: 首页>>代码示例>>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;未经允许,请勿转载。