<commit_before><?php

use Rogue\Models\Post;
use Rogue\Models\User;
use Rogue\Models\Signup;

class ReviewsTest extends TestCase
{
    /**
     * Test that a PUT request to /reviews updates the post's status and creates a new event and review.
     *
     * PUT /reviews
     * @return void
     */
    public function testUpdatingASingleReview()
    {
        $this->mockTime('8/3/2017 17:02:00');

        // Create a post.
        $user = factory(User::class, 'admin')->create();
        $post = factory(Post::class)->create();

        $this->actingAs($user)->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        $this->assertResponseStatus(201);

        // Make sure the post status is updated & a review is created.
        $this->assertEquals('accepted', $post->fresh()->status);
        $this->seeInDatabase('reviews', [
            'admin_northstar_id' => $user->northstar_id,
            'post_id' => $post->id,
        ]);

        // Make sure we created an event for the review.
        $this->seeInDatabase('events', [
            'eventable_type' => 'Rogue\Models\Review',
            'created_at' => '2017-08-03 17:02:00'
        ]);
    }

    /**
     * Test that non-admin cannot review posts.
     *
     * @return void
     */
    public function testUnauthenticatedUserCantReviewPosts()
    {
        $user = factory(User::class)->create();
        $post = factory(Post::class)->create();

        $this->actingAs($user)->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        $this->assertResponseStatus(403);
    }

    /**
     * Test that a post and signup's updated_at updates when a review is made.
     *
     * @return void
     */
    public function testUpdatedPostAndSignupWithReview()
    {
        // @TODO: This isn't currently working.
        $this->markTestSkipped();

        // Create a signup and a post, and associate them to each other.
        $signup = factory(Signup::class)->create();
        $post = factory(Post::class)->create();
        $post->signup()->associate($signup);

        // And then later on, we'll make a review...
        $this->mockTime('8/3/2017 16:55:00');

        // Review the post.
        $this->actingAsAdmin()->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        // Make sure the signup and post's updated_at are both updated.
        $this->assertEquals('2017-08-03 16:55:00', (string) $signup->fresh()->updated_at);
        $this->assertEquals('2017-08-03 16:55:00', (string) $post->fresh()->updated_at);
    }
}<commit_msg>Mark specific problem in incomplete test.<commit_after><?php

use Rogue\Models\Post;
use Rogue\Models\User;
use Rogue\Models\Signup;

class ReviewsTest extends TestCase
{
    /**
     * Test that a PUT request to /reviews updates the post's status and creates a new event and review.
     *
     * PUT /reviews
     * @return void
     */
    public function testUpdatingASingleReview()
    {
        $this->mockTime('8/3/2017 17:02:00');

        // Create a post.
        $user = factory(User::class, 'admin')->create();
        $post = factory(Post::class)->create();

        $this->actingAs($user)->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        $this->assertResponseStatus(201);

        // Make sure the post status is updated & a review is created.
        $this->assertEquals('accepted', $post->fresh()->status);
        $this->seeInDatabase('reviews', [
            'admin_northstar_id' => $user->northstar_id,
            'post_id' => $post->id,
        ]);

        // Make sure we created an event for the review.
        $this->seeInDatabase('events', [
            'eventable_type' => 'Rogue\Models\Review',
            'created_at' => '2017-08-03 17:02:00'
        ]);
    }

    /**
     * Test that non-admin cannot review posts.
     *
     * @return void
     */
    public function testUnauthenticatedUserCantReviewPosts()
    {
        $user = factory(User::class)->create();
        $post = factory(Post::class)->create();

        $this->actingAs($user)->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        $this->assertResponseStatus(403);
    }

    /**
     * Test that a post and signup's updated_at updates when a review is made.
     *
     * @return void
     */
    public function testUpdatedPostAndSignupWithReview()
    {
        // Create a signup and a post, and associate them to each other.
        $signup = factory(Signup::class)->create();
        $post = factory(Post::class)->create();
        $post->signup()->associate($signup);

        // And then later on, we'll make a review...
        $this->mockTime('8/3/2017 16:55:00');

        // Review the post.
        $this->actingAsAdmin()->put('reviews', [
            'post_id' => $post->id,
            'status' => 'accepted',
        ]);

        // Make sure the signup and post's updated_at are both updated.
        $this->assertEquals('2017-08-03 16:55:00', (string) $post->fresh()->updated_at);

        // @TODO: Signup timestamp isn't being touched.
        // $this->assertEquals('2017-08-03 16:55:00', (string) $signup->fresh()->updated_at);
        $this->markTestIncomplete();
    }
}
{'fraction_non_alphanumeric': 0.15979955456570155, 'fraction_numerical': 0.026726057906458798, 'mean_word_length': 2.1718658034137728, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5294656', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1604, 'n_words': 374}