-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,4 +379,35 @@ public function test_who_to_folow() | |
] | ||
]); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_allows_authorized_users_to_use_the_add_feedback_feature(): void | ||
{ | ||
$choices = ['still-thinking', 'probably', 'very-likely']; | ||
$choice = $choices[array_rand($choices)]; | ||
|
||
$user = User::factory()->make([ | ||
'email' => '[email protected]', | ||
'password' => (new BcryptHasher)->make('pass123'), | ||
]); | ||
$user->save(); | ||
|
||
$bearerToken = Auth::attempt([ | ||
'email' => '[email protected]', | ||
'password' => 'pass123' | ||
]); | ||
|
||
$this->json( | ||
'POST', | ||
'/api/v1/feedback', | ||
[ | ||
'choice' => $choice | ||
], | ||
[ | ||
'Authorization' => 'Bearer ' . $bearerToken | ||
] | ||
)->assertStatus(200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Unit; | ||
|
||
use App\Http\Controllers\DefinitionsController; | ||
use App\Http\Controllers\StaticContentController; | ||
use App\Models\Definition; | ||
|
||
class StaticContentsTest extends \TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_returns_definitions_data() | ||
{ | ||
$this->seed('Database\\Seeders\\DefinitionsSeeder'); | ||
$controller = new DefinitionsController(); | ||
|
||
$definitions = $controller->index(); | ||
$this->assertNotEmpty($definitions->all()); | ||
|
||
$definitions->map(function ($defintion) { | ||
$this->assertInstanceOf(Definition::class, $defintion); | ||
}); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_returns_static_contents_data() | ||
{ | ||
$this->seed('Database\Seeders\StaticContentsSeeder'); | ||
$controller = new StaticContentController(); | ||
|
||
$staticContents = $controller->get(); | ||
$decoded = json_decode($staticContents->getContent(), true); | ||
|
||
$this->assertArrayHasKey('cookiePolicy', $decoded['response']); | ||
$this->assertArrayHasKey('usagePolicy', $decoded['response']); | ||
$this->assertArrayHasKey('dataRetentionPolicy', $decoded['response']); | ||
$this->assertArrayHasKey('termsAndConditions', $decoded['response']); | ||
} | ||
} |