* Remove sempro/phpunit-pretty-print * Bump PHPUnit dependencies * Bump nunomaduro/collision and filp/whoops * Update phpunit.xml * Change setUp to protected * Remove --verbose option * Update phpunit.xml * Remove Bootstrap * Add types in tests * Make tests class final * Remove unused variables * Add .phpunit.cache to .gitignore * Apply fixes from StyleCI * Update phpunit.xml * Break tests (to test CI/CD) * Revert "Break tests (to test CI/CD)" This reverts commit 928b199bc4ee09238f83f33cc7c12304992368ab. * Update composer.lock --------- Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
29 lines
733 B
PHP
29 lines
733 B
PHP
<?php
|
|
|
|
trait ApiTestTrait
|
|
{
|
|
public function assertApiResponse(array $actualData): void
|
|
{
|
|
$this->assertApiSuccess();
|
|
|
|
$response = json_decode($this->response->getContent(), true);
|
|
$responseData = $response['data'];
|
|
|
|
$this->assertNotEmpty($responseData['id']);
|
|
$this->assertModelData($actualData, $responseData);
|
|
}
|
|
|
|
public function assertApiSuccess(): void
|
|
{
|
|
$this->assertResponseOk();
|
|
$this->seeJson(['success' => true]);
|
|
}
|
|
|
|
public function assertModelData(array $actualData, array $expectedData): void
|
|
{
|
|
foreach ($actualData as $key => $value) {
|
|
$this->assertEquals($actualData[$key], $expectedData[$key]);
|
|
}
|
|
}
|
|
}
|