2020-06-16 11:24:32 -04:00
|
|
|
<?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;
|
|
|
|
|
|
2020-12-16 17:47:42 -04:00
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-16 11:24:32 -04:00
|
|
|
/**
|
|
|
|
|
* Review get cases notes related to the case
|
|
|
|
|
*
|
2020-12-16 17:47:42 -04:00
|
|
|
* @covers \ProcessMaker\Model\AppNotes::getNotes()
|
2020-06-16 11:24:32 -04:00
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_test_get_case_notes()
|
|
|
|
|
{
|
2020-12-16 17:47:42 -04:00
|
|
|
// Create factories
|
|
|
|
|
$cases = $this->createCaseNotes();
|
|
|
|
|
// Create an instance
|
2020-06-16 11:24:32 -04:00
|
|
|
$notes = new AppNotes();
|
2020-12-16 17:47:42 -04:00
|
|
|
$res = $notes->getNotes($cases[0]['APP_UID']);
|
2020-06-16 11:24:32 -04:00
|
|
|
$this->assertNotEmpty($res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review get total cases notes by cases
|
|
|
|
|
*
|
2020-12-16 17:47:42 -04:00
|
|
|
* @covers \ProcessMaker\Model\AppNotes::getTotal()
|
|
|
|
|
* @covers \ProcessMaker\Model\AppNotes::scopeAppUid()
|
2020-06-16 11:24:32 -04:00
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_test_get_total_case_notes()
|
|
|
|
|
{
|
2020-12-16 17:47:42 -04:00
|
|
|
// Create factories
|
|
|
|
|
$cases = $this->createCaseNotes();
|
|
|
|
|
// Create an instance
|
|
|
|
|
$notes = new AppNotes();
|
|
|
|
|
$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
|
2020-06-16 11:24:32 -04:00
|
|
|
$notes = new AppNotes();
|
2020-12-16 17:47:42 -04:00
|
|
|
$total = $notes::total($cases[0]['APP_NUMBER']);
|
2020-06-16 11:24:32 -04:00
|
|
|
$this->assertEquals(10, $total);
|
|
|
|
|
}
|
|
|
|
|
}
|