HEX
Server: LiteSpeed
System: Linux premium260.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: aliazzsr (627)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/aliazzsr/api.crm.vqode.com/tests/api/CompanyContactCreateCept.php
<?php

$I = new ApiTester($scenario);

$I->wantTo('create companies and see result');

$I->login();

$I->comment('creating a new company contact successfully');
$faker = \Faker\Factory::create();
$influencers = array_map('intval', $I->grabColumnFromDatabase('influencer', 'id'));
$companies = array_map('intval', $I->grabColumnFromDatabase('company', 'id'));
$dataToLoad = [
    'company_id' => $faker->randomElement($companies),
    'name' => $faker->name,
    'surname' => $faker->lastName,
    'job_title' => $faker->jobTitle,
    'salutation' => $faker->name,
    'email' => $faker->email,
    'mobile' => $faker->phoneNumber,
    'phone' => $faker->phoneNumber,
    'notes' => $faker->text,
    'influencer_id' => $faker->randomElement($influencers),
    'linkedin' => $faker->randomElement([false, true]),
    'reltype_id' => $I->fake()->randomElement(\app\models\enums\CompanyContactRelType::getConstantsByName()),
];
$I->sendPOST('company-contacts', $dataToLoad);
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::CREATED);
$I->seeResponseIsJson();
$I->seeResponseContainsJson($dataToLoad);
$I->seeResponseJsonMatchesJsonPath('$.id');
$I->seeResponseJsonMatchesJsonPath('$.reltype_id');

$I->seeInDatabase('company_contact', $dataToLoad);

$I->comment('validating new company contact');
$dataToLoad = [
    'name' => $faker->name,
];
$I->sendPOST('companies', $dataToLoad);
$I->seeResponseCodeIs(\Codeception\Util\HttpCode::UNPROCESSABLE_ENTITY);