| Server IP : 77.68.25.176 / Your IP : 216.73.216.25 Web Server : Apache System : Linux plesk 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 User : dwp ( 10001) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/dazzlingwebplanet.co.uk/indoukhub.dazzlingwebplanet.co.uk/tests/ |
Upload File : |
<?php namespace Tests;
trait ApiTestTrait
{
private $response;
public function assertApiResponse(Array $actualData)
{
$this->assertApiSuccess();
$response = json_decode($this->response->getContent(), true);
$responseData = $response['data'];
$this->assertNotEmpty($responseData['id']);
$this->assertModelData($actualData, $responseData);
}
public function assertApiSuccess()
{
$this->response->assertStatus(200);
$this->response->assertJson(['success' => true]);
}
public function assertModelData(Array $actualData, Array $expectedData)
{
foreach ($actualData as $key => $value) {
if (in_array($key, ['created_at', 'updated_at'])) {
continue;
}
$this->assertEquals($actualData[$key], $expectedData[$key]);
}
}
}