Merged in bugfix/PMCORE-1651 (pull request #7383)
PMCORE-1651 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppNotes;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class AppNotesTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\Model\AppNotes
|
||||
*/
|
||||
class AppNotesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Review get cases notes related to the case
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_get_case_notes()
|
||||
{
|
||||
$appNotes = factory(AppNotes::class)->states('foreign_keys')->create();
|
||||
$notes = new AppNotes();
|
||||
$res = $notes->getNotes($appNotes->APP_UID);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review get total cases notes by cases
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_get_total_case_notes()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
$appNotes = factory(AppNotes::class, 10)->states('foreign_keys')->create([
|
||||
'APP_UID' => $application->APP_UID
|
||||
]);
|
||||
$notes = new AppNotes();
|
||||
$total = $notes->getTotal($application->APP_UID);
|
||||
$this->assertEquals(10, $total);
|
||||
}
|
||||
}
|
||||
@@ -117,6 +117,7 @@ class AppProxy extends HttpProxyController
|
||||
|
||||
// Get the notes
|
||||
$appNote = new Notes();
|
||||
$total = $appNote->getTotal($appUid);
|
||||
$response = $appNote->getNotes($appUid, $httpData->start, $httpData->limit);
|
||||
$response = AppNotes::applyHtmlentitiesInNotes($response);
|
||||
|
||||
@@ -128,6 +129,8 @@ class AppProxy extends HttpProxyController
|
||||
$response['notes'][$iterator]['attachments'] = $documents->getFiles($value['NOTE_ID']);
|
||||
$iterator++;
|
||||
}
|
||||
// Get the total of cases notes by case
|
||||
$response['totalCount'] = $total;
|
||||
|
||||
require_once("classes/model/Application.php");
|
||||
$application = new Application();
|
||||
|
||||
@@ -98,9 +98,22 @@ class AppNotes extends Model
|
||||
$notes['notes'][] = $row;
|
||||
});
|
||||
|
||||
// Add the total of rows to return
|
||||
$notes['totalCount'] = $limit;
|
||||
|
||||
return $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total notes by case
|
||||
*
|
||||
* @param string $appUid
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getTotal(string $appUid)
|
||||
{
|
||||
$query = AppNotes::query()->select(['NOTE_ID']);
|
||||
$query->appUid($appUid);
|
||||
$total = $query->get()->count();
|
||||
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user