Last active
May 6, 2020 06:44
-
-
Save Sankame/393556a5fb90b37acb7ceddd22860f3f to your computer and use it in GitHub Desktop.
Sample code using Laravel, PHPUnit and Mockery
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
/** | |
* @runInSeparateProcess | |
* @preserveGlobalState disabled | |
*/ | |
public function testEditNormal() | |
{ | |
$this->mock = M::mock('alias:App\Contact')->makePartial(); | |
$this->mock->shouldReceive('find')->once()->with(self::ID)->andReturnUsing(function(){ | |
$contacts = (object)array( | |
'id'=>self::ID, | |
'first_name'=>self::FIRST_NAME, | |
'last_name'=>self::LAST_NAME, | |
'email'=>self::EMAIL, | |
'city'=>self::CITY, | |
'country'=>self::COUNTRY, | |
'job_title'=>self::JOB_TITLE); | |
return $contacts; | |
}); | |
$response = $this->get('/contacts/' . self::ID . '/edit'); | |
$response->assertStatus(200); | |
//Check all values output in the page. | |
$response->assertSee(self::FIRST_NAME); | |
$response->assertSee(self::LAST_NAME); | |
$response->assertSee(self::EMAIL); | |
$response->assertSee(self::CITY); | |
$response->assertSee(self::COUNTRY); | |
$response->assertSee(self::JOB_TITLE); | |
//Check header items in the page. | |
$response->assertSee('First Name:'); | |
$response->assertSee('Last Name:'); | |
$response->assertSee('Email:'); | |
$response->assertSee('City:'); | |
$response->assertSee('Country:'); | |
$response->assertSee('Job Title:'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment