public function testDestroyReturnsJsonResponseInstance()
 {
     $users = Factory::times(5)->create('App\\User');
     $currentUser = User::first();
     Auth::login($currentUser);
     $controller = new FriendController($currentUser);
     $request = new Request(['userId' => 2]);
     $response = $controller->destroy($request);
     $this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
 }
Example #2
0
 /**
  * @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());
     }
 }
Example #3
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']);
 }
Example #4
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]);
 }
 /** @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]);
 }
 public function testGetIdsThatSentRequestToCurrentUser()
 {
     $user = Factory::create('App\\User');
     $friendRequests = Factory::times(25)->create('App\\FriendRequest', ['user_id' => $user->id]);
     $repository = new EloquentFriendRequestRepository();
     $results = $repository->getIdsThatSentRequestToCurrentUser($user->id);
     $this->assertEquals(25, count($results));
 }
Example #7
0
 public function run()
 {
     TestDummy::times(1)->create('Bican\\Roles\\Models\\Role');
     Role::create(['name' => 'Printeron', 'slug' => 'Printeron', 'description' => 'Dostep tylko dla pracownikow Printon', 'level' => '40']);
     Role::create(['name' => 'Printing House', 'slug' => preg_replace('/[\\s-]+/', '-', 'Printing House'), 'description' => 'Drukarnia', 'level' => '30']);
     Role::create(['name' => 'Advertising Agency', 'slug' => "Advertising-Agency", 'description' => 'Dostep tylko dla Agencji reklamowych', 'level' => '20']);
     Role::create(['name' => 'Client', 'slug' => "Client", 'description' => 'Klient', 'level' => '10']);
 }
 /** @test */
 public function it_finds_users_with_statuses_by_their_username()
 {
     $statuses = TestDummy::times(3)->create('Larabook\\Statuses\\Status');
     $username = $statuses[0]->user->username;
     $user = $this->repo->findByUsername($username);
     $this->assertEquals($username, $user->username);
     $this->assertCount(3, $user->statuses);
 }
 public function testIndex()
 {
     $projects = Factory::times(2)->create('Project');
     $this->action('GET', 'ProjectsController@index');
     $this->assertResponseOk();
     $this->assertViewIs('projects.index');
     $this->assertViewHas('projects');
 }
 /**
  * @test
  */
 public function it_gets_all_statuses_for_a_user()
 {
     $user = TestDummy::times(2)->create('App\\User');
     TestDummy::times(2)->create('App\\Status', ['user_id' => $user[0]->id]);
     TestDummy::times(2)->create('App\\Status', ['user_id' => $user[1]->id]);
     $statusesForUser = $this->repo->getAllForUser($user[0]);
     $this->assertCount(2, $statusesForUser);
 }
Example #11
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');
 }
Example #12
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));
 }
 public function run()
 {
     $this->truncateTable('property_types');
     $propertyTypes = config('setup.properties.types');
     foreach ($propertyTypes as $id => $propertyType) {
         PropertyType::create(['id' => $propertyType['id'], 'name' => $propertyType['name'], 'element' => $propertyType['element'], 'type' => $propertyType['type'], 'is_void' => $propertyType['is_void']]);
     }
     Factory::times(10)->create(PropertyType::class);
 }
 public function testIndex()
 {
     Factory::times(2)->create('Post');
     $this->action('GET', 'PagesController@index');
     $this->assertResponseOk();
     $this->assertViewIs('pages.index');
     $this->assertViewHas('latestPost');
     $this->assertViewHas('popularPosts');
 }
 /**
  * A functional test example.
  *
  * @return void
  */
 public function testReceiptCategoryAssign()
 {
     $receipt = Factory::create('App\\Receipt');
     $categories = Factory::times(3)->create('App\\Category');
     $owner = ['user_id' => \App\User::first()->id];
     $receipt->categories()->attach($categories->lists('id'), $owner);
     foreach ($categories as $category) {
         $this->assertTrue($receipt->hasCategory($category));
     }
 }
 public function testShow()
 {
     $tag = Factory::create('Tag');
     $posts = Factory::times(3)->create('Post');
     $tag->posts()->sync([$posts[0]->id, $posts[1]->id, $posts[2]->id]);
     $response = $this->action('GET', 'TagsController@show', $tag->slug);
     $this->assertResponseOk();
     $this->assertViewIs('tags.show');
     $this->assertViewHas('posts');
 }
 public function testDeleteRelatedMetaWhenRemovesAUser()
 {
     $user = Factory::create('User', ['id' => 1]);
     Factory::times(2)->create('PostMeta', ['meta_key' => 'pal_user_id', 'meta_value' => 1]);
     $metaBeforeDelete = $user->meta;
     $user->delete();
     $metaAfterDelete = PostMeta::where('meta_key', '=', 'pal_user_id')->where('meta_value', '=', $user->id)->get();
     assertThat($metaBeforeDelete, is(nonEmptyTraversable()));
     assertThat($metaAfterDelete, is(emptyTraversable()));
 }
Example #18
0
 public function testIndexReturnsViewInstance()
 {
     $currentUser = Factory::create('App\\User');
     $feeds = Factory::times(20)->create('App\\Feed', ['user_id' => $currentUser->id]);
     Auth::login($currentUser);
     $feedController = new FeedController($currentUser);
     $feedRepository = new EloquentFeedRepository();
     $response = $feedController->index($feedRepository);
     $this->assertInstanceOf('Illuminate\\View\\View', $response);
 }
Example #19
0
 /** @test */
 public function it_gets_all_statuses_for_a_user()
 {
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[0]->id, 'body' => 'My Body 1']);
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[1]->id, 'body' => 'My Body 2']);
     $statusesForUser1 = $this->repo->getAllForUser($users[0]->id);
     $this->assertCount(2, $statusesForUser1);
     $statusesForUser2 = $this->repo->getAllForUser($users[1]->id);
     $this->assertCount(2, $statusesForUser2);
 }
 public function testShow()
 {
     $posts = Factory::times(3)->create('Post');
     head($posts)->update(['published_at' => null]);
     $series = head($posts)->series;
     $response = $this->action('GET', 'SeriesController@show', $series->slug);
     $this->assertResponseOk();
     $this->assertViewIs('series.show');
     $this->assertViewHas('series');
     $this->assertContains('2 posts', $response->getContent());
 }
 public function testIndexReturnsViewInstance()
 {
     $user = Factory::create('App\\User');
     $friendRequests = Factory::times(25)->create('App\\FriendRequest', ['user_id' => $user->id]);
     Auth::login($user);
     $friendRequestController = new FriendRequestController($user);
     $friendRequestRepository = new EloquentFriendRequestRepository();
     $userRepository = new EloquentUserRepository();
     $response = $friendRequestController->index($friendRequestRepository, $userRepository);
     $this->assertInstanceOf('Illuminate\\View\\View', $response);
 }
 /** @test */
 public function it_unfollows_another_user()
 {
     // given I have two users
     list($john, $susan) = TestDummy::times(2)->create('Larabook\\Users\\User');
     // and one user follows another user
     $this->repo->follow($susan->id, $john);
     // when I unfollow that same user
     $this->repo->unfollow($susan->id, $john);
     // then I should NOT see that user in the list of those that $john follows...
     $this->tester->dontSeeRecord('follows', ['follower_id' => $john->id, 'followed_id' => $susan->id]);
 }
Example #23
0
 public function testFindManyById()
 {
     $users = Factory::times(20)->create('App\\User');
     $ids = [];
     foreach ($users as $user) {
         $ids[] = $user->id;
     }
     $userRepository = new EloquentUserRepository();
     $result = $userRepository->findManyById($ids);
     $this->assertEquals(20, count($result));
 }
 /** @test */
 public function it_unfallows_the_user()
 {
     # Given I have 2 users
     list($john, $susan) = Factory::times(2)->create(User::class);
     # And one user fallows another user
     $this->repo->fallow($susan, $john);
     # then I unfallow that same user
     $this->repo->unfallow($susan, $john);
     # Then I should NOT see the user in a list of those that $john fallows...
     $this->tester->dontSeeRecord('fallows', ['fallower_id' => $john->id, 'fallowed_id' => $susan->id]);
 }
 /** @test */
 public function it_gets_all_statuses_for_a_user()
 {
     // Given
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[0]->id]);
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[1]->id]);
     // When
     $statusesForUser = $this->repository->getAllForUser($users[0]->id);
     // Then
     $this->assertCount(2, $statusesForUser);
 }
 /** @test */
 public function it_unfollows_another_user()
 {
     // given I have 2 users
     list($cat, $dog) = TestDummy::times(2)->create('HACKson\\Users\\User');
     // and one user follows another user
     $this->repo->follow($cat->id, $dog);
     // and one user unfollows another user
     $this->repo->unfollow($cat->id, $dog);
     // then I should see the user in the list of user 0 followings
     $this->assertFalse($dog->followedUsers->contains($cat->id));
 }
 /** @test */
 public function it_gets_all_statuses_for_a_user()
 {
     //given i have 2 users
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     //and statuses for both of them
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[0]->id, 'body' => 'My status']);
     TestDummy::times(2)->create('Larabook\\Statuses\\Status', ['user_id' => $users[1]->id, 'body' => 'His status']);
     //when i fetch statuses for one user
     $statusesForUser = $this->repo->getAllForUser($users[0]);
     //then i should receive only relevant ones
     $this->assertCount(2, $statusesForUser);
 }
Example #28
0
 /**
  * It send multiple Notifications
  *
  * @method send
  * @group failing
  * @test
  */
 function it_send_multiple_notifications()
 {
     Factory::times(10)->create(User::class);
     $this->createCategory(['name' => 'me']);
     $allUsers = User::all();
     $this->notifynder->loop($allUsers, function ($builder, $user) {
         $builder->category('me')->url('you')->from(1)->to($user->id);
     })->send();
     // should send 10 notifications
     $notifications = Notification::all();
     $this->assertCount(10, $notifications);
 }
 /** @tests */
 public function it_unfollows_another_user()
 {
     // given I have two users
     // an array of using object that was created
     $users = TestDummy::times(2)->create('Larabook\\Users\\User');
     //and one user follows another user
     $this->repo->follow($users[1]->id, $users[0]);
     //when I unfollow the same user
     $this->repo->unfollow($users[1]->id, $users[0]);
     // then I should NOT see that user in the list of those that $users[0] follows...
     $this->tester->dontSeeRecord('follows', ['follower_id' => $users[0]->id, 'followed_id' => $users[1]->id]);
 }
 /** @test */
 public function it_gets_all_statuses_for_a_user()
 {
     // Given I have two users
     $users = TestDummy::times(2)->create('HACKson\\Users\\User');
     // And statuses for both of them
     TestDummy::times(2)->create('HACKson\\Statuses\\Status', ['user_id' => $users[0]->id]);
     TestDummy::times(2)->create('HACKson\\Statuses\\Status', ['user_id' => $users[1]->id]);
     // When I fetch statuses for one user
     $statusesForUser = $this->repo->getAllForUser($users[0]);
     // Then I should receive only the relevant ones
     $this->assertCount(2, $statusesForUser);
 }