Merged in bugfix/PMCORE-2636 (pull request #7677)
PMCORE-2636 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -67,6 +67,15 @@ $factory->state(\ProcessMaker\Model\Application::class, 'foreign_keys', function
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(\ProcessMaker\Model\Application::class, 'web_entry', function (Faker $faker) {
|
||||
$appNumber = $faker->unique()->numberBetween(5000);
|
||||
return [
|
||||
'APP_NUMBER' => $appNumber * -1,
|
||||
'APP_STATUS_ID' => 2,
|
||||
'APP_STATUS' => 'TO_DO'
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(\ProcessMaker\Model\Application::class, 'todo', function (Faker $faker) {
|
||||
return [
|
||||
'APP_NUMBER' => $faker->unique()->numberBetween(1000),
|
||||
|
||||
@@ -86,6 +86,51 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
|
||||
];
|
||||
});
|
||||
|
||||
// Create a delegation with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\Delegation::class, 'web_entry', function (Faker $faker) {
|
||||
// Create values in the foreign key relations
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$category = factory(\ProcessMaker\Model\ProcessCategory::class)->create();
|
||||
$process = factory(\ProcessMaker\Model\Process::class)->create([
|
||||
'PRO_CATEGORY' => $category->CATEGORY_UID,
|
||||
'CATEGORY_ID' => $category->CATEGORY_ID
|
||||
]);
|
||||
$task = factory(\ProcessMaker\Model\Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
$application = factory(\ProcessMaker\Model\Application::class)->states('web_entry')->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
|
||||
// Return with default values
|
||||
return [
|
||||
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => 1,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'DEL_TYPE' => 'NORMAL',
|
||||
'DEL_THREAD' => 1,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PRIORITY' => 3,
|
||||
'DEL_DELEGATE_DATE' => $faker->dateTime(),
|
||||
'DEL_INIT_DATE' => $faker->dateTime(),
|
||||
'DEL_TASK_DUE_DATE' => $faker->dateTime(),
|
||||
'DEL_RISK_DATE' => $faker->dateTime(),
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_DATA' => '',
|
||||
'DEL_TITLE' => $faker->word()
|
||||
];
|
||||
});
|
||||
|
||||
// Create a open delegation
|
||||
$factory->state(\ProcessMaker\Model\Delegation::class, 'open', function (Faker $faker) {
|
||||
// Create dates with sense
|
||||
|
||||
@@ -238,6 +238,27 @@ class SearchTest extends TestCase
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests web entry with negative appNumbers
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_web_entry_not_submitted()
|
||||
{
|
||||
// Create factories related to the delegation cases
|
||||
$cases = $this->createSearch();
|
||||
$casesNotSubmitted = factory(Delegation::class, 5)->states('web_entry')->create();
|
||||
// Create new Search object
|
||||
$search = new Search();
|
||||
// Set order by column value
|
||||
$search->setOrderByColumn('APP_NUMBER');
|
||||
$result = $search->getData();
|
||||
// Review if the cases not submitted are not considered
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertEquals(count($result) , count($cases));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getCounter method
|
||||
*
|
||||
|
||||
@@ -162,6 +162,8 @@ class Search extends AbstractCases
|
||||
$query->groupBy('APP_NUMBER');
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Exclude the web entries does not submitted */
|
||||
$query->positiveCases($query);
|
||||
/** Apply order and pagination */
|
||||
// The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
|
||||
@@ -455,6 +455,18 @@ class Delegation extends Model
|
||||
return $query->where('APP_DELEGATION.APP_NUMBER', '<=', $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for query to get the positive cases for avoid the web entry
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePositiveCases($query)
|
||||
{
|
||||
return $query->where('APP_DELEGATION.APP_NUMBER', '>', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope more than one range of cases
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user