user = User::first(); $this->be($this->user); } public function test_matches_create_user_profile() { $this->authUser(); $this->databaseTableSetUpForTesting(); $response = $this->call('GET','/matches'); $this->assertViewHas('searchMatches'); $searchMatches = $response->original->getData()['searchMatches']; $this->assertInstanceOf('StdClass', $searchMatches); } protected function databaseTableSetUpForTesting() { $band = new Band($this->bandData()); $this->user->bands()->save($band); $this->profile = $band; $this->associateMatch(); } public function bandData() { return [ 'tab' => 'about', 'alias' => 'Match_band_test_123', 'genres' => 1, 'desired_instruments' => 1, 'bio' => 'String for bio', ]; } public function associateMatch() { $this->matchIds = []; foreach ( range(1, 10 ) as $index) { $matchableProfileId = Band::orderBy(DB::raw('RAND()'))->first()->id; $model = Match::create([ 'date_added' => Carbon\Carbon::now(), 'status' => 'new', 'profile_type' => 'band', 'profile_id' => $this->profile->id, 'match_profile_type' => 'band', 'match_profile_id' => $matchableProfileId ]); $this->matchIds[] = $model->id; } } }