Skip to content

Commit

Permalink
New tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlesRuizDeveloper committed Jun 10, 2024
1 parent c9ecd37 commit b2e8096
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/Feature/TermsAndConditionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,31 @@ public function testTermsResponseHasJsonHeader()

$response->assertHeader('Content-Type', 'application/json');
}

// Nuevos tests adicionales
public function testTermsServiceThrowsException()
{
// Simula una excepción en el servicio
$this->mock(\App\Services\TermsAndConditionsService::class, function ($mock) {
$mock->shouldReceive('getTermsAndConditions')->andThrow(new \Exception('Test exception'));
});

$response = $this->getJson(route('terms-and-conditions'));

$response->assertStatus(500);
$response->assertJsonStructure(['error', 'message']);
}

public function testTermsServiceReturnsCustomContent()
{
// Simula un contenido diferente en el servicio
$this->mock(\App\Services\TermsAndConditionsService::class, function ($mock) {
$mock->shouldReceive('getTermsAndConditions')->andReturn('Custom content for testing');
});

$response = $this->getJson(route('terms-and-conditions'));

$response->assertStatus(200);
$response->assertJson(['content' => 'Custom content for testing']);
}
}

0 comments on commit b2e8096

Please sign in to comment.