コード例 #1
0
 /**
  * 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#');*/
 }
コード例 #2
0
ファイル: QuestionServiceTest.php プロジェクト: a1ex7/asciit
 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);
 }
コード例 #3
0
 /**
  * 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();
 }
コード例 #4
0
 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]);
 }
コード例 #5
0
ファイル: RevisionsTraitTest.php プロジェクト: pionl/revision
 /**
  * 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);
 }
コード例 #6
0
ファイル: JsonRpcTest.php プロジェクト: ngmy/webloyer
 /**
  * @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);
 }
コード例 #7
0
 public function testHandleLoginFailedAttempt()
 {
     Input::replace($input = array('email' => '*****@*****.**', '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');
 }
コード例 #8
0
 /**
  * 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);
 }
コード例 #9
0
ファイル: MuralTest.php プロジェクト: laravolt/mural
 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);
 }
コード例 #10
0
 /** @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 = '******';
     $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');
 }
コード例 #11
0
ファイル: PostsControllerTest.php プロジェクト: sorora/bms
 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');
 }
コード例 #12
0
 /** @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');
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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'));
 }
コード例 #15
0
 public function testCallback()
 {
     \Auth::shouldReceive('attempt')->once()->andReturn(true);
     $this->client->request('GET', 'auth/callback');
     $this->assertTrue($this->client->getResponse()->isRedirect());
 }
コード例 #16
0
 public function testAuthControllerCanReturnErrors()
 {
     Auth::shouldReceive('attempt')->once()->andReturn(False);
     $response = $this->test->postLogin();
     $this->assertIsRedirect($response, URL::route('day004_login'));
 }
コード例 #17
0
ファイル: LiveExtensionTest.php プロジェクト: apsdsm/spectre
 /**
  * @test
  */
 function it_renders_update_source_when_viewed_through_the_admin_interface()
 {
     \Auth::shouldReceive('check')->once()->andReturn(true);
     $rendered = \View::file($this->valid_path)->render();
     $this->assertContains('<h1 data-live-update-source="title">Title</h1>', $rendered);
 }
コード例 #18
0
 /**
  * Mock the guard validation.
  *
  * @param  bool  $auth
  * @return void
  */
 private function mockGuardValidation(bool $auth)
 {
     Auth::shouldReceive('validate')->once()->andReturn($auth);
 }
コード例 #19
0
ファイル: AccessControllerTest.php プロジェクト: sorora/aurp
 public function testLogout()
 {
     Auth::shouldReceive('logout')->once()->andReturn(true);
     $this->get($this->prefix . 'logout');
     $this->assertRedirectedToRoute('login');
 }
コード例 #20
0
 /**
  * @test
  */
 public function it_renders_the_admin_header_when_viewed_through_the_admin_interface()
 {
     \Auth::shouldReceive('check')->once()->andReturn(true);
     $rendered = \View::file($this->valid_path)->render();
     $this->assertContains("<!-- Spectre Editing Header -->", $rendered);
 }
コード例 #21
0
 public function testIndexProjectOrderByUpdatedAt()
 {
     $project = Mockery::mock(Project::class);
     $scope = Mockery::mock(Scope::class);
     $user = Mockery::mock(User::class);
     $controller = new ProjectController($project, $scope);
     \Auth::shouldReceive('user')->andReturn($user);
     $user->shouldReceive('projects->orderBy->get');
     $controller->index();
 }