Remove id from Address tests (#1333)
This commit is contained in:
@@ -157,7 +157,6 @@ class ApiAdressesTest extends ApiTestCase
|
||||
|
||||
$response->assertJsonFragment([
|
||||
'object' => 'address',
|
||||
'id' => 1,
|
||||
'name' => 'address name',
|
||||
'country' => [
|
||||
'object' => 'country',
|
||||
@@ -168,14 +167,16 @@ class ApiAdressesTest extends ApiTestCase
|
||||
'street' => 'street',
|
||||
'postal_code' => '12345',
|
||||
]);
|
||||
|
||||
$address_id = $response->json('data.id');
|
||||
$this->assertGreaterThan(0, $address_id);
|
||||
}
|
||||
|
||||
public function test_address_put()
|
||||
{
|
||||
$user = $this->signin();
|
||||
$contact = factory('App\Contact')->create(['account_id' => $user->account->id]);
|
||||
|
||||
$response = $this->json('POST', '/api/addresses', [
|
||||
$address = factory('App\Address')->create([
|
||||
'account_id' => $user->account->id,
|
||||
'contact_id' => $contact->id,
|
||||
'name' => 'address name',
|
||||
@@ -184,12 +185,7 @@ class ApiAdressesTest extends ApiTestCase
|
||||
'country' => 'FR',
|
||||
]);
|
||||
|
||||
$response->assertStatus(201);
|
||||
|
||||
$address_id = $response->json('data.id');
|
||||
$this->assertGreaterThan(0, $address_id);
|
||||
|
||||
$response = $this->json('PUT', '/api/addresses/'.$address_id, [
|
||||
$response = $this->json('PUT', '/api/addresses/'.$address->id, [
|
||||
'contact_id' => $contact->id,
|
||||
'name' => 'address name up',
|
||||
'country' => 'US',
|
||||
@@ -199,7 +195,7 @@ class ApiAdressesTest extends ApiTestCase
|
||||
|
||||
$response->assertJsonFragment([
|
||||
'object' => 'address',
|
||||
'id' => $address_id,
|
||||
'id' => $address->id,
|
||||
'name' => 'address name up',
|
||||
'country' => [
|
||||
'object' => 'country',
|
||||
@@ -210,14 +206,23 @@ class ApiAdressesTest extends ApiTestCase
|
||||
'street' => 'street',
|
||||
'postal_code' => '12345',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('addresses', [
|
||||
'account_id' => $user->account->id,
|
||||
'contact_id' => $contact->id,
|
||||
'id' => $address->id,
|
||||
'name' => 'address name up',
|
||||
'street' => 'street',
|
||||
'postal_code' => '12345',
|
||||
'country' => 'US',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_address_delete()
|
||||
{
|
||||
$user = $this->signin();
|
||||
$contact = factory('App\Contact')->create(['account_id' => $user->account->id]);
|
||||
|
||||
$response = $this->json('POST', '/api/addresses', [
|
||||
$address = factory('App\Address')->create([
|
||||
'account_id' => $user->account->id,
|
||||
'contact_id' => $contact->id,
|
||||
'name' => 'address name',
|
||||
@@ -226,18 +231,19 @@ class ApiAdressesTest extends ApiTestCase
|
||||
'country' => 'FR',
|
||||
]);
|
||||
|
||||
$response->assertStatus(201);
|
||||
|
||||
$address_id = $response->json('data.id');
|
||||
$this->assertGreaterThan(0, $address_id);
|
||||
|
||||
$response = $this->json('DELETE', '/api/addresses/'.$address_id);
|
||||
$response = $this->json('DELETE', '/api/addresses/'.$address->id);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$response->assertJsonFragment([
|
||||
'id' => $address_id,
|
||||
'id' => $address->id,
|
||||
'deleted' => true,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('addresses', [
|
||||
'account_id' => $user->account->id,
|
||||
'contact_id' => $contact->id,
|
||||
'id' => $address->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user