-
-
Save deivide/b147669a29edde48843a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MatchesControllerTest extends TestCase | |
{ | |
protected $user; | |
protected $profile; | |
public function setUp() | |
{ | |
parent::setUp(); | |
DB::beginTransaction(); | |
} | |
public function tearDown() | |
{ | |
DB::rollBack(); | |
} | |
public function authUser() | |
{ | |
$this->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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment