/** * 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']); }