Skip to content

Commit

Permalink
test(feature): add test for updating the user
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Dec 3, 2023
1 parent 39c1d33 commit f0b3616
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions t/Feature/Resource/UserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Tests\Feature\Resource;

use Throwable;

use CodeIgniter\Test\Fabricator;
use Faker\Factory;

use App\Exceptions\InvalidRequest;
use App\Exceptions\MissingResource;
use App\Models\CurrencyModel;
use Tests\Feature\Helper\AuthenticatedHTTPTestCase;

class UserTest extends AuthenticatedHTTPTestCase
{
public function testDefaultUpdate()
{
$authenticated_info = $this->makeAuthenticatedInfo();

$faker = Factory::create();
$password = $faker->password();
$user_data = [
"email" => $faker->email(),
"username" => $faker->userName()
];

$result = $authenticated_info
->getRequest()
->withBodyFormat("json")
->patch("/api/v1/user", [
"user" => $user_data
]);

$result->assertStatus(204);
$tableNames = config("Auth")->tables;
$this->seeInDatabase($tableNames["users"], [
"id" => $authenticated_info->getUser()->id,
"username" => $user_data["username"]
]);
$this->seeInDatabase($tableNames["identities"], [
"user_id" => $authenticated_info->getUser()->id,
"secret" => $user_data["email"]
]);
}
}

0 comments on commit f0b3616

Please sign in to comment.