PMCORE-3880 PhpUnit: Error: Call to undefined function factory

This commit is contained in:
Roly Gutierrez
2022-07-21 00:04:21 -04:00
parent 99fa155266
commit 01833eb210
295 changed files with 6494 additions and 4762 deletions

View File

@@ -1,46 +1,82 @@
<?php
use Faker\Generator as Faker;
namespace Database\Factories;
$factory->define(\ProcessMaker\Model\RbacUsers::class, function (Faker $faker) {
return [
'USR_UID' => G::generateUniqueID(),
'USR_USERNAME' => $faker->unique()->userName,
'USR_PASSWORD' => $faker->password,
'USR_FIRSTNAME' => $faker->firstName,
'USR_LASTNAME' => $faker->lastName,
'USR_EMAIL' => $faker->unique()->email,
'USR_DUE_DATE' => $faker->dateTimeInInterval('now', '+1 year')->format('Y-m-d H:i:s'),
'USR_CREATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'),
'USR_UPDATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'),
'USR_STATUS' => $faker->randomElement([0, 1]),
'USR_AUTH_TYPE' => 'MYSQL', // Authentication type, by default is MySQL
'UID_AUTH_SOURCE' => '00000000000000000000000000000000', // When the type is "MYSQL" the value for this field is this...
'USR_AUTH_USER_DN' => '', // Don't required for now
'USR_AUTH_SUPERVISOR_DN' => '' // Don't required for now
];
});
use App\Factories\Factory;
use G;
use Illuminate\Support\Str;
// Create a deleted user
$factory->state(\ProcessMaker\Model\RbacUsers::class, 'deleted', function () {
return [
'USR_USERNAME' => '',
'USR_STATUS' => 0,
'USR_AUTH_TYPE' => '',
'UID_AUTH_SOURCE' => ''
];
});
class RbacUsersFactory extends Factory
{
// Create an active user
$factory->state(\ProcessMaker\Model\RbacUsers::class, 'active', function () {
return [
'USR_STATUS' => 1
];
});
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'USR_UID' => G::generateUniqueID(),
'USR_USERNAME' => $this->faker->unique()->userName,
'USR_PASSWORD' => $this->faker->password,
'USR_FIRSTNAME' => $this->faker->firstName,
'USR_LASTNAME' => $this->faker->lastName,
'USR_EMAIL' => $this->faker->unique()->email,
'USR_DUE_DATE' => $this->faker->dateTimeInInterval('now', '+1 year')->format('Y-m-d H:i:s'),
'USR_CREATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'),
'USR_UPDATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'),
'USR_STATUS' => $this->faker->randomElement([0, 1]),
'USR_AUTH_TYPE' => 'MYSQL', // Authentication type, by default is MySQL
'UID_AUTH_SOURCE' => '00000000000000000000000000000000', // When the type is "MYSQL" the value for this field is this...
'USR_AUTH_USER_DN' => '', // Don't required for now
'USR_AUTH_SUPERVISOR_DN' => '' // Don't required for now
];
}
// Create an inactive user
$factory->state(\ProcessMaker\Model\RbacUsers::class, 'inactive', function () {
return [
'USR_STATUS' => 0
];
});
/**
* Create a deleted user
* @return type
*/
public function deleted()
{
$state = function (array $attributes) {
return [
'USR_USERNAME' => '',
'USR_STATUS' => 0,
'USR_AUTH_TYPE' => '',
'UID_AUTH_SOURCE' => ''
];
};
return $this->state($state);
}
/**
* Create an active user
* @return type
*/
public function active()
{
$state = function (array $attributes) {
return [
'USR_STATUS' => 1
];
};
return $this->state($state);
}
/**
* Create an inactive user
* @return type
*/
public function inactive()
{
$state = function (array $attributes) {
return [
'USR_STATUS' => 0
];
};
return $this->state($state);
}
}