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);