<commit_before><?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class MovieReviePredictControllerTest extends TestCase
{

    /**
     * test predict
     *
     * @dataProvider predictProvider
     * @param $review
     * @param $status
     * @param $jsonResponse
     */
    public function testPredict($review, $status, $jsonResponse)
    {
        // get our uri using the route helper
        $uri = route('predict-review', [], false);

        // call the predict route
        $response = $this->post(
            $uri,
            [
                // our csrf token
                '_token' => csrf_token(),
                // pass our review in
                'review' => $review,
            ],
            [
                // requested with ajax
                'X-Requested-With' => 'XMLHttpRequest'
            ]
        );

        // we expect a json response back cause
        // this is an ajax route
        $response
            ->assertStatus($status)
            ->assertJson($jsonResponse);

    }

    public function predictProvider()
    {
        return [
            'no review' => [
                // review
                '',
                // status
                422,
                // json response
                ["review" => ["The review field is required."]],
            ],
            'review not long enough' => [
                'test',
                // status
                422,
                // json response
                ["review" => ["The review must be at least 15 characters."]],
            ],
            'review successful' => [
                // review
                'The movie was the best movie I\'ve ever seen',
                // status
                200,
                // json response
                [
                    'label' => 'positive',
                    'probability' => '98.62'
                ],
            ],
        ];
    }

    /**<commit_msg>fixing unit tests for laravel 5.5<commit_after><?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class MovieReviePredictControllerTest extends TestCase
{

    /**
     * test predict
     *
     * @dataProvider predictProvider
     * @param $review
     * @param $status
     * @param $jsonResponse
     */
    public function testPredict($review, $status, $jsonResponse)
    {
        // get our uri using the route helper
        $uri = route('predict-review', [], false);

        // call the predict route
        $response = $this->post(
            $uri,
            [
                // our csrf token
                '_token' => csrf_token(),
                // pass our review in
                'review' => $review,
            ],
            [
                // requested with ajax
                'X-Requested-With' => 'XMLHttpRequest'
            ]
        );

        // we expect a json response back cause
        // this is an ajax route
        $response
            ->assertStatus($status)
            ->assertJson($jsonResponse);

    }

    public function predictProvider()
    {
        return [
            'no review' => [
                // review
                '',
                // status
                422,
                // json response
                [
                    "message" => "The given data was invalid.",
                    "errors" =>
                        [
                            "review" =>
                                [
                                    "The review field is required.",
                                ],
                        ],
                ],
            ],
            'review not long enough' => [
                'test',
                // status
                422,
                // json response
                [
                    "message" => "The given data was invalid.",
                    "errors" =>
                        [
                            "review" =>
                                [
                                    "The review must be at least 15 characters.",
                                ],
                        ],
                ],
                ["review" => ["The review must be at least 15 characters."]],
            ],
            'review successful' => [
                // review
                'The movie was the best movie I\'ve ever seen',
                // status
                200,
                // json response
                [
                    'label' => 'positive',
                    'probability' => '98.62'
                ],
            ],
        ];
    }

    /**
{'fraction_non_alphanumeric': 0.10097521332791548, 'fraction_numerical': 0.00690776107273466, 'mean_word_length': 0.9771084337349397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4257680', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1098, 'n_words': 294}