PMCORE-2559
This commit is contained in:
@@ -16,32 +16,71 @@ class AppNotesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Create notes
|
||||
*
|
||||
* @param int
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createCaseNotes($rows = 10)
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
$notes = factory(AppNotes::class, $rows)->states('foreign_keys')->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
|
||||
return $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Review get cases notes related to the case
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppNotes::getNotes()
|
||||
* @test
|
||||
*/
|
||||
public function it_test_get_case_notes()
|
||||
{
|
||||
$appNotes = factory(AppNotes::class)->states('foreign_keys')->create();
|
||||
// Create factories
|
||||
$cases = $this->createCaseNotes();
|
||||
// Create an instance
|
||||
$notes = new AppNotes();
|
||||
$res = $notes->getNotes($appNotes->APP_UID);
|
||||
$res = $notes->getNotes($cases[0]['APP_UID']);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review get total cases notes by cases
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppNotes::getTotal()
|
||||
* @covers \ProcessMaker\Model\AppNotes::scopeAppUid()
|
||||
* @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
|
||||
]);
|
||||
// Create factories
|
||||
$cases = $this->createCaseNotes();
|
||||
// Create an instance
|
||||
$notes = new AppNotes();
|
||||
$total = $notes->getTotal($application->APP_UID);
|
||||
$total = $notes::getTotal($cases[0]['APP_UID']);
|
||||
$this->assertEquals(10, $total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review get total cases notes by cases
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppNotes::total()
|
||||
* @covers \ProcessMaker\Model\AppNotes::scopeAppNumber()
|
||||
* @test
|
||||
*/
|
||||
public function it_test_count_case_notes()
|
||||
{
|
||||
// Create factories
|
||||
$cases = $this->createCaseNotes();
|
||||
// Create an instance
|
||||
$notes = new AppNotes();
|
||||
$total = $notes::total($cases[0]['APP_NUMBER']);
|
||||
$this->assertEquals(10, $total);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use G;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Process;
|
||||
@@ -49,6 +50,18 @@ class ApplicationTest extends TestCase
|
||||
$this->assertInstanceOf(User::class, $application->creatoruser);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if return the columns used
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Application::scopeStatusId()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_cases_by_status_id()
|
||||
{
|
||||
$table = factory(Application::class)->create();
|
||||
$this->assertCount(1, $table->statusId($table->APP_STATUS_ID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if return the columns used
|
||||
*
|
||||
@@ -81,6 +94,24 @@ class ApplicationTest extends TestCase
|
||||
$this->assertArrayHasKey('APP_INIT_USER', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This review if get the case number
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Application::getCaseNumber()
|
||||
* @test
|
||||
*/
|
||||
public function it_get_case_number()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
$result = Application::getCaseNumber($application->APP_UID);
|
||||
// When the application exist
|
||||
$this->assertEquals($result, $application->APP_NUMBER);
|
||||
// When the application does not exist
|
||||
$appFake = G::generateUniqueID();
|
||||
$result = Application::getCaseNumber($appFake);
|
||||
$this->assertEquals($result, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the columns was updated correctly
|
||||
*
|
||||
@@ -110,4 +141,20 @@ class ApplicationTest extends TestCase
|
||||
$this->assertArrayHasKey('APP_CUR_USER', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count cases per process
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Application::getCountByProUid()
|
||||
* @covers \ProcessMaker\Model\Application::scopeProUid()
|
||||
* @covers \ProcessMaker\Model\Application::scopeStatusId()
|
||||
* @covers \ProcessMaker\Model\Application::scopePositivesCases()
|
||||
* @test
|
||||
*/
|
||||
public function it_count_cases_by_process()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
factory(Application::class, 5)->create(['PRO_UID' => $process->PRO_UID]);
|
||||
$result = Application::getCountByProUid($process->PRO_UID);
|
||||
$this->assertEquals($result, 5);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user