Suppress PHPMD messages and make sure to use route() [skip ci]

This commit is contained in:
James Cole 2019-06-09 09:39:56 +02:00
parent 57cfd7e3bc
commit a1929b0521
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
16 changed files with 93 additions and 45 deletions

View File

@ -33,6 +33,9 @@ use Tests\TestCase;
/** /**
* Class AccountControllerTest * Class AccountControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class AccountControllerTest extends TestCase class AccountControllerTest extends TestCase
{ {

View File

@ -35,6 +35,9 @@ use Tests\TestCase;
/** /**
* *
* Class AttachmentControllerTest * Class AttachmentControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class AttachmentControllerTest extends TestCase class AttachmentControllerTest extends TestCase
{ {

View File

@ -38,6 +38,9 @@ use Tests\TestCase;
/** /**
* *
* Class AvailableBudgetControllerTest * Class AvailableBudgetControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class AvailableBudgetControllerTest extends TestCase class AvailableBudgetControllerTest extends TestCase
{ {

View File

@ -33,6 +33,9 @@ use Tests\TestCase;
/** /**
* Class BillControllerTest * Class BillControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class BillControllerTest extends TestCase class BillControllerTest extends TestCase
{ {

View File

@ -44,6 +44,9 @@ use Tests\TestCase;
/** /**
* *
* Class BudgetControllerTest * Class BudgetControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class BudgetControllerTest extends TestCase class BudgetControllerTest extends TestCase
{ {

View File

@ -43,6 +43,9 @@ use Tests\TestCase;
/** /**
* *
* Class BudgetLimitControllerTest * Class BudgetLimitControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class BudgetLimitControllerTest extends TestCase class BudgetLimitControllerTest extends TestCase
{ {

View File

@ -42,6 +42,9 @@ use Tests\TestCase;
/** /**
* *
* Class CategoryControllerTest * Class CategoryControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class CategoryControllerTest extends TestCase class CategoryControllerTest extends TestCase
{ {

View File

@ -60,6 +60,9 @@ use Tests\TestCase;
/** /**
* Class CurrencyControllerTest * Class CurrencyControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class CurrencyControllerTest extends TestCase class CurrencyControllerTest extends TestCase
{ {
@ -108,7 +111,7 @@ class CurrencyControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/currencies', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.currencies.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]); $response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
@ -153,7 +156,7 @@ class CurrencyControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/currencies', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.currencies.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]); $response->assertJson(['data' => ['type' => 'currencies', 'links' => true],]);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');

View File

@ -35,6 +35,9 @@ use Tests\TestCase;
/** /**
* *
* Class LinkTypeControllerTest * Class LinkTypeControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class LinkTypeControllerTest extends TestCase class LinkTypeControllerTest extends TestCase
{ {
@ -85,7 +88,7 @@ class LinkTypeControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/link_types', $data); $response = $this->post(route('api.v1.link_types.store'), $data);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
} }
@ -115,7 +118,7 @@ class LinkTypeControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/link_types', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.link_types.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(500); $response->assertStatus(500);
$response->assertSee('You need the \"owner\"-role to do this.'); $response->assertSee('You need the \"owner\"-role to do this.');
} }

View File

@ -37,6 +37,9 @@ use Tests\TestCase;
/** /**
* *
* Class PiggyBankControllerTest * Class PiggyBankControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class PiggyBankControllerTest extends TestCase class PiggyBankControllerTest extends TestCase
{ {
@ -81,7 +84,7 @@ class PiggyBankControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/piggy_banks/', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.piggy_banks.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertJson(['data' => ['type' => 'piggy_banks', 'links' => true],]); $response->assertJson(['data' => ['type' => 'piggy_banks', 'links' => true],]);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
@ -109,7 +112,7 @@ class PiggyBankControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/piggy_banks/', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.piggy_banks.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(500); $response->assertStatus(500);
$response->assertHeader('Content-Type', 'application/json'); $response->assertHeader('Content-Type', 'application/json');
$response->assertSee('Could not store new piggy bank.'); $response->assertSee('Could not store new piggy bank.');

View File

@ -34,6 +34,9 @@ use Tests\TestCase;
/** /**
* *
* Class PreferencesControllerTest * Class PreferencesControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class PreferencesControllerTest extends TestCase class PreferencesControllerTest extends TestCase
{ {

View File

@ -41,6 +41,9 @@ use Tests\TestCase;
/** /**
* *
* Class RecurrenceControllerTest * Class RecurrenceControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class RecurrenceControllerTest extends TestCase class RecurrenceControllerTest extends TestCase
{ {
@ -116,7 +119,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
} }
@ -183,7 +186,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
} }
@ -251,7 +254,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
@ -321,7 +324,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
@ -392,7 +395,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
} }
@ -452,7 +455,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -521,7 +524,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -587,7 +590,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -655,7 +658,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -723,7 +726,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -788,7 +791,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -853,7 +856,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -919,7 +922,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -985,7 +988,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1050,7 +1053,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1122,7 +1125,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1191,7 +1194,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1253,7 +1256,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1306,7 +1309,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertExactJson( $response->assertExactJson(
[ [
'message' => 'The given data was invalid.', 'message' => 'The given data was invalid.',
@ -1387,7 +1390,7 @@ class RecurrenceControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/recurrences', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.recurrences.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');

View File

@ -36,6 +36,9 @@ use Tests\TestCase;
/** /**
* Class TagControllerTest * Class TagControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class TagControllerTest extends TestCase class TagControllerTest extends TestCase
{ {

View File

@ -39,6 +39,9 @@ use Tests\TestCase;
/** /**
* Class TransactionControllerTest * Class TransactionControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class TransactionControllerTest extends TestCase class TransactionControllerTest extends TestCase
{ {
@ -93,7 +96,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -148,7 +151,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -203,7 +206,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -257,7 +260,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -311,7 +314,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -372,7 +375,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -410,7 +413,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -473,7 +476,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -537,7 +540,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -604,7 +607,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [
@ -686,7 +689,7 @@ class TransactionControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transactions', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transactions.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertExactJson( $response->assertExactJson(
[ [

View File

@ -39,6 +39,9 @@ use Tests\TestCase;
/** /**
* *
* Class TransactionLinkControllerTest * Class TransactionLinkControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class TransactionLinkControllerTest extends TestCase class TransactionLinkControllerTest extends TestCase
{ {
@ -100,7 +103,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data); $response = $this->post(route('api.v1.transaction_links.store'), $data);
$response->assertStatus(200); $response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json'); $response->assertHeader('Content-Type', 'application/vnd.api+json');
} }
@ -152,7 +155,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertSee('Already have a link between inward and outward.'); $response->assertSee('Already have a link between inward and outward.');
@ -207,7 +210,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
$response->assertSee('Invalid inward ID.'); // the creation moment. $response->assertSee('Invalid inward ID.'); // the creation moment.
$response->assertStatus(422); $response->assertStatus(422);
$response->assertHeader('Content-Type', 'application/json'); $response->assertHeader('Content-Type', 'application/json');
@ -260,7 +263,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
$response->assertSee('Invalid outward ID.'); $response->assertSee('Invalid outward ID.');
$response->assertStatus(422); $response->assertStatus(422);
$response->assertHeader('Content-Type', 'application/json'); $response->assertHeader('Content-Type', 'application/json');
@ -312,7 +315,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(500); $response->assertStatus(500);
$response->assertSee('Source or destination is NULL.'); // the creation moment. $response->assertSee('Source or destination is NULL.'); // the creation moment.
$response->assertHeader('Content-Type', 'application/json'); $response->assertHeader('Content-Type', 'application/json');
@ -362,7 +365,7 @@ class TransactionLinkControllerTest extends TestCase
]; ];
// test API // test API
$response = $this->post('/api/v1/transaction_links', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.transaction_links.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertSee('Invalid inward ID.'); // error message $response->assertSee('Invalid inward ID.'); // error message
$response->assertHeader('Content-Type', 'application/json'); $response->assertHeader('Content-Type', 'application/json');

View File

@ -35,6 +35,9 @@ use Tests\TestCase;
/** /**
* Class UserControllerTest * Class UserControllerTest
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/ */
class UserControllerTest extends TestCase class UserControllerTest extends TestCase
{ {
@ -76,7 +79,7 @@ class UserControllerTest extends TestCase
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]); $transformer->shouldReceive('transform')->atLeast()->once()->andReturn(['id' => 5]);
// test API // test API
$response = $this->post('/api/v1/users', $data, ['Content-Type' => 'application/x-www-form-urlencoded']); $response = $this->post(route('api.v1.users.store'), $data, ['Content-Type' => 'application/x-www-form-urlencoded']);
$response->assertStatus(200); $response->assertStatus(200);
} }
@ -129,7 +132,7 @@ class UserControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->twice()->andReturn(true); $userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->twice()->andReturn(true);
// test API // test API
$response = $this->post('/api/v1/users', $data, ['Accept' => 'application/json']); $response = $this->post(route('api.v1.users.store'), $data, ['Accept' => 'application/json']);
$response->assertStatus(422); $response->assertStatus(422);
$response->assertExactJson( $response->assertExactJson(
[ [