/** @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]); }
/** @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_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); }
/** @test */ public function it_saves_a_status_for_a_user() { // Given $user = TestDummy::create('Larabook\\Users\\User'); $unsavedStatus = TestDummy::build('Larabook\\Statuses\\Status', ['body' => 'This is a test status', 'user_id' => null]); // When $this->repository->save($unsavedStatus, $user->id); // Then $this->tester->seeRecord('statuses', ['body' => 'This is a test status', 'user_id' => $user->id]); }
/** @test */ public function it_saves_a_status_for_a_user() { // Given I have an unsaved status $status = TestDummy::build('Larabook\\Statuses\\Status', ['user_id' => null, 'body' => 'My status']); // And an existing user $user = TestDummy::create('Larabook\\Users\\User'); // When I try to persist this status $this->repo->save($status, $user->id); // Then it should be saved $this->tester->seeRecord('statuses', ['body' => 'My status', 'user_id' => $user->id]); }
/** @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]); }
/** @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_saves_a_status_for_a_user() { // Given I have an unsaved status $status = TestDummy::create('HACKson\\Statuses\\Status', ['user_id' => null, 'body' => 'Statusmessage.']); // And an existing user $user = TestDummy::create('HACKson\\Users\\User'); // When I try to persist this status $this->repo->save($status, $user->id); // Then it should be saved // And the status should have the correct user_id $this->tester->seeRecord('statuses', ['body' => 'Statusmessage.', 'user_id' => $user->id]); }
/** @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_saves_a_status_for_a_user() { //given unsaved status $status = TestDummy::create('Larabook\\Statuses\\Status', ['user_id' => null, 'body' => 'My status']); //and an existing user $user = TestDummy::create('Larabook\\Users\\User'); //when i try to persist this status $savedStatus = $this->repo->save($status, $user->id); //then it should be saved $this->tester->seeRecord('statuses', ['body' => 'My status']); //and the status should have the correct user_id $this->assertEquals($user->id, $savedStatus->user_id); }
/** * @test */ public function it_saves_a_status_for_a_user() { // Given I have an unsaved status $status = TestDummy::create('App\\Status', ['user_id' => null, 'body' => 'My Status']); // And existing user $user = TestDummy::create('App\\User'); // When I try to persist this status $savedStatus = $this->repo->save($status, $user->id); // It should be saved $this->tester->seeRecord('statuses', ['body' => 'My Status']); // Status should have correct user id $this->assertEquals($user->id, $savedStatus->user_id); }
/** @test */ public function it_saves_a_status_for_a_specific_user() { // Given I have unsaved status $status = Factory::build(Status::class, ['user_id' => null, 'body' => 'My Status']); // And an existing user $user = Factory::create(User::class); // When I try to persist this status $savedStatus = $this->repo->save($status, $user); // Then it should be saved $this->tester->seeRecord('statuses', ['body' => 'My Status']); // And the status should have the correct user_id $this->assertEquals($user->id, $savedStatus->user_id); }
/** * @test * * Uses array index to access specific user */ public function it_unfollows_another_user() { // I have 2 users list($john, $susan) = TestDummy::times(2)->create('App\\User'); // User Id to unfollow (second user) $userIdToUnfollow = $susan->id; // And first User unfollows the second User $john->followedUsers()->detach($userIdToUnfollow); // You should see the list of those that user[0] follows // Method 1 (assertCount) - seeing that there is 1 user following $this->assertCount(0, $john->followedUsers()->get()); // Method 2 (assertTrue) - Does the list of followed users contain the second user $this->assertFalse($john->followedUsers->contains($susan->id)); // Method 3 (seeRecord) - Seeing if the record exists in the table $this->tester->dontSeeRecord('follows', ['follower_id' => $john->id, 'followed_id' => $susan->id]); }