Skip to content

Commit

Permalink
Merge pull request #6 from open-source-contributions/improve_assertions
Browse files Browse the repository at this point in the history
Improve PHPUnit assertions
  • Loading branch information
ssi-anik committed Oct 31, 2021
2 parents f3c0a14 + b8c18e5 commit ccc8253
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/FormRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testValidationExceptionWithMessageAndStatusCode()
'status_code' => 400,
])->seeStatusCode(400)->response->getData(true);
$this->assertIsString($response['message']);
$this->assertTrue($response['message'] == 'This should be error message');
$this->assertSame('This should be error message', $response['message']);
}

public function testValidationPasses()
Expand All @@ -66,10 +66,10 @@ public function testValidationPasses()
])->seeStatusCode(200)->response->getContent();
$response = json_decode($response, true);

$this->assertTrue($response['all']['extra'] == 'data');
$this->assertSame('data', $response['all']['extra']);
$this->assertIsArray($response['route_info']);
$this->assertTrue('testing' === $response['param'], 'Found value: ' . $response['param']);
$this->assertTrue(count($response['validated']) == 2, 'More than 2 is returned in the validated field');
$this->assertSame('testing', $response['param'], 'Found value: ' . $response['param']);
$this->assertCount(2, $response['validated'], 'More than 2 is returned in the validated field');
}

public function testAuthorizationForRequest()
Expand All @@ -80,14 +80,14 @@ public function testAuthorizationForRequest()
public function testMessages()
{
$response = $this->post('form-request', ['age' => 'age', 'message' => true])->response->getData(true);
$this->assertTrue('The age must be a number value' === $response['errors']['age'][0]);
$this->assertSame('The age must be a number value', $response['errors']['age'][0]);
}

public function testAttributes()
{
$response = $this->post('form-request', ['age' => 'age', 'attribute' => true])->response->getData(true);

$this->assertTrue('The oldness must be a number.' === $response['errors']['age'][0]);
$this->assertSame('The oldness must be a number.', $response['errors']['age'][0]);
}

public function testErrorResponse()
Expand Down

0 comments on commit ccc8253

Please sign in to comment.