Revert "PMCORE-1542 (pull request #7355)"
This reverts pull request #7355. > PMCORE-1542
This commit is contained in:
@@ -5,8 +5,6 @@ namespace ProcessMaker\BusinessModel;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Documents;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -79,61 +77,4 @@ class CasesTest extends TestCase
|
||||
$case = new Cases();
|
||||
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the upload file related to the case notes, an return an exception when the array is empty
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::uploadFilesInCaseNotes()
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function it_return_exception_in_upload_files_related_case_note()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID
|
||||
]);
|
||||
// Upload the file
|
||||
$case = new Cases();
|
||||
// Return an exception because the files does not exist
|
||||
$case->uploadFilesInCaseNotes('00000000000000000000000000000001', $application->APP_UID, $filesReferences = []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the upload file related to the case notes
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::uploadFilesInCaseNotes()
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_upload_files_related_case_note()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID
|
||||
]);
|
||||
// File reference to upload
|
||||
$filesReferences = [
|
||||
'activityRename.gif' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activity.gif',
|
||||
];
|
||||
// Path of the case
|
||||
$pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . $application->APP_UID . PATH_SEP;
|
||||
// Upload the file
|
||||
$case = new Cases();
|
||||
$result = $case->uploadFilesInCaseNotes('00000000000000000000000000000001', $application->APP_UID, $filesReferences);
|
||||
$result = head($result);
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertArrayHasKey('APP_UID', $result);
|
||||
$this->assertEquals($application->APP_UID, $result['APP_UID']);
|
||||
$this->assertArrayHasKey('APP_DOC_TYPE', $result);
|
||||
$this->assertEquals(Documents::DOC_TYPE_CASE_NOTE, $result['APP_DOC_TYPE']);
|
||||
$this->assertArrayHasKey('APP_DOC_FILENAME', $result);
|
||||
$this->assertEquals('activityRename.gif', $result['APP_DOC_FILENAME']);
|
||||
|
||||
G::rm_dir($pathCase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Documents;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DocumentsTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\Model\Documents
|
||||
*/
|
||||
class DocumentsTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Review get app files related to the case notes
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_get_case_note_files()
|
||||
{
|
||||
$appDoc = factory(Documents::class)->states('case_notes')->create();
|
||||
$doc = new Documents();
|
||||
$res = $doc->getAppFiles($appDoc->APP_UID, Documents::DOC_TYPE_CASE_NOTE);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\src\ProcessMaker\Util\Helpers;
|
||||
|
||||
use G;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SaveAppDocumentTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It test if the file reference was uploaded
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_copy_file_same_name()
|
||||
{
|
||||
$files = [
|
||||
'name' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activate.png',
|
||||
'tmp_name' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activate.png',
|
||||
];
|
||||
$appUid = G::generateUniqueID();
|
||||
$appDocUid = G::generateUniqueID();
|
||||
$pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . G::getPathFromUID($appUid) . PATH_SEP;
|
||||
saveAppDocument($files, $appUid, $appDocUid, 1, false);
|
||||
$this->assertFileExists($pathCase . $appDocUid . '_1.png');
|
||||
G::rm_dir($pathCase);
|
||||
}
|
||||
|
||||
/**
|
||||
* It test if the file reference was uploaded
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_copy_file_different_name()
|
||||
{
|
||||
$files = [
|
||||
'name' => 'activityRename.gif',
|
||||
'tmp_name' => PATH_TRUNK . 'tests' . PATH_SEP . 'resources' . PATH_SEP . 'images' . PATH_SEP . 'activity.gif',
|
||||
];
|
||||
$appUid = G::generateUniqueID();
|
||||
$appDocUid = G::generateUniqueID();
|
||||
$pathCase = PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP . G::getPathFromUID($appUid) . PATH_SEP;
|
||||
saveAppDocument($files, $appUid, $appDocUid, 1, false);
|
||||
$this->assertFileExists($pathCase . $appDocUid . '_1.gif');
|
||||
G::rm_dir($pathCase);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user