<commit_before><?php

namespace SuitTests\Supports;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Mockery;
use SuitTests\TestCase;
use Suitcoda\Model\Category;
use Suitcoda\Model\Inspection;
use Suitcoda\Model\JobInspect;
use Suitcoda\Model\Project;
use Suitcoda\Model\Score;
use Suitcoda\Model\Url;
use Suitcoda\Supports\CalculateScore;

class CalculateScoreTest extends TestCase
{
    use DatabaseTransactions;

    /**
     * Setup the test environment.
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
    }

    /**
     * Clean up the testing environment before the next test.
     *
     * @return void
     */
    public function tearDown()
    {
        parent::tearDown();
    }

    /**
     * Test add score to database
     *
     * @return void
     */
    public function testAddScore()
    {
        $projectFaker = factory(Project::class)->create();
        $inspectionFaker = factory(Inspection::class)->create([
            'project_id' => $projectFaker->id
        ]);
        factory(JobInspect::class, 5)->create([
            'inspection_id' => $inspectionFaker->id,
            'scope_id' => 1,
            'issue_count' => 7,
            'status' => 2
        ]);
        factory(Url::class, 2)->create([
            'project_id' => $projectFaker->id
        ]);
        $score = Mockery::mock(Score::class);
        $category = Mockery::mock(Category::class);

        $score->shouldReceive('findOrNewByInspectionId')->andReturn(new Score);
        $score->shouldReceive('inspection->associate');
        $score->shouldReceive('save')->andReturn(true);
        $category->shouldReceive('all')->andReturn(Category::all());

        $calculateScore = new CalculateScore($score, $category);

        $calculateScore->calculate($inspectionFaker);
        $this->seeInDatabase('scores', [
            'category_id' => '1',
            'score' => 17.5
        ]);
    }<commit_msg>Fix calculate test case<commit_after><?php

namespace SuitTests\Supports;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Mockery;
use SuitTests\TestCase;
use Suitcoda\Model\Category;
use Suitcoda\Model\Inspection;
use Suitcoda\Model\JobInspect;
use Suitcoda\Model\Project;
use Suitcoda\Model\Score;
use Suitcoda\Model\Url;
use Suitcoda\Supports\CalculateScore;

class CalculateScoreTest extends TestCase
{
    use DatabaseTransactions;

    /**
     * Setup the test environment.
     *
     * @return void
     */
    public function setUp()
    {
        parent::setUp();
    }

    /**
     * Clean up the testing environment before the next test.
     *
     * @return void
     */
    public function tearDown()
    {
        parent::tearDown();
    }

    /**
     * Test add score to database
     *
     * @return void
     */
    public function testAddScore()
    {
        $projectFaker = factory(Project::class)->create();
        $inspectionFaker = factory(Inspection::class)->create([
            'project_id' => $projectFaker->id
        ]);
        factory(JobInspect::class, 5)->create([
            'inspection_id' => $inspectionFaker->id,
            'scope_id' => 1,
            'issue_count' => 7,
            'status' => 2
        ]);
        factory(Url::class, 2)->create([
            'project_id' => $projectFaker->id
        ]);
        $score = Mockery::mock(Score::class);
        $category = Mockery::mock(Category::class);

        $score->shouldReceive('findOrNewByRelatedId')->andReturn(new Score);
        $score->shouldReceive('inspection->associate');
        $score->shouldReceive('save')->andReturn(true);
        $category->shouldReceive('all')->andReturn(Category::all());

        $calculateScore = new CalculateScore($score, $category);

        $calculateScore->calculate($inspectionFaker);
        $this->seeInDatabase('scores', [
            'category_id' => '1',
            'score' => 17.5
        ]);
    }
{'fraction_non_alphanumeric': 0.14033341627270465, 'fraction_numerical': 0.004478726051256532, 'mean_word_length': 2.5701598579040854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 53, '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': '2349766', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1178, 'n_words': 213}