コード例 #1
0
ファイル: MatchTest.php プロジェクト: bashmach/ggf
 /**
  * @param $request
  * @param $response
  * @param $attributesToCheck
  *
  * @dataProvider matchUpdatesWithRequests
  */
 public function testUpdateMatchScore($request, $response, $attributesToCheck)
 {
     $member = Factory::create('App\\Models\\Member');
     Auth::login($member);
     /**
      * @var $tournament Tournament
      * @var $league League
      * @var $homeTeam Team
      * @var $awayTeam Team
      * @var $homeTournamentTeam TournamentTeam
      * @var $awayTournamentTeam TournamentTeam
      * @var $match Match
      */
     $tournament = Factory::create('App\\Models\\Tournament');
     $league = Factory::create('App\\Models\\League');
     $homeTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
     $awayTeam = Factory::create('App\\Models\\Team', ['leagueId' => $league->id]);
     $homeTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $homeTeam->id, 'tournamentId' => $tournament->id]);
     $awayTournamentTeam = Factory::create('App\\Models\\TournamentTeam', ['teamId' => $awayTeam->id, 'tournamentId' => $tournament->id]);
     $match = Factory::create('App\\Models\\Match', ['tournamentId' => $tournament->id, 'homeTournamentTeamId' => $homeTournamentTeam->id, 'awayTournamentTeamId' => $awayTournamentTeam->id]);
     $this->put('/api/v1/matches/' . $match->id, ['match' => $request], ['HTTP_X-Requested-With' => 'XMLHttpRequest', 'HTTP_CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json']);
     $this->assertResponseStatus($response['status']);
     if (!empty($result)) {
         $updatedRow = Match::find($match->id);
         foreach ($result as $property => $value) {
             $this->assertEquals($value, $updatedRow->getAttribute($property));
         }
     }
 }
コード例 #2
0
 /**
  * Tests if the remove function works correctly.
  */
 public function testRepoRemovePlayerSuccessRemoval()
 {
     $player = Factory::create('App\\Models\\Player');
     $success = $this->repository->removePlayer($player->nickname);
     $this->assertTrue($success);
     $this->assertNull(Player::find($player->id));
 }
コード例 #3
0
 public function testStoreWithIncorrectCredentials()
 {
     $user = Factory::create('User', ['email' => '*****@*****.**']);
     $this->action('POST', 'Admin\\SessionsController@store', ['email' => $user->email, 'password' => 'foo']);
     $this->assertRedirectedToRoute('admin.sessions.create');
     $this->assertSessionHas('error', 'Your login credentials were invalid.');
 }
コード例 #4
0
 public function testDestroy()
 {
     $series = Factory::create('Series');
     $this->action('DELETE', 'Admin\\SeriesController@destroy', $series->slug);
     $this->assertRedirectedToRoute('admin.series.index');
     $this->assertEquals(0, Series::count());
 }
コード例 #5
0
ファイル: CreateUser.php プロジェクト: timegridio/concierge
 private function makeUser($overrides = [])
 {
     # $user = factory(User::class)->make($overrides);
     $user = Factory::build('Timegridio\\Tests\\Models\\User', $overrides);
     $user->email = '*****@*****.**';
     return $user;
 }
 /**
  * Tests if the repo removeAdministrator removes an
  * admin properly.
  */
 public function testRepoRemoveAdminSuccessRemoval()
 {
     $admin = Factory::create('App\\Models\\Administrator');
     $wasDeleted = $this->repository->removeAdministrator($admin->nickname);
     $this->assertTrue($wasDeleted);
     $this->assertNull(Administrator::find($admin->id));
 }
コード例 #7
0
ファイル: CreateDomain.php プロジェクト: timegridio/concierge
 private function makeDomain(User $owner, $overrides = [])
 {
     $domain = Factory::build(Domain::class, $overrides);
     $domain->save();
     $domain->owners()->attach($owner);
     return $domain;
 }
コード例 #8
0
 /** @test */
 public function it_unfollows_another_user()
 {
     list($john, $susan) = TestDummy::times(2)->create('Larabook\\Users\\User');
     $this->repo->follow($susan->id, $john);
     $this->repo->unfollow($susan->id, $john);
     $this->tester->dontseeRecord('follows', ['follower_id' => $john->id, 'followed_id' => $susan->id]);
 }
コード例 #9
0
 public function testDestroy()
 {
     $user = Factory::create('User');
     $this->action('DELETE', 'Admin\\UsersController@destroy', $user->id);
     $this->assertRedirectedToRoute('admin.users.index');
     $this->assertEquals(0, User::count());
 }
コード例 #10
0
ファイル: DrawLeagueTest.php プロジェクト: bashmach/ggf
 /**
  * @param $teamsAmount
  * @param $matcheAmount
  *
  * @dataProvider tournamentTeamsProvider
  */
 public function testSuccessLeagueDrawWithDifferrentTeamsAmount($teamsAmount, $matchesAmount)
 {
     /**
      * @var $tournament Tournament
      */
     $tournament = Factory::create('App\\Models\\Tournament');
     /**
      * @var $tournament Tournament
      */
     $league = Factory::create('App\\Models\\League');
     Factory::times($teamsAmount)->create('App\\Models\\Team', ['leagueId' => $league->id])->each(function ($team, $key) use($tournament) {
         $tournament->tournamentTeams()->create(['teamId' => $team->id, 'tournamentId' => $tournament->id]);
     });
     $tournament->status = Tournament::STATUS_STARTED;
     $tournament->save();
     $this->assertTrue($tournament instanceof Tournament);
     // verify total matches amount
     $this->assertEquals($matchesAmount, $tournament->matches()->getResults()->count());
     /**
      * @var $matches Collection
      * @var $team TournamentTeam
      */
     $matches = Match::where(['tournamentId' => $tournament->id])->get();
     foreach ($tournament->tournamentTeams()->getResults() as $team) {
         // verify matches per team
         $this->assertEquals(($teamsAmount - 1) * 2, $matches->filter(function ($match) use($team) {
             return $match->homeTournamentTeamId == $team->id || $match->awayTournamentTeamId == $team->id;
         })->count());
     }
 }
コード例 #11
0
 public function testDestroy()
 {
     $project = Factory::create('Project');
     $this->action('DELETE', 'Admin\\ProjectsController@destroy', $project->slug);
     $this->assertRedirectedToRoute('admin.projects.index');
     $this->assertEquals(0, Project::count());
 }
コード例 #12
0
 /** @test */
 public function it_deletes_an_album_review_with_a_picture()
 {
     $album = TestDummy::create('WITR\\AlbumReview', ['img_name' => '01234-review.jpg']);
     copy(__DIR__ . '/files/review.jpg', public_path() . '/img/albums/01234-review.jpg');
     $this->beEditor();
     $this->visit('/admin/reviews/' . $album->id)->onPage('/admin/reviews/' . $album->id)->submitForm('Delete Review')->andSee('Album Review Deleted!')->onPage('/admin/reviews')->notSeeInDatabase('album_reviews', ['id' => $album->id])->cannotSeeFile(public_path() . '/img/albums/' . $album->img_name);
 }
コード例 #13
0
 private function makeBusiness(User $owner, $overrides = [])
 {
     $business = Factory::build(Business::class, $overrides);
     $business->save();
     $business->owners()->attach($owner);
     return $business;
 }
コード例 #14
0
 public function test_it_saves_a_todo_for_a_given_todolist()
 {
     $todolist = Factory::create(App\Umbrella\Todo\TodoList::class, ['user_id' => 1]);
     $todoRepository = $this->app->make(App\Umbrella\Todo\Repository\TodoRepositoryInterface::class);
     $todo = $todoRepository->create('Finish up homework', $todolist);
     $this->seeInDatabase('todo', ['name' => 'Finish up homework', 'todo_list_id' => $todolist->id]);
 }
コード例 #15
0
 /** @test */
 public function it_unfollows_another_user()
 {
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     $this->repo->follow($users[1]->id, $users[0]);
     $this->repo->unfollow($users[1]->id, $users[0]);
     $this->tester->dontSeeRecord('follows', ['follower_id' => $users[0]->id, 'followed_id' => $users[1]->id]);
 }
コード例 #16
0
 public function testUserRelationshipReturnsModel()
 {
     $meta = Factory::create('PostMeta', ['meta_key' => 'pal_user_id', 'meta_value' => 1]);
     Factory::create('User', ['id' => 1]);
     $user = $meta->user;
     assertThat($user, is(anInstanceof('User')));
 }
コード例 #17
0
 public function test_it_updates_a_todo()
 {
     $todo = Factory::create(App\Umbrella\Todo\Todo::class);
     $todoRepository = $this->app->make(App\Umbrella\Todo\Repository\TodoRepositoryInterface::class);
     $todoRepository->update($todo, ['finished' => true]);
     $this->seeInDatabase('todo', ['id' => $todo->id, 'finished' => 1]);
 }
コード例 #18
0
 public function test_it_persists_a_todolist_for_a_given_user()
 {
     $user = \Laracasts\TestDummy\Factory::create(App\Umbrella\User\User::class);
     $todolistRepo = App::make('App\\Umbrella\\Todo\\Repository\\TodolistRepositoryInterface');
     $todolist = $todolistRepo->create('Private', $user);
     $this->seeInDatabase('todolist', ['name' => 'Private']);
 }
コード例 #19
0
 public function run()
 {
     TestDummy::times(1)->create('Bican\\Roles\\Models\\Permission');
     Permission::create(['name' => 'Manager', 'slug' => 'Manager', 'description' => 'Reporting to Board']);
     Permission::create(['name' => 'Admin', 'slug' => preg_replace('/[\\s-]+/', '-', "admin"), 'description' => 'Reporting to Manager']);
     Permission::create(['name' => 'Trainee', 'slug' => "Trainee", 'description' => 'Reporting to Admin']);
 }
コード例 #20
0
ファイル: MessagesTest.php プロジェクト: aku345/Larasocial
 public function testSendingAmessageToAnotherUser()
 {
     $currentUser = Factory::create('App\\User');
     $otherUser = Factory::create('App\\User');
     Auth::login($currentUser);
     $this->visit('/messages/compose/' . $otherUser->id)->submitForm('Submit', ['body' => 'This is the new message to you.'])->verifyInDatabase('messages', ['body' => 'This is the new message to you.'])->verifyInDatabase('message_responses', ['body' => 'This is the new message to you.']);
 }
コード例 #21
0
 public function testHandleReturnsTrueOnsuccesfulLogin()
 {
     $currentUser = Factory::create('App\\User');
     $loginUserCommand = new LoginUserCommand($currentUser->email, $currentUser->password);
     $loginUserCommand->handle();
     // $this->assertTrue($response);
     // $this->assertTrue($response);
 }
コード例 #22
0
 public function testGetPublishedByUserAndFriendsAjaxReturnArrayWithResults()
 {
     $user = Factory::create('App\\User');
     $feeds = Factory::times(20)->create('App\\Feed', ['user_id' => $user->id]);
     $repository = new EloquentFeedRepository();
     $feedCount = $repository->getPublishedByUserAndFriends($user);
     $this->assertEquals(10, count($feedCount));
 }
コード例 #23
0
 public function testHandleReturnsTheNewlyCreatedFeed()
 {
     $currentUser = Factory::create('App\\User');
     Auth::login($currentUser);
     $createFeedCommand = new CreateFeedCommand('This is the feed body', 'postername', 'http://image/sampleimage.jpg');
     $response = $createFeedCommand->handle();
     $this->assertInstanceOf('App\\Feed', $response);
 }
コード例 #24
0
 public function testAddNewFriendRequest()
 {
     $currentUser = Factory::create('App\\User');
     $otherUser = Factory::create('App\\User');
     Auth::login($currentUser);
     $this->visit('users')->click('Add friend');
     $this->assertResponseOk();
 }
コード例 #25
0
 private function makeAppointment(Business $business, User $issuer, Contact $contact, $override = [])
 {
     $appointment = Factory::build(Appointment::class, $override);
     $appointment->contact()->associate($contact);
     $appointment->issuer()->associate($issuer);
     $appointment->business()->associate($business);
     return $appointment;
 }
コード例 #26
0
 public function testHandleReturnsLogout()
 {
     $tempUser = Factory::create('App\\User');
     Auth::login($tempUser);
     $logoutUserCommand = new LogoutUserCommand($tempUser->id);
     $response = $logoutUserCommand->handle();
     $this->assertFalse($response);
 }
コード例 #27
0
 /** @test */
 public function it_saves_a_status_for_a_user()
 {
     $status = TestDummy::create('Larabook\\Statuses\\Status', ['user_id' => null, 'body' => 'My Body 3']);
     $users = TestDummy::create('Larabook\\Users\\User');
     $savedStatus = $this->repo->save($status, $users->id);
     $this->tester->seeRecord('statuses', ['body' => 'My Body 3']);
     $this->assertEquals($users->id, $savedStatus->user_id);
 }
コード例 #28
0
 public function testFindByIdWithResponsesReturnsCollection()
 {
     $messageResponse = Factory::create('App\\MessageResponse');
     $message = Message::first();
     $messageRepository = new EloquentMessageRepository();
     $response = $messageRepository->findByIdWithMessageResponses($message->id);
     $this->assertInstanceOf('App\\Message', $response);
 }
コード例 #29
0
 public function testBothUserObjectsExistInClass()
 {
     $requestedUser = Factory::create('App\\User');
     $requesterUser = Factory::create('App\\User');
     $event = new FriendRequestWasSent($requestedUser, $requesterUser);
     $this->assertEquals($requesterUser->email, $event->requesterUser->email);
     $this->assertEquals($requestedUser->email, $event->requestedUser->email);
 }
コード例 #30
0
 public function run()
 {
     DB::table('user')->delete();
     TestDummy::create('normal_user');
     TestDummy::create('editor_user');
     TestDummy::create('admin_user');
     TestDummy::times(20)->create('WITR\\User');
 }