Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Daniel Rojas
2014-04-08 09:45:41 -04:00
15 changed files with 643 additions and 69 deletions

View File

@@ -0,0 +1,72 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category
Requirements:
a workspace with the workspace with one process category
Background:
Given that I have a valid access_token
Scenario: Get list of Categories
Given I request "categories"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 1 records
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
Scenario: Create a new Categories
Given POST this data:
"""
{
"cat_name": "Test new Category"
}
"""
And I request "category"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "cat_uid" in session array as variable "cat_uid"
Scenario: Get list of Categories
Given I request "categories"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 2 records
Scenario: Update the Category created in this script
Given PUT this data:
"""
{
"cat_name": "Name Updated"
}
"""
And that I want to update a resource with the key "cat_uid" stored in session array
And I request "category"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Scenario: Delete the Category created previously in this script
Given that I want to delete a resource with the key "cat_uid" stored in session array
And I request "category"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"

View File

@@ -0,0 +1,139 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category Main Test
Requirements:
a workspace with the workspace with one process category
Background:
Given that I have a valid access_token
Scenario: Get list of Categories
Given I request "categories"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 1 records
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the "cat_uid" property equals "4177095085330818c324501061677193"
And the "cat_name" property equals "Category Cases Lists"
And the "cat_total_processes" property equals 5
Scenario Outline: Create a new Categories
Given POST this data:
"""
{
"cat_name": "<cat_name>"
}
"""
And I request "category"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
And store "cat_uid" in session array as variable "cat_uid_<cat_uid_number>"
Examples:
| test_description | cat_uid_number | cat_name |
| Create new Category with character special | 1 | sample!@#$%^^& |
| Create new Category with only character numeric | 2 | 32425325 |
| Create new Category with only character special | 3 | @$@$#@% |
| Create new Category with normal character | 4 | sample |
Scenario: Get list of Categories
Given I request "categories"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the response has 5 records
Scenario: Create Category with same name
Given POST this data:
"""
{
"cat_name": "sample"
}
"""
And I request "category"
Then the response status code should be 400
And the response status message should have the following text "Duplicate"
Scenario Outline: Update the Category created in this script
Given PUT this data:
"""
{
"cat_name": "cat_name"
}
"""
And I request "category/cat_uid" with the key "cat_uid" stored in session array as variable "cat_uid_<cat_uid_number>"
And store "cat_uid" in session array as variable "cat_uid_<cat_uid_number>"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
Examples:
| test_description | cat_uid_number | cat_name |
| Update Category | 1 | UPDATE sample!@#$%^^& |
| Update Category | 2 | UPDATE 32425325 |
Scenario Outline: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the "cat_name" property equals "UPDATE sample!@#$%^^&"
And the "cat_total_processes" property equals 0
Examples:
| cat_uid_number | cat_name | cat_total_processes |
| 1 | UPDATE sample!@#$%^^& | 0 |
| 2 | UPDATE 32425325 | 0 |
Scenario Outline: Delete the Category created previously in this script
Given that I want to delete a resource with the key "cat_uid" stored in session array as variable "cat_uid_<cat_uid_number>"
And I request "category"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Examples:
| cat_uid_number |
| 1 |
| 2 |
| 3 |
| 4 |
Scenario: Get a Category specific
Given I request "category/4177095085330818c324501061677193"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "array"
And the "cat_uid" property equals "4177095085330818c324501061677193"
And the "cat_name" property equals "Category Cases Lists"
And the "cat_total_processes" property equals 5

View File

@@ -0,0 +1,23 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Process Category Negative Tests
Background:
Given that I have a valid access_token
Scenario Outline: Create a new Categories (Negative Test)
Given POST this data:
"""
{
"cat_name": "<cat_name>"
}
"""
And I request "category"
Then the response status code should be <error_code>
And the response status message should have the following text "<error_message>"
Examples:
| test_description | cat_name | error_code | error_message |
| without name | | 400 | cat_name |

View File

@@ -22,9 +22,9 @@ Scenario Outline: Create a new case (Negative Test)
Examples:
| Description | pro_uid | tas_uid | error_code | error_message |
| Create new case with pro_uid wrong | 99209594750ec1111111927000421575 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with task_uid wrong | 46279907250ec73b9b25a78031279680 | 99371337811111111111116024620271 | 400 | task_uid |
| Create new case with tas_uid wrong | 46279907250ec73b9b25a78031279680 | 99371337811111111111116024620271 | 400 | tas_uid |
| Create new case without pro_uid | | 52838134750ec7dd0989fc0015625952 | 400 | pro_uid |
| Create new case without tas_uid | 34579467750ec8d55e8b115057818502 | | 400 | task_uid |
| Create new case without tas_uid | 34579467750ec8d55e8b115057818502 | | 400 | tas_uid |
| Create new case whith pro_uid and tas_uid wrong | 8245849601111111181ecc7039804404 | 5690001111111118e4a9243080698854 | 400 | pro_uid |
@@ -34,9 +34,9 @@ Scenario Outline: Create a new case Impersonate (Negative Test)
Given POST this data:
"""
{
"pro_uid": "99209594750ec27ea338927000421575",
"pro_uid": "<pro_uid>",
"usr_uid": "<usr_uid>",
"tas_uid": "68707275350ec281ada1c95068712556",
"tas_uid": "<tas_uid>",
"variables": [{"name": "pruebaQA", "amount":"10400"}]
}
"""
@@ -45,12 +45,12 @@ Scenario Outline: Create a new case Impersonate (Negative Test)
And the response status message should have the following text "<error_message>"
Examples:
| Description | case_number | usr_uid | error_code | error_message |
| Create new case with process "Derivation rules - sequential" - Case Start with chris | 26 | 51049032352d56710347233042615067 | 400 | pro_uid |
| Create new case with process "Derivation rules - evaluation" - Case Start with adam | 27 | 44811996752d567110634a1013636964 | 400 | task_uid |
| Create new case with process "Derivation rules - Parallel" - Case Start with aaron | 28 | 24166330352d56730cdd525035621101 | 400 | pro_uid |
| Create new case with process "Derivation rules - parallel evaluation"- Case Start with jeremiah | 29 | 86677227852d5671f40ba25017213081 | 400 | task_uid |
| Create new case with process "Derivation rules - selection" - Case Start with admin | 30 | 62625000752d5672d6661e6072881167 | 400 | |
| Description | pro_uid | usr_uid | tas_uid | error_code | error_message |
| Create new case with process "Derivation rules - sequential" invalid pro_uid | 99201111111111111138927000421575 | 51049032352d56710347233042615067 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with process "Derivation rules - evaluation" invalid tas_uid | 99209594750ec27ea338927000421575 | 44811996752d567110634a1013636964 | 68707211111111111111111111712556 | 400 | tas_uid |
| Create new case with process "Derivation rules - Parallel" usr_uid | 99209594750ec27ea338927000421575 | 24166331111111111111115035621101 | 68707275350ec281ada1c95068712556 | 400 | usr_uid |
| Create new case with process "Derivation rules - without pro_uid | | 86677227852d5671f40ba25017213081 | 68707275350ec281ada1c95068712556 | 400 | pro_uid |
| Create new case with process "Derivation rules - selection" tas_uid | 99209594750ec27ea338927000421575 | 62625000752d5672d6661e6072881167 | | 400 | tas_uid |
Scenario Outline: Create a case, derivate and cancel. then try do pause or route
@@ -66,6 +66,7 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route
And I request "cases"
Then the response status code should be 200
And store "app_uid" in session array as variable "app_uid_<case_number>"
#Send some variables
And PUT this data:
"""
@@ -116,8 +117,21 @@ Scenario Outline: Create a case, derivate and cancel. then try do pause or route
Then the response status code should be 400
And the response status message should have the following text "<error_message_pause>"
And PUT this data:
"""
{
}
"""
And that I want to delete a resource with the key "app_uid" stored in session array as variable "app_uid_<case_number>"
And I request "cases"
Then the response status code should be 200
And the content type is "application/json"
And the response charset is "UTF-8"
And the type is "object"
Examples:
| Description | case_number | pro_uid | tas_uid | error_message_route | error_message_pause |
| Create new case with process "Derivation rules - sequential" | 1 | 99209594750ec27ea338927000421575 | 68707275350ec281ada1c95068712556 | This case delegation is already closed | This case delegation is already closed |

View File

@@ -9,7 +9,6 @@ Background:
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
the response time should at least be (\d+) milliseconds$/
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
@@ -36,4 +35,11 @@ Scenario: Create a new case note for specified case
And the content type is "application/json"
And the type is "object"
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
#case 125

View File

@@ -12,18 +12,46 @@ Scenario: List of case notes for this case
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "note_content" property in row 0 equals "tercer case note creado desde script"
Scenario: Create a new case note for specified case
Scenario: Get a List of cases notes of a case with paged
Given I request "cases/1185553665335d2e209f723099733152/notes/paged"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
Scenario Outline: Create a new case note for specified case
Given POST this data:
"""
{
"note_content": "tercer case note creado desde script",
"send_email": 1
"note_content": "<note_content>",
"send_email": <send_email>
}
"""
And I request "case/1185553665335d2e209f723099733152/case"
Then the response status code should be 201
And I request "cases/1185553665335d2e209f723099733152/note"
Then the response status code should be 200
And the response charset is "UTF-8"
And the content type is "application/json"
And the type is "object"
Examples:
| test_description | note_content | send_email |
| Create case note with charater special | Test!@#$ %^&*£ | 1 |
| Create case note with 150 chacarters | Este es una prueba con varios caracteres 112334@#$Este es una prueba con varios caracteres 112334@#$Este es una prueba con varios caracteres 112334@#$ | 1 |
| Create case note with character without space | Estaesunapruebasinespaciosentrepalabraslamismadebeseraceptado | 1 |
| Create case note without send mail | Test sin envio de email | 0 |
| Create case normal with character normal | tercer case note creado desde script | 1 |
Scenario: List of case notes for this case
Given I request "cases/1185553665335d2e209f723099733152/notes"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "note_content" property in row 0 equals "tercer case note creado desde script"
And the "note_content" property in row 1 equals "Test sin envio de email"

View File

@@ -21,7 +21,4 @@ Scenario: create a new case note for specified case (Negative Tests)
And the response status message should have the following text "You do not have permission to cases notes"
#case 124

View File

@@ -13,11 +13,11 @@ Scenario: Returns a list of the uploaded documents for a given case
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the response has 5 records
And the response has 9 records
Scenario: Returns an uploaded documents for a given case
Given I request "cases/170220159534214f642abb8058832933/input-document/6075490825331a1c5eebff9015468244"
Given I request "cases/170220159534214f642abb8058832933/input-document/925833635534215b9148a64026212674"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"

View File

@@ -40,19 +40,11 @@ Scenario Outline: Post metadata and then upload documents for a given case
| 4 | /home/wendy/uploadfiles/test.txt | 170220159534214f642abb8058832933 | 68671480353319e5e1dee74089764900 | 19582733053319e304cfa76025663570 | comment 1 |
Scenario Outline: Returns an uploaded documents for a given case
Given I request "cases/<case_uid>/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
Given I request "cases/<case_uid>/input-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
And the "app_doc_uid" property equals "<app_doc_uid>"
And the "app_doc_filename" property equals "<app_doc_filename>"
And the "doc_uid" property equals "<doc_uid>"
And the "app_doc_version" property equals "<app_doc_version>"
And the "app_doc_create_date" property equals "<app_doc_create_date>"
And the "app_doc_create_user" property equals "<app_doc_create_user>"
And the "app_doc_type" property equals "<app_doc_type>"
And the "app_doc_index" property equals "<app_doc_index>"
And the "app_doc_link" property equals "<app_doc_link>"
Examples:

View File

@@ -9,7 +9,7 @@ Background:
Scenario: Returns a list of the uploaded documents for a given case
Given I request "cases/170220159534214f642abb8058832000/input-documents"
Given I request "cases/170220159534214f642abb8058832900/input-documents"
Then the response status code should be 404
Scenario Outline: Post metadata and then upload documents for a given case

View File

@@ -13,14 +13,14 @@ Scenario: Returns a list of the generated documents for a given cases
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the response has 6 records
And the response has 1 records
Scenario: Returns an generated document for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/3000248055333006ab56a01005891659"
Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "Object"
And the type is "object"
Scenario: Generate or regenerates an output documents for a given case

View File

@@ -262,13 +262,19 @@ class Calendar
public function create($arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
unset($arrayData["CAL_UID"]);
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
$this->throwExceptionIfExistsName($arrayData["CAL_NAME"], $this->arrayFieldNameForException["calendarName"]);
@@ -321,11 +327,7 @@ class Calendar
$arrayDataAux = array();
$arrayDataAux["CALENDAR_UID"] = \G::generateUniqueID();
$arrayDataAux["CALENDAR_NAME"] = $arrayData["CAL_NAME"];
if (isset($arrayData["CAL_DESCRIPTION"])) {
$arrayDataAux["CALENDAR_DESCRIPTION"] = $arrayData["CAL_DESCRIPTION"];
}
$arrayDataAux["CALENDAR_DESCRIPTION"] = (isset($arrayData["CAL_DESCRIPTION"]))? $arrayData["CAL_DESCRIPTION"] : "";
$arrayDataAux["CALENDAR_WORK_DAYS"] = explode("|", $this->workDaysReplaceData(implode("|", $arrayData["CAL_WORK_DAYS"])));
$arrayDataAux["CALENDAR_STATUS"] = $arrayData["CAL_STATUS"];
@@ -361,11 +363,17 @@ class Calendar
public function update($calendarUid, $arrayData)
{
try {
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$validator = new \ProcessMaker\BusinessModel\Validator();
$validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
//Set data
$arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER);
//Verify data
$process = new \ProcessMaker\BusinessModel\Process();
$this->throwExceptionIfNotExistsCalendar($calendarUid, $this->arrayFieldNameForException["calendarUid"]);
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);

View File

@@ -61,7 +61,9 @@ class Cases
if ($start != 0) {
$start--;
}
if ((abs((int)$limit)) == 0) {
$limit = (int)$limit;
$limit = abs($limit);
if ($limit == 0) {
G::LoadClass("configuration");
$conf = new \Configurations();
$generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');

View File

@@ -9,7 +9,8 @@ namespace ProcessMaker\BusinessModel;
*
* @protected
*/
class Validator{
class Validator
{
/**
* Validate dep_uid
* @var string $dep_uid. Uid for Departament
@@ -330,6 +331,47 @@ class Validator{
throw (new \Exception("The field '$nameField' is empty."));
}
}
/**
* Verify if data is array
*
* @param string $data Data
* @param string $dataNameForException Data name for the exception
*
* return void Throw exception if data is not array
*/
public function throwExceptionIfDataIsNotArray($data, $dataNameForException)
{
try {
if (!is_array($data)) {
$msg = str_replace(array("{0}"), array($dataNameForException), "The data \"{0}\" is not array");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
/**
* Verify if data is empty
*
* @param string $data Data
* @param string $dataNameForException Data name for the exception
*
* return void Throw exception if data is empty
*/
public function throwExceptionIfDataIsEmpty($data, $dataNameForException)
{
try {
if (empty($data)) {
$msg = str_replace(array("{0}"), array($dataNameForException), "The data \"{0}\" is empty");
throw (new \Exception($msg));
}
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -12,8 +12,8 @@ if (!class_exists("Propel")) {
*/
class CalendarTest extends \PHPUnit_Framework_TestCase
{
private static $calendar;
private static $numCalendar = 2;
protected static $calendar;
protected static $numCalendar = 2;
/**
* Set class for test
@@ -63,6 +63,22 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
$arrayRecord[] = $arrayCalendar;
}
//Create - Japanese characters
$arrayData = array(
"CAL_NAME" => "私の名前PHPUnitの",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertTrue(isset($arrayCalendar["CAL_UID"]));
$arrayRecord[] = $arrayCalendar;
//Return
return $arrayRecord;
}
@@ -70,10 +86,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test update calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*/
public function testUpdate($arrayRecord)
{
@@ -92,10 +108,10 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test get calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
*/
public function testGetCalendars($arrayRecord)
{
@@ -121,13 +137,14 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
/**
* Test get calendar
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
*/
public function testGetCalendar($arrayRecord)
{
//Get
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[0]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
@@ -137,15 +154,249 @@ class CalendarTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($arrayCalendar["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
$this->assertEquals($arrayCalendar["CAL_STATUS"], $arrayRecord[0]["CAL_STATUS"]);
//Get - Japanese characters
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[self::$numCalendar]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertEquals($arrayCalendar["CAL_NAME"], "私の名前PHPUnitの");
$this->assertEquals($arrayCalendar["CAL_WORK_DAYS"], array("MON", "TUE", "WED", "THU", "FRI"));
$this->assertEquals($arrayCalendar["CAL_STATUS"], "ACTIVE");
}
/**
* Test exception when data not is array
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The data "$arrayData" is not array
*/
public function testCreateExceptionNoIsArrayData()
{
$arrayData = 0;
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for empty data
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The data "$arrayData" is empty
*/
public function testCreateExceptionEmptyData()
{
$arrayData = array();
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for required data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The "CAL_NAME" attribute is not defined
*/
public function testCreateExceptionRequiredDataCalName()
{
$arrayData = array(
//"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for invalid data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The "CAL_NAME" attribute is empty
*/
public function testCreateExceptionInvalidDataCalName()
{
$arrayData = array(
"CAL_NAME" => "",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for invalid data (CAL_WORK_DAYS)
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value specified for "CAL_WORK_DAYS"
*/
public function testCreateExceptionInvalidDataCalWorkDays()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MONDAY", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception for calendar name existing
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @expectedException Exception
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar0" already exists
*/
public function testCreateExceptionExistsCalName()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar0",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->create($arrayData);
}
/**
* Test exception when data not is array
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage The data "$arrayData" is not array
*/
public function testUpdateExceptionNoIsArrayData()
{
$arrayData = 0;
$arrayCalendar = self::$calendar->update("", $arrayData);
}
/**
* Test exception for empty data
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage The data "$arrayData" is empty
*/
public function testUpdateExceptionEmptyData()
{
$arrayData = array();
$arrayCalendar = self::$calendar->update("", $arrayData);
}
/**
* Test exception for invalid calendar UID
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @expectedException Exception
* @expectedExceptionMessage The calendar with CAL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exists
*/
public function testUpdateExceptionInvalidCalUid()
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
}
/**
* Test exception for invalid data (CAL_NAME)
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage The "CAL_NAME" attribute is empty
*/
public function testUpdateExceptionInvalidDataCalName($arrayRecord)
{
$arrayData = array(
"CAL_NAME" => "",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test exception for invalid data (CAL_WORK_DAYS)
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage Invalid value specified for "CAL_WORK_DAYS"
*/
public function testUpdateExceptionInvalidDataCalWorkDays($arrayRecord)
{
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MONDAY", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE"
);
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test exception for calendar name existing
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @expectedException Exception
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar1" already exists
*/
public function testUpdateExceptionExistsCalName($arrayRecord)
{
$arrayData = $arrayRecord[1];
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
}
/**
* Test delete calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::delete
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::delete
*/
public function testDelete($arrayRecord)
{