Do it like this.
$this->disableCookieEncryption();
$cookies = ['api-token' => 'e3ef09fa9434e65837193bd77ca7b281c6847f8b8554fe48d98694e3c7e40dc8'];
$response = $this->call('POST', route('user.register'), $record, $cookies);
public function testRegisterUserSuccess()
{
$this->faker = Factory::create();
$data = [
User::FAMILY_NAME => $this->faker->randomElement(['ド','ダオ']),
User::GIVEN_NAME => $this->faker->randomElement(['アイン', 'ウイアン']),
User::FAMILY_NAME_KANA => $this->faker->randomElement(['ド','ダオ']),
User::GIVEN_NAME_KANA =>$this->faker->randomElement(['アイン', 'ウイアン']),
User::WORK_PREFECTURE_ID => 1,
User::WORK_PREFECTURE_PUBLISH_TYPE => 'PRIVATE',
User::SOCIETY_TYPE => 'student',
User::SOCIETY_PUBLISH_TYPE => 'private',
User::LANGUAGE => 'jp',
User::NICK_NAME => 'uyen',
User::IS_MAIL_RECEIVABLED => 1,
User::WORK_ORGANIZATION_NAME => 'TakajouRei',
User::WORK_CORPORATE_NUMBER => 1000,
];
$record = [
'family_name'=>'anh',
'given_name_kana'=>'ダオ',
'family_name_kana'=>'ダオ',
'profile_publish_type'=>'private',
'work_prefecture_id'=>1000,
'work_prefecture_publish_type'=> 'private',
'work_organization_name'=> 'asdasda',
'given_name'=>'sada',
'society_type'=>'student',
'society_publish_type'=> 'asda',
'language'=> 'VI',
'nick_name'=>'asd',
'is_mail_receivabled'=>1,
'work_corporate_number'=> 1000
];
// dd($data);
$cookie = Cookie('api-token','e3ef09fa9434e65837193bd77ca7b281c6847f8b8554fe48d98694e3c7e40dc8');
$response = $this->call('POST',route('user.register'),$record,$cookie);
// $response = $this->postJson(route('user.register'),$record)->withCookie('api-token','e3ef09fa9434e65837193bd77ca7b281c6847f8b8554fe48d98694e3c7e40dc8');
$response->assertStatus(200);
$response->assertJsonStructure([
'api_version',
'data'=>['user_id'],
]);
}
thanks for help guys
and this is log error from CMD
vendor/bin/phpunit --filter=testRegisterUserSuccess
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 129 ms, Memory: 18.00 MB
There was 1 error:
1) Tests\Feature\Apis\ApiRegisterUserTest::testRegisterUserSuccess
TypeError: Argument 4 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory() must be of the type array, object given, called in /home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php on line 410
/home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php:1976
/home/ket/Desktop/gcode/vendor/symfony/http-foundation/Request.php:410
/home/ket/Desktop/gcode/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:464
/home/ket/Desktop/gcode/tests/Feature/Apis/ApiRegisterUserTest.php:64
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
Please or to participate in this conversation.