diff --git a/src/CrowdinApiClient/Api/TaskApi.php b/src/CrowdinApiClient/Api/TaskApi.php index 6b8b7e77..bcf1f494 100644 --- a/src/CrowdinApiClient/Api/TaskApi.php +++ b/src/CrowdinApiClient/Api/TaskApi.php @@ -19,15 +19,16 @@ class TaskApi extends AbstractApi { /** - * List Tasks + * List Project Tasks * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.getMany API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.getMany API Documentation Enterprise * * @param int $projectId * @param array $params - * integer $params[limit] [ 1 .. 500 ] Default: 25
- * integer $params[offset] >= 0 Default: 0
- * string $params[status] Enum: "todo" "in_progress" "done" "closed" Example: status=done
+ * string $params[orderBy]
+ * integer $params[limit] [1 .. 500] Default: 25
+ * integer $params[offset] >= 0 Default: 0
+ * string $params[status] Enum: "todo" "in_progress" "done" "closed"
* integer $params[assigneeId] * * @return ModelCollection @@ -39,7 +40,7 @@ public function list(int $projectId, array $params = []): ModelCollection } /** - * Get Task + * Get Project Task * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.get API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.get API Documentation Enterprise * @@ -54,7 +55,7 @@ public function get(int $projectId, int $taskId): ?Task } /** - * Add Task + * Add Project Task * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.post API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.post API Documentation Enterprise * @@ -69,7 +70,7 @@ public function create(int $projectId, array $data): ?Task } /** - * Edit Task + * Edit Project Task * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.patch API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.patch API Documentation Enterprise * @@ -83,7 +84,7 @@ public function update($task): ?Task } /** - * Delete Task + * Delete Project Task * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.delete API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.delete API Documentation Enterprise * @@ -98,7 +99,7 @@ public function delete(int $projectId, int $taskId) } /** - * Export Task Strings + * Export Project Task Strings * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.export.get API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.export.get API Documentation Enterprise * @@ -112,21 +113,53 @@ public function exportStrings(int $projectId, int $taskId): ?DownloadFile return $this->_post($path, DownloadFile::class, []); } + /** + * List Tasks + * @link https://developer.crowdin.com/api/v2/#operation/api.users.tasks.getMany API Documentation + * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.users.tasks.getMany API Documentation Enterprise + * + * @param int $userId + * @param array $params + * string $params[orderBy]
+ * integer $params[limit] [1 .. 500] Default: 25
+ * integer $params[offset] >= 0 Default: 0
+ * string $params[status] Enum: "todo" "in_progress" "done" "closed"
+ * string $params[type] Enum: 0 1 2 3
+ * string $params[projectIds]
+ * string $params[assigneeIds]
+ * string $params[creatorIds]
+ * string $params[targetLanguageIds]
+ * string $params[sourceLanguageIds]
+ * string $params[createdAtFrom]
+ * string $params[createdAtTo]
+ * string $params[deadlineFrom]
+ * string $params[deadlineTo] + * + * @return ModelCollection|null + */ + public function listTasks(int $userId, array $params = []): ?ModelCollection + { + $path = sprintf('users/%d/tasks', $userId); + return $this->_list($path, Task::class, $params); + } + /** * List User Tasks + * @link https://developer.crowdin.com/api/v2/#operation/api.user.tasks.getMany API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.user.tasks.getMany API Documentation Enterprise * * @param array $params - * integer $params[limit] [ 1 .. 500 ] Default: 25
- * integer $params[offset] >= 0 Default: 25
- * string $params[status] Enum: "todo" "in_progress" "done" "closed" Example: status=done
- * string $params[isArchived] Default: 0 Default: 0 Example: isArchived=1 + * string $params[orderBy]
+ * integer $params[limit] [1 .. 500] Default: 25
+ * integer $params[offset] >= 0 Default: 0
+ * string $params[status] Enum: "todo" "in_progress" "done" "closed"
+ * string $params[isArchived] Enum: "0" "1" * - * @return ModelCollection + * @return ModelCollection|null */ public function listUserTasks(array $params = []): ?ModelCollection { - return $this->_list('user/tasks', Task::class, $params); + return $this->_list('user/tasks', Task::class, $params); } /** @@ -148,21 +181,21 @@ public function userTaskArchivedStatus(int $taskId, int $projectId, bool $isArch 'op' => 'replace', 'path' => '/isArchived', 'value' => $isArchived, - ] + ], ]; return $this->_patch($path, Task::class, $body, ['projectId' => $projectId]); } /** - * List Task Settings template + * List Project Task Settings Templates * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.getMany API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.settings-templates.getMany API Documentation Enterprise * * @param int $projectId * @param array $params - * integer $params[limit] [ 1 .. 500 ] Default: 25
- * integer $params[offset] >= 0 Default: 0
+ * integer $params[limit] [1 .. 500] Default: 25
+ * integer $params[offset] >= 0 Default: 0
* * @return ModelCollection */ @@ -173,7 +206,7 @@ public function listSettingsTemplates(int $projectId, array $params = []): Model } /** - * Get Task Settings template + * Get Task Settings Template * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.get API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.settings-templates.get API Documentation Enterprise * @@ -188,7 +221,7 @@ public function getSettingsTemplate(int $projectId, int $taskSettingsTemplateId) } /** - * Add Task Settings Template + * Add Project Task Settings Template * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.post API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.settings-templates.post API Documentation Enterprise * @@ -205,7 +238,7 @@ public function addSettingsTemplate(int $projectId, array $data): ?TaskSettingsT } /** - * Delete Task Settings Template + * Delete Project Task Settings Template * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.delete API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.settings-templates.delete API Documentation Enterprise * @@ -220,7 +253,7 @@ public function deleteSettingsTemplate(int $projectId, int $taskSettingsTemplate } /** - * Update Task Settings Template + * Update Project Task Settings Template * * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.settings-templates.patch API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.settings-templates.patch API Documentation Enterprise @@ -229,8 +262,10 @@ public function deleteSettingsTemplate(int $projectId, int $taskSettingsTemplate * @param TaskSettingsTemplate $taskSettingsTemplate * @return TaskSettingsTemplate|null */ - public function updateSettingsTemplate(int $projectId, TaskSettingsTemplate $taskSettingsTemplate): ?TaskSettingsTemplate - { + public function updateSettingsTemplate( + int $projectId, + TaskSettingsTemplate $taskSettingsTemplate + ): ?TaskSettingsTemplate { $path = sprintf('projects/%d/tasks/settings-templates/%d', $projectId, $taskSettingsTemplate->getId()); return $this->_update($path, $taskSettingsTemplate); } diff --git a/src/CrowdinApiClient/Api/TaskCommentApi.php b/src/CrowdinApiClient/Api/TaskCommentApi.php index daa0e69d..5d574177 100644 --- a/src/CrowdinApiClient/Api/TaskCommentApi.php +++ b/src/CrowdinApiClient/Api/TaskCommentApi.php @@ -13,7 +13,7 @@ class TaskCommentApi extends AbstractApi { /** - * List Task Comments + * List Project Task Comments * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.getMany API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.comments.getMany API Documentation Enterprise * @@ -32,7 +32,7 @@ public function list(int $projectId, int $taskId, array $params = []): ModelColl } /** - * Get Task Comment + * Get Project Task Comment * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.get API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.comments.get API Documentation Enterprise * @@ -48,7 +48,7 @@ public function get(int $projectId, int $taskId, int $commentId): ?TaskComment } /** - * Add Task Comment + * Add Project Task Comment * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.post API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.comments.post API Documentation Enterprise * @@ -67,7 +67,7 @@ public function create(int $projectId, int $taskId, array $data): ?TaskComment } /** - * Edit Task Comment + * Edit Project Task Comment * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.patch API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.comments.patch API Documentation Enterprise * @@ -83,7 +83,7 @@ public function update(int $projectId, int $taskId, TaskComment $taskComment): ? } /** - * Delete Task Comment + * Delete Project Task Comment * @link https://developer.crowdin.com/api/v2/#operation/api.projects.tasks.comments.delete API Documentation * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.tasks.comments.delete API Documentation Enterprise * diff --git a/src/CrowdinApiClient/Model/Task.php b/src/CrowdinApiClient/Model/Task.php index f55de340..ea814664 100644 --- a/src/CrowdinApiClient/Model/Task.php +++ b/src/CrowdinApiClient/Model/Task.php @@ -27,11 +27,6 @@ class Task extends BaseModel */ protected $type; - /** - * @var string|null - */ - protected $vendor; - /** * @var string */ @@ -43,19 +38,19 @@ class Task extends BaseModel protected $title; /** - * @var array + * @var integer|null */ - protected $assignees; + protected $batchId; /** * @var array */ - protected $assignedTeams; + protected $assignees; /** * @var array */ - protected $fileIds; + protected $assignedTeams; /** * @var array @@ -63,6 +58,7 @@ class Task extends BaseModel protected $progress; /** + * @deprecated * @var array|null */ protected $translateProgress; @@ -82,25 +78,20 @@ class Task extends BaseModel */ protected $description; - /** - * @var string - */ - protected $hash; - /** * @var string */ protected $translationUrl; /** - * @var integer + * @var string|null */ - protected $wordsCount; + protected $webUrl; /** * @var integer */ - protected $filesCount; + protected $wordsCount; /** * @var integer @@ -112,11 +103,26 @@ class Task extends BaseModel */ protected $deadline; + /** + * @var string|null + */ + protected $startedAt; + + /** + * @var string|null + */ + protected $resolvedAt; + /** * @var string */ protected $timeRange; + /** + * @var string + */ + protected $translationsUpdatedTimeRange; + /** * @var integer */ @@ -137,6 +143,81 @@ class Task extends BaseModel */ protected $updatedAt; + /** + * @var array + */ + protected $sourceLanguage; + + /** + * @var array + */ + protected $targetLanguages; + + /** + * @var int[] + */ + protected $labelIds; + + /** + * @var string|null + */ + protected $labelMatchRule; + + /** + * @var array + */ + protected $excludeLabelIds; + + /** + * @var string|null + */ + protected $excludeLabelMatchRule; + + /** + * @var int + */ + protected $precedingTaskId; + + /** + * @var array + */ + protected $estimatedCost; + + /** + * @var array + */ + protected $actualCost; + + /** + * @var bool + */ + protected $generateCostEstimate; + + /** + * @var bool + */ + protected $generateTranslationCost; + + /** + * @var int|null + */ + protected $reportSettingsTemplateId; + + /** + * @var string|null + */ + protected $vendor; + + /** + * @var integer + */ + protected $filesCount; + + /** + * @var array + */ + protected $fileIds; + /** * @var bool */ @@ -147,6 +228,11 @@ class Task extends BaseModel */ protected $fields = []; + /** + * @var string + */ + protected $hash; + public function __construct(array $data = []) { parent::__construct($data); @@ -154,31 +240,64 @@ public function __construct(array $data = []) $this->id = (int)$this->getDataProperty('id'); $this->projectId = (int)$this->getDataProperty('projectId'); $this->creatorId = (int)$this->getDataProperty('creatorId'); - $this->type = (string)$this->getDataProperty('type'); - $this->vendor = $this->getDataProperty('vendor') ? (string)$this->getDataProperty('vendor') : null; + $this->type = (int)$this->getDataProperty('type'); $this->status = (string)$this->getDataProperty('status'); $this->title = (string)$this->getDataProperty('title'); + $this->batchId = $this->getDataProperty('batchId') !== null ? (int)$this->getDataProperty('batchId') : null; $this->assignees = (array)$this->getDataProperty('assignees'); $this->assignedTeams = (array)$this->getDataProperty('assignedTeams'); - $this->fileIds = (array)$this->getDataProperty('fileIds'); $this->progress = (array)$this->getDataProperty('progress'); - $this->translateProgress = $this->getDataProperty('translateProgress') ? (array)$this->getDataProperty('translateProgress') : null; + $this->translateProgress = $this->getDataProperty('translateProgress') + ? (array)$this->getDataProperty('translateProgress') + : null; $this->sourceLanguageId = (string)$this->getDataProperty('sourceLanguageId'); $this->targetLanguageId = (string)$this->getDataProperty('targetLanguageId'); $this->description = (string)$this->getDataProperty('description'); - $this->hash = (string)$this->getDataProperty('hash'); $this->translationUrl = (string)$this->getDataProperty('translationUrl'); + $this->webUrl = $this->getDataProperty('webUrl') ? (string)$this->getDataProperty('webUrl') : null; $this->wordsCount = (int)$this->getDataProperty('wordsCount'); - $this->filesCount = (int)$this->getDataProperty('filesCount'); $this->commentsCount = (int)$this->getDataProperty('commentsCount'); $this->deadline = (string)$this->getDataProperty('deadline'); + $this->startedAt = $this->getDataProperty('startedAt') ? (string)$this->getDataProperty('startedAt') : null; + $this->resolvedAt = $this->getDataProperty('resolvedAt') ? (string)$this->getDataProperty('resolvedAt') : null; $this->timeRange = (string)$this->getDataProperty('timeRange'); + $this->translationsUpdatedTimeRange = (string)$this->getDataProperty('translationsUpdatedTimeRange'); $this->workflowStepId = (int)$this->getDataProperty('workflowStepId'); $this->buyUrl = $this->getDataProperty('buyUrl') ? (string)$this->getDataProperty('buyUrl') : null; $this->createdAt = (string)$this->getDataProperty('createdAt'); $this->updatedAt = (string)$this->getDataProperty('updatedAt'); + $this->sourceLanguage = (array)$this->getDataProperty('sourceLanguage'); + $this->targetLanguages = (array)$this->getDataProperty('targetLanguages'); + $this->labelIds = $this->getDataProperty('labelIds') !== null + ? (array)$this->getDataProperty('labelIds') + : null; + $this->labelMatchRule = $this->getDataProperty('labelMatchRule') + ? (string)$this->getDataProperty('labelMatchRule') + : null; + $this->excludeLabelIds = (array)$this->getDataProperty('excludeLabelIds'); + $this->excludeLabelMatchRule = $this->getDataProperty('excludeLabelMatchRule') + ? (string)$this->getDataProperty('excludeLabelMatchRule') + : null; + $this->precedingTaskId = (int)$this->getDataProperty('precedingTaskId'); + $this->estimatedCost = (array)$this->getDataProperty('estimatedCost'); + $this->actualCost = (array)$this->getDataProperty('actualCost'); + $this->generateCostEstimate = (bool)$this->getDataProperty('generateCostEstimate'); + $this->generateTranslationCost = (bool)$this->getDataProperty('generateTranslationCost'); + $this->reportSettingsTemplateId = $this->getDataProperty('reportSettingsTemplateId') + ? (int)$this->getDataProperty('reportSettingsTemplateId') + : null; + $this->vendor = $this->getDataProperty('vendor') ? (string)$this->getDataProperty('vendor') : null; + $this->filesCount = (int)$this->getDataProperty('filesCount'); + $this->fileIds = (array)$this->getDataProperty('fileIds'); + + // User Task $this->isArchived = (bool)$this->getDataProperty('isArchived'); + + // Enterprise only $this->fields = (array)$this->getDataProperty('fields'); + + // Deprecated + $this->hash = (string)$this->getDataProperty('hash'); } /** @@ -213,16 +332,6 @@ public function getType(): int return $this->type; } - public function getVendor(): ?string - { - return $this->vendor; - } - - public function setVendor(string $vendor): void - { - $this->vendor = $vendor; - } - /** * @return string */ @@ -255,6 +364,11 @@ public function setTitle(string $title): void $this->title = $title; } + public function getBatchId(): ?int + { + return $this->batchId; + } + /** * @return array */ @@ -281,22 +395,6 @@ public function setAssignedTeams(array $assignedTeams): void $this->assignedTeams = $assignedTeams; } - /** - * @return array - */ - public function getFileIds(): array - { - return $this->fileIds; - } - - /** - * @param array $fileIds - */ - public function setFileIds(array $fileIds): void - { - $this->fileIds = $fileIds; - } - /** * @return array */ @@ -345,14 +443,6 @@ public function setDescription(string $description): void $this->description = $description; } - /** - * @return string - */ - public function getHash(): string - { - return $this->hash; - } - /** * @return string */ @@ -361,20 +451,17 @@ public function getTranslationUrl(): string return $this->translationUrl; } - /** - * @return int - */ - public function getWordsCount(): int + public function getWebUrl(): ?string { - return $this->wordsCount; + return $this->webUrl; } /** * @return int */ - public function getFilesCount(): int + public function getWordsCount(): int { - return $this->filesCount; + return $this->wordsCount; } /** @@ -401,6 +488,26 @@ public function setDeadline(string $deadline): void $this->deadline = $deadline; } + public function getStartedAt(): ?string + { + return $this->startedAt; + } + + public function setStartedAt(?string $startedAt): void + { + $this->startedAt = $startedAt; + } + + public function getResolvedAt(): ?string + { + return $this->resolvedAt; + } + + public function setResolvedAt(?string $resolvedAt): void + { + $this->resolvedAt = $resolvedAt; + } + /** * @return string */ @@ -409,6 +516,11 @@ public function getTimeRange(): string return $this->timeRange; } + public function getTranslationsUpdatedTimeRange(): string + { + return $this->translationsUpdatedTimeRange; + } + /** * @return int */ @@ -422,7 +534,11 @@ public function getBuyUrl(): ?string return $this->buyUrl; } - public function setBuyUrl(string $buyUrl): void + /** + * @deprecated Crowdin API does not allow update this property. This method is will be removed in a future major release. + * @param string|null $buyUrl + */ + public function setBuyUrl(?string $buyUrl): void { $this->buyUrl = $buyUrl; } @@ -443,6 +559,44 @@ public function getUpdatedAt(): string return $this->updatedAt; } + public function getVendor(): ?string + { + return $this->vendor; + } + + /** + * @deprecated Crowdin API does not allow update this property. This method is will be removed in a future major release. + * @param string|null $vendor + */ + public function setVendor(?string $vendor): void + { + $this->vendor = $vendor; + } + + /** + * @return int + */ + public function getFilesCount(): int + { + return $this->filesCount; + } + + /** + * @return array + */ + public function getFileIds(): array + { + return $this->fileIds; + } + + /** + * @param array $fileIds + */ + public function setFileIds(array $fileIds): void + { + $this->fileIds = $fileIds; + } + /** * @return bool */ @@ -452,9 +606,10 @@ public function isArchived(): ?bool } /** + * @deprecated Crowdin API does not allow update this property. This method is will be removed in a future major release. * @param bool $isArchived */ - public function setIsArchived(?bool $isArchived): void + public function setIsArchived(bool $isArchived): void { $this->isArchived = $isArchived; } @@ -474,4 +629,114 @@ public function setFields(array $fields): void { $this->fields = $fields; } + + public function getSourceLanguage(): array + { + return $this->sourceLanguage; + } + + public function getTargetLanguages(): array + { + return $this->targetLanguages; + } + + /** + * @return int[]|null + */ + public function getLabelIds(): ?array + { + return $this->labelIds; + } + + /** + * @param int[] $labelIds + */ + public function setLabelIds(array $labelIds): void + { + $this->labelIds = $labelIds; + } + + public function getLabelMatchRule(): ?string + { + return $this->labelMatchRule; + } + + public function setLabelMatchRule(?string $labelMatchRule): void + { + $this->labelMatchRule = $labelMatchRule; + } + + public function getExcludeLabelIds(): array + { + return $this->excludeLabelIds; + } + + public function setExcludeLabelIds(array $excludeLabelIds): void + { + $this->excludeLabelIds = $excludeLabelIds; + } + + public function getExcludeLabelMatchRule(): ?string + { + return $this->excludeLabelMatchRule; + } + + public function setExcludeLabelMatchRule(?string $excludeLabelMatchRule): void + { + $this->excludeLabelMatchRule = $excludeLabelMatchRule; + } + + public function getPrecedingTaskId(): int + { + return $this->precedingTaskId; + } + + public function getEstimatedCost(): array + { + return $this->estimatedCost; + } + + public function getActualCost(): array + { + return $this->actualCost; + } + + public function getGenerateCostEstimate(): bool + { + return $this->generateCostEstimate; + } + + public function setGenerateCostEstimate(bool $generateCostEstimate): void + { + $this->generateCostEstimate = $generateCostEstimate; + } + + public function getGenerateTranslationCost(): bool + { + return $this->generateTranslationCost; + } + + public function setGenerateTranslationCost(bool $generateTranslationCost): void + { + $this->generateTranslationCost = $generateTranslationCost; + } + + public function getReportSettingsTemplateId(): ?int + { + return $this->reportSettingsTemplateId; + } + + public function setReportSettingsTemplateId(?int $reportSettingsTemplateId): void + { + $this->reportSettingsTemplateId = $reportSettingsTemplateId; + } + + /** + * @deprecated Crowdin API does not return this property anymore. This method is will be removed in a future major release. + * @return string|null + */ + public function getHash(): ?string + { + return $this->hash; + } } diff --git a/src/CrowdinApiClient/Model/TaskForUpdate.php b/src/CrowdinApiClient/Model/TaskForUpdate.php index adbdcb7f..91e2735c 100644 --- a/src/CrowdinApiClient/Model/TaskForUpdate.php +++ b/src/CrowdinApiClient/Model/TaskForUpdate.php @@ -8,55 +8,114 @@ class TaskForUpdate extends Task { /** - * @var boolean + * @deprecated + * @var bool */ protected $splitFiles; /** - * @var boolean + * @var bool + */ + protected $splitContent; + + /** + * @var int[] + */ + protected $stringIds; + + /** + * @var bool */ protected $skipAssignedStrings; /** - * @var string + * @var string|null */ protected $dateFrom; /** - * @var string + * @var string|null */ protected $dateTo; /** - * @var int[] + * @var string|null + */ + protected $translationsUpdatedDateFrom; + + /** + * @var string|null */ - protected $labelIds; + protected $translationsUpdatedDateTo; public function __construct(array $data = []) { parent::__construct($data); - $this->data['splitFiles'] = false; - $this->data['skipAssignedStrings'] = false; - $this->data['dateFrom'] = ''; - $this->data['dateTo'] = ''; - $this->data['labelIds'] = []; + + $this->initMissingProperties(); $this->splitFiles = null !== $this->getDataProperty('splitFiles') - ? (bool)$this->getDataProperty('splitFiles') : null; + && $this->getDataProperty('splitFiles'); + $this->splitContent = null !== $this->getDataProperty('splitContent') + && $this->getDataProperty('splitContent'); + $this->stringIds = null !== $this->getDataProperty('stringIds') + ? (array)$this->getDataProperty('stringIds') + : []; $this->skipAssignedStrings = null !== $this->getDataProperty('skipAssignedStrings') - ? (bool)$this->getDataProperty('skipAssignedStrings') : null; + && $this->getDataProperty('skipAssignedStrings'); $this->dateFrom = null !== $this->getDataProperty('dateFrom') - ? (string)$this->getDataProperty('dateFrom') : null; + ? (string)$this->getDataProperty('dateFrom') + : null; $this->dateTo = null !== $this->getDataProperty('dateTo') - ? (string)$this->getDataProperty('dateTo') : null; - $this->labelIds = null !== $this->getDataProperty('labelIds') - ? (array)$this->getDataProperty('labelIds') : null; + ? (string)$this->getDataProperty('dateTo') + : null; + $this->translationsUpdatedDateFrom = null !== $this->getDataProperty('translationsUpdatedDateFrom') + ? (string)$this->getDataProperty('translationsUpdatedDateFrom') + : null; + $this->translationsUpdatedDateTo = null !== $this->getDataProperty('translationsUpdatedDateTo') + ? (string)$this->getDataProperty('translationsUpdatedDateTo') + : null; + } + + private function initMissingProperties(): void + { + if (!array_key_exists('splitFiles', $this->data)) { + $this->data['splitFiles'] = false; + } + + if (!array_key_exists('splitContent', $this->data)) { + $this->data['splitContent'] = false; + } + + if (!array_key_exists('stringIds', $this->data)) { + $this->data['stringIds'] = []; + } + + if (!array_key_exists('skipAssignedStrings', $this->data)) { + $this->data['skipAssignedStrings'] = false; + } + + if (!array_key_exists('dateFrom', $this->data)) { + $this->data['dateFrom'] = null; + } + + if (!array_key_exists('dateTo', $this->data)) { + $this->data['dateTo'] = null; + } + + if (!array_key_exists('translationsUpdatedDateFrom', $this->data)) { + $this->data['translationsUpdatedDateFrom'] = null; + } + + if (!array_key_exists('translationsUpdatedDateTo', $this->data)) { + $this->data['translationsUpdatedDateTo'] = null; + } } /** * @return bool */ - public function getSplitFiles(): ?bool + public function getSplitFiles(): bool { return $this->splitFiles; } @@ -72,7 +131,39 @@ public function setSplitFiles(bool $splitFiles): void /** * @return bool */ - public function getSkipAssignedStrings(): ?bool + public function getSplitContent(): bool + { + return $this->splitContent; + } + + /** + * @param bool $splitContent + */ + public function setSplitContent(bool $splitContent): void + { + $this->splitContent = $splitContent; + } + + /** + * @return array + */ + public function getStringIds(): array + { + return $this->stringIds; + } + + /** + * @param array $stringIds + */ + public function setStringIds(array $stringIds): void + { + $this->stringIds = $stringIds; + } + + /** + * @return bool + */ + public function getSkipAssignedStrings(): bool { return $this->skipAssignedStrings; } @@ -86,7 +177,7 @@ public function setSkipAssignedStrings(bool $skipAssignedStrings): void } /** - * @return string + * @return string|null */ public function getDateFrom(): ?string { @@ -102,7 +193,7 @@ public function setDateFrom(string $dateFrom): void } /** - * @return string + * @return string|null */ public function getDateTo(): ?string { @@ -117,19 +208,23 @@ public function setDateTo(string $dateTo): void $this->dateTo = $dateTo; } - /** - * @return int[]|null - */ - public function getLabelIds(): ?array + public function getTranslationsUpdatedDateFrom(): ?string { - return $this->labelIds; + return $this->translationsUpdatedDateFrom; } - /** - * @param int[] $labelIds - */ - public function setLabelIds(array $labelIds): void + public function setTranslationsUpdatedDateFrom(?string $translationsUpdatedDateFrom): void + { + $this->translationsUpdatedDateFrom = $translationsUpdatedDateFrom; + } + + public function getTranslationsUpdatedDateTo(): ?string + { + return $this->translationsUpdatedDateTo; + } + + public function setTranslationsUpdatedDateTo(?string $translationsUpdatedDateTo): void { - $this->labelIds = $labelIds; + $this->translationsUpdatedDateTo = $translationsUpdatedDateTo; } } diff --git a/tests/CrowdinApiClient/Api/TaskApiTest.php b/tests/CrowdinApiClient/Api/TaskApiTest.php index c7a6d7e9..38a0b2f3 100644 --- a/tests/CrowdinApiClient/Api/TaskApiTest.php +++ b/tests/CrowdinApiClient/Api/TaskApiTest.php @@ -15,55 +15,53 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/tasks', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor":null, - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } - ], - "fileIds": [ - 1 + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => null, + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [1], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'buyUrl' => null, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "buyUrl": null, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $tasks = $this->crowdin->task->list(2); @@ -79,22 +77,17 @@ public function testCreate() $params = [ 'title' => 'string', 'languageId' => 'es', - 'fileIds' => - [ - 0 => 0, - ], + 'fileIds' => [0], 'type' => 0, 'status' => 'todo', 'description' => 'string', 'splitFiles' => false, - 'assignees' => + 'assignees' => [ [ - 0 => - [ - 'id' => 0, - 'wordsCount' => 0, - ], + 'id' => 0, + 'wordsCount' => 0, ], + ], 'deadline' => '2100-12-31T23:59:59+00:00', 'dateFrom' => '2100-12-31T23:59:59+00:00', 'dateTo' => '2100-12-31T23:59:59+00:00', @@ -104,44 +97,41 @@ public function testCreate() 'path' => '/projects/2/tasks', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } - ], - "fileIds": [ - 1 + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [1], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }' - + ]), ]); $task = $this->crowdin->task->create(2, $params); @@ -151,101 +141,106 @@ public function testCreate() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/tasks/2', '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor":"gengo", - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->mockRequestGet( + '/projects/2/tasks/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], ], - "fileIds": [ - 1 + 'fileIds' => [1], + 'labelIds' => [], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }'); + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]) + ); $task = $this->crowdin->task->get(2, 2); + $this->assertInstanceOf(Task::class, $task); $this->assertEquals(2, $task->getId()); - $this->assertEquals("gengo", $task->getVendor()); - - $this->mockRequestPatch('/projects/2/tasks/2', '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor":"gengo", - "status": "todo", - "title": "test edit", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->assertEquals('gengo', $task->getVendor()); + + $newTitle = 'New title'; + $newLabelIds = [1, 3]; + + $this->mockRequestPatch( + '/projects/2/tasks/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => $newTitle, + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], ], - "fileIds": [ - 1 + 'fileIds' => [1], + 'labelIds' => $newLabelIds, + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }'); + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]) + ); $taskForUpdate = new TaskForUpdate($task->getData()); - $taskForUpdate->setTitle('test edit'); - $taskForUpdate->setSkipAssignedStrings(true); - $taskForUpdate->setSplitFiles(true); - $taskForUpdate->setLabelIds([1, 3]); - $taskForUpdate->setDateFrom('2021-01-23T09:04:29+00:00'); - $taskForUpdate->setDateTo('2021-02-12T09:04:29+00:00'); + $taskForUpdate->setTitle($newTitle); + $taskForUpdate->setLabelIds($newLabelIds); $task = $this->crowdin->task->update($taskForUpdate); + $this->assertInstanceOf(Task::class, $task); - $this->assertEquals(2, $task->getId()); - $this->assertEquals('test edit', $task->getTitle()); + $this->assertEquals($newTitle, $task->getTitle()); + $this->assertEquals($newLabelIds, $task->getLabelIds()); $this->assertEquals('gengo', $task->getVendor()); } @@ -260,70 +255,132 @@ public function testExportStrings() $this->mockRequest([ 'path' => '/projects/2/tasks/3/exports', 'method' => 'post', - 'response' => '{ - "data": { - "url": "https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62", - "expireIn": "2019-09-20T10:31:21+00:00" - } - }' - + 'response' => json_encode([ + 'data' => [ + 'url' => 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + 'expireIn' => '2019-09-20T10:31:21+00:00', + ], + ]), ]); $export = $this->crowdin->task->exportStrings(2, 3); $this->assertInstanceOf(DownloadFile::class, $export); - $this->assertEquals('https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', $export->getUrl()); + $this->assertEquals( + 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + $export->getUrl() + ); + } + + public function testListTasks() + { + $this->mockRequestGet( + '/users/6/tasks', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [1], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 25, + ], + ], + ]) + ); + + $tasks = $this->crowdin->task->listTasks(6); + + $this->assertInstanceOf(ModelCollection::class, $tasks); + $this->assertCount(1, $tasks); + $this->assertInstanceOf(Task::class, $tasks[0]); + $this->assertEquals(2, $tasks[0]->getId()); } public function testListUserTasks() { - $this->mockRequestGet('/user/tasks', '{ - "data": [ - { - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->mockRequestGet( + '/user/tasks', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [1], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + 'isArchived' => false, + ], ], - "fileIds": [ - 1 + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 25, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00", - "isArchived": false - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 25 - } - ] - }'); + ], + ]) + ); $tasks = $this->crowdin->task->listUserTasks(); $this->assertInstanceOf(ModelCollection::class, $tasks); @@ -334,46 +391,45 @@ public function testListUserTasks() public function testUserTaskArchivedStatus() { - $this->mockRequestPatch('/user/tasks/2?projectId=2', '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->mockRequestPatch( + '/user/tasks/2?projectId=2', + json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], ], - "fileIds": [ - 1 + 'fileIds' => [1], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00", - "isArchived": true - } - }', [ - - ]); + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + 'isArchived' => true, + ], + ]) + ); $task = $this->crowdin->task->userTaskArchivedStatus(2, 2); @@ -384,34 +440,35 @@ public function testUserTaskArchivedStatus() public function testListSettingsTemplate() { - $this->mockRequestGet('/projects/2/tasks/settings-templates', '{ - "data": [ - { - "data": { - "id": 1, - "name": "Default template", - "config": { - "languages": [ - { - "languageId": "uk", - "userIds": [ - 1 - ] - } - ] - }, - "createdAt": "2019-09-23T09:35:31+00:00", - "updatedAt": "2020-09-23T09:35:31+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 25 - } - ] - }'); + $this->mockRequestGet( + '/projects/2/tasks/settings-templates', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 1, + 'name' => 'Default template', + 'config' => [ + 'languages' => [ + [ + 'languageId' => 'uk', + 'userIds' => [1], + ], + ], + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + 'updatedAt' => '2020-09-23T09:35:31+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 25, + ], + ], + ]) + ); $taskSettingsTemplates = $this->crowdin->task->listSettingsTemplates(2); $this->assertInstanceOf(ModelCollection::class, $taskSettingsTemplates); @@ -428,37 +485,32 @@ public function testAddSettingsTemplate() 'languages' => [ [ 'languageId' => 'uk', - 'userIds' => [ - 1 - ] - ] - ] - ] + 'userIds' => [1], + ], + ], + ], ]; $this->mockRequest([ 'path' => '/projects/2/tasks/settings-templates', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 1, - "name": "Default template", - "config": { - "languages": [ - { - "languageId": "uk", - "userIds": [ - 1 - ] - } - ] - }, - "createdAt": "2019-09-23T09:35:31+00:00", - "updatedAt": "2020-09-23T09:35:31+00:00" - } - }' - + 'response' => json_encode([ + 'data' => [ + 'id' => 1, + 'name' => 'Default template', + 'config' => [ + 'languages' => [ + [ + 'languageId' => 'uk', + 'userIds' => [1], + ], + ], + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + 'updatedAt' => '2020-09-23T09:35:31+00:00', + ], + ]), ]); $taskSettingsTemplate = $this->crowdin->task->addSettingsTemplate(2, $params); @@ -468,24 +520,25 @@ public function testAddSettingsTemplate() public function testGetAndUpdateSettingsTemplate() { - $this->mockRequestGet('/projects/2/tasks/settings-templates/1', '{ - "data": { - "id": 1, - "name": "Default template", - "config": { - "languages": [ - { - "languageId": "uk", - "userIds": [ - 1 - ] - } - ] - }, - "createdAt": "2019-09-23T09:35:31+00:00", - "updatedAt": "2020-09-23T09:35:31+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/tasks/settings-templates/1', + json_encode([ + 'data' => [ + 'id' => 1, + 'name' => 'Default template', + 'config' => [ + 'languages' => [ + [ + 'languageId' => 'uk', + 'userIds' => [1], + ], + ], + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + 'updatedAt' => '2020-09-23T09:35:31+00:00', + ], + ]) + ); $taskSettingsTemplate = $this->crowdin->task->getSettingsTemplate(2, 1); $this->assertInstanceOf(TaskSettingsTemplate::class, $taskSettingsTemplate); @@ -494,25 +547,22 @@ public function testGetAndUpdateSettingsTemplate() $this->mockRequest([ 'path' => '/projects/2/tasks/settings-templates/1', 'method' => 'patch', - 'response' => '{ - "data": { - "id": 1, - "name": "Test template", - "config": { - "languages": [ - { - "languageId": "fr", - "userIds": [ - 1 - ] - } - ] - }, - "createdAt": "2019-09-23T09:35:31+00:00", - "updatedAt": "2020-09-23T09:35:31+00:00" - } - }' - + 'response' => json_encode([ + 'data' => [ + 'id' => 1, + 'name' => 'Test template', + 'config' => [ + 'languages' => [ + [ + 'languageId' => 'fr', + 'userIds' => [1], + ], + ], + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + 'updatedAt' => '2020-09-23T09:35:31+00:00', + ], + ]), ]); $params = new TaskSettingsTemplate($taskSettingsTemplate->getData()); @@ -521,11 +571,9 @@ public function testGetAndUpdateSettingsTemplate() 'languages' => [ [ 'languageId' => 'fr', - 'userIds' => [ - 1 - ] - ] - ] + 'userIds' => [1], + ], + ], ]); $taskSettingsTemplate = $this->crowdin->task->updateSettingsTemplate(2, $params); diff --git a/tests/CrowdinApiClient/Model/TaskCommentTest.php b/tests/CrowdinApiClient/Model/TaskCommentTest.php index 1da7e277..cfa8fad2 100644 --- a/tests/CrowdinApiClient/Model/TaskCommentTest.php +++ b/tests/CrowdinApiClient/Model/TaskCommentTest.php @@ -7,11 +7,6 @@ class TaskCommentTest extends TestCase { - /** - * @var TaskComment - */ - public $taskComment; - public $data = [ 'id' => 1233, 'userId' => 5, @@ -24,28 +19,27 @@ class TaskCommentTest extends TestCase public function testLoadData() { - $this->taskComment = new TaskComment($this->data); - $this->checkData(); + $taskComment = new TaskComment($this->data); + + $this->assertEquals($this->data['id'], $taskComment->getId()); + $this->assertEquals($this->data['userId'], $taskComment->getUserId()); + $this->assertEquals($this->data['taskId'], $taskComment->getTaskId()); + $this->assertEquals($this->data['text'], $taskComment->getText()); + $this->assertEquals($this->data['timeSpent'], $taskComment->getTimeSpent()); + $this->assertEquals($this->data['createdAt'], $taskComment->getCreatedAt()); + $this->assertEquals($this->data['updatedAt'], $taskComment->getUpdatedAt()); } public function testSetData() { - $this->taskComment = new TaskComment(); - $this->taskComment->setText($this->data['text']); - $this->taskComment->setTimeSpent($this->data['timeSpent']); + $text = 'New task comment text'; + $timeSpent = 7200; - $this->assertEquals($this->data['text'], $this->taskComment->getText()); - $this->assertEquals($this->data['timeSpent'], $this->taskComment->getTimeSpent()); - } + $taskComment = new TaskComment(); + $taskComment->setText($text); + $taskComment->setTimeSpent($timeSpent); - public function checkData() - { - $this->assertEquals($this->data['id'], $this->taskComment->getId()); - $this->assertEquals($this->data['userId'], $this->taskComment->getUserId()); - $this->assertEquals($this->data['taskId'], $this->taskComment->getTaskId()); - $this->assertEquals($this->data['text'], $this->taskComment->getText()); - $this->assertEquals($this->data['timeSpent'], $this->taskComment->getTimeSpent()); - $this->assertEquals($this->data['createdAt'], $this->taskComment->getCreatedAt()); - $this->assertEquals($this->data['updatedAt'], $this->taskComment->getUpdatedAt()); + $this->assertEquals($text, $taskComment->getText()); + $this->assertEquals($timeSpent, $taskComment->getTimeSpent()); } } diff --git a/tests/CrowdinApiClient/Model/TaskForUpdateTest.php b/tests/CrowdinApiClient/Model/TaskForUpdateTest.php index 65edc5b3..8df5557e 100644 --- a/tests/CrowdinApiClient/Model/TaskForUpdateTest.php +++ b/tests/CrowdinApiClient/Model/TaskForUpdateTest.php @@ -7,115 +7,185 @@ class TaskForUpdateTest extends TestCase { - /** - * @var TaskForUpdate - */ - public $taskForUpdate; - public $data = [ 'id' => 2, 'projectId' => 2, 'creatorId' => 6, 'type' => 1, - 'vendor' => 'gengo', 'status' => 'todo', 'title' => 'French', - 'assignees' => + 'batchId' => 1, + 'splitFiles' => true, + 'splitContent' => true, + 'stringIds' => [1, 2, 3], + 'skipAssignedStrings' => true, + 'assignees' => [ [ - 0 => - [ - 'id' => 1, - 'wordsCount' => 5, - ], + 'id' => 1, + 'username' => 'john.doe', + 'fullName' => 'John Doe', + 'avatarUrl' => '', + 'wordsCount' => 165, + 'wordsLeft' => 5, + 'timeSpent' => 56, ], - "assignedTeams" => [ + ], + 'assignedTeams' => [ [ 'id' => 1, 'wordsCount' => 5, - ] - ], - 'fileIds' => - [ - 0 => 1, + 'timeSpent' => 3600, ], - 'progress' => - [ - 'total' => 24, - 'done' => 15, - 'percent' => 62, - ], - 'translateProgress' => null, + ], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'translateProgress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], 'sourceLanguageId' => 'en', 'targetLanguageId' => 'fr', - 'description' => 'Proofrea all French strings', - 'hash' => 'dac37aff364d83899128e68afe0de4994', - 'translationUrl' => '/proofrea/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'description' => 'Proofread all French strings', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'webUrl' => 'https://crowdin.com/project/example/tasks/2', 'wordsCount' => 24, - 'filesCount' => 2, 'commentsCount' => 0, 'deadline' => '2019-09-27T07:00:14+00:00', + 'startedAt' => '2019-09-25T07:00:14+00:00', + 'resolvedAt' => '2019-09-26T07:00:14+00:00', + 'dateFrom' => '2019-09-23T09:04:29+00:00', + 'dateTo' => '2019-09-27T07:00:14+00:00', + 'translationsUpdatedDateFrom' => '2019-09-20T09:04:29+00:00', + 'translationsUpdatedDateTo' => '2019-09-25T09:04:29+00:00', 'timeRange' => 'string', + 'translationsUpdatedTimeRange' => 'string', 'workflowStepId' => 10, 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', 'createdAt' => '2019-09-23T09:04:29+00:00', 'updatedAt' => '2019-09-23T09:04:29+00:00', - 'isArchived' => false + 'sourceLanguage' => [ + 'id' => 'en', + 'name' => 'English', + ], + 'targetLanguages' => [ + [ + 'id' => 'fr', + 'name' => 'French', + ], + ], + 'labelIds' => [13, 27], + 'labelMatchRule' => 'all', + 'excludeLabelIds' => [], + 'excludeLabelMatchRule' => null, + 'precedingTaskId' => 1, + 'estimatedCost' => [ + 'cost' => 10.0, + 'date' => '2019-09-23T09:04:29+00:00', + 'currency' => 'USD', + ], + 'actualCost' => [ + 'cost' => 12.0, + 'date' => '2019-09-23T09:04:29+00:00', + 'currency' => 'USD', + ], + 'generateCostEstimate' => true, + 'generateTranslationCost' => false, + 'reportSettingsTemplateId' => null, + 'vendor' => 'gengo', + 'filesCount' => 2, + 'fileIds' => [1, 2], + 'isArchived' => false, + 'fields' => [ + 'client-company' => 'ACME Corp', + ], ]; public function testLoadData() { - $this->taskForUpdate = new TaskForUpdate($this->data); - $this->checkData(); + $taskForUpdate = new TaskForUpdate($this->data); + $this->assertEquals($this->data['id'], $taskForUpdate->getId()); + $this->assertEquals($this->data['projectId'], $taskForUpdate->getProjectId()); + $this->assertEquals($this->data['creatorId'], $taskForUpdate->getCreatorId()); + $this->assertEquals($this->data['type'], $taskForUpdate->getType()); + $this->assertEquals($this->data['vendor'], $taskForUpdate->getVendor()); + $this->assertEquals($this->data['status'], $taskForUpdate->getStatus()); + $this->assertEquals($this->data['title'], $taskForUpdate->getTitle()); + $this->assertEquals($this->data['splitFiles'], $taskForUpdate->getSplitFiles()); + $this->assertEquals($this->data['splitContent'], $taskForUpdate->getSplitContent()); + $this->assertEquals($this->data['stringIds'], $taskForUpdate->getStringIds()); + $this->assertEquals($this->data['skipAssignedStrings'], $taskForUpdate->getSkipAssignedStrings()); + $this->assertEquals($this->data['assignees'], $taskForUpdate->getAssignees()); + $this->assertEquals($this->data['assignedTeams'], $taskForUpdate->getAssignedTeams()); + $this->assertEquals($this->data['fileIds'], $taskForUpdate->getFileIds()); + $this->assertEquals($this->data['progress'], $taskForUpdate->getProgress()); + $this->assertEquals($this->data['translateProgress'], $taskForUpdate->getTranslateProgress()); + $this->assertEquals($this->data['sourceLanguageId'], $taskForUpdate->getSourceLanguageId()); + $this->assertEquals($this->data['targetLanguageId'], $taskForUpdate->getTargetLanguageId()); + $this->assertEquals($this->data['description'], $taskForUpdate->getDescription()); + $this->assertEquals($this->data['translationUrl'], $taskForUpdate->getTranslationUrl()); + $this->assertEquals($this->data['wordsCount'], $taskForUpdate->getWordsCount()); + $this->assertEquals($this->data['filesCount'], $taskForUpdate->getFilesCount()); + $this->assertEquals($this->data['commentsCount'], $taskForUpdate->getCommentsCount()); + $this->assertEquals($this->data['deadline'], $taskForUpdate->getDeadline()); + $this->assertEquals($this->data['startedAt'], $taskForUpdate->getStartedAt()); + $this->assertEquals($this->data['resolvedAt'], $taskForUpdate->getResolvedAt()); + $this->assertEquals($this->data['dateFrom'], $taskForUpdate->getDateFrom()); + $this->assertEquals($this->data['dateTo'], $taskForUpdate->getDateTo()); + $this->assertEquals($this->data['translationsUpdatedDateFrom'], $taskForUpdate->getTranslationsUpdatedDateFrom()); + $this->assertEquals($this->data['translationsUpdatedDateTo'], $taskForUpdate->getTranslationsUpdatedDateTo()); + $this->assertEquals($this->data['timeRange'], $taskForUpdate->getTimeRange()); + $this->assertEquals($this->data['translationsUpdatedTimeRange'], $taskForUpdate->getTranslationsUpdatedTimeRange()); + $this->assertEquals($this->data['workflowStepId'], $taskForUpdate->getWorkflowStepId()); + $this->assertEquals($this->data['buyUrl'], $taskForUpdate->getBuyUrl()); + $this->assertEquals($this->data['createdAt'], $taskForUpdate->getCreatedAt()); + $this->assertEquals($this->data['updatedAt'], $taskForUpdate->getUpdatedAt()); + $this->assertEquals($this->data['isArchived'], $taskForUpdate->isArchived()); } public function testSetData() { - $this->taskForUpdate = new TaskForUpdate(); - $this->taskForUpdate->setStatus($this->data['status']); - $this->taskForUpdate->setTitle($this->data['title']); - $this->taskForUpdate->setSkipAssignedStrings(true); - $this->taskForUpdate->setSplitFiles(true); - $this->taskForUpdate->setDateFrom('2021-03-01T11:05:24+00:00'); - $this->taskForUpdate->setDateTo('2021-03-04T11:05:24+00:00'); - $this->taskForUpdate->setLabelIds([8, 9, 23]); + $status = 'in_progress'; + $title = 'New Title'; + $splitFiles = true; + $splitContent = false; + $stringIds = [4, 5, 6]; + $skipAssignedStrings = true; + $dateFrom = '2021-03-01T11:05:24+00:00'; + $dateTo = '2021-03-04T11:05:24+00:00'; + $translationsUpdatedDateFrom = '2021-02-01T11:05:24+00:00'; + $translationsUpdatedDateTo = '2021-02-15T11:05:24+00:00'; + $labelIds = [8, 9, 23]; - $this->assertEquals($this->data['status'], $this->taskForUpdate->getStatus()); - $this->assertEquals($this->data['title'], $this->taskForUpdate->getTitle()); - $this->assertEquals(true, $this->taskForUpdate->getSkipAssignedStrings()); - $this->assertEquals(true, $this->taskForUpdate->getSplitFiles()); - $this->assertEquals('2021-03-01T11:05:24+00:00', $this->taskForUpdate->getDateFrom()); - $this->assertEquals('2021-03-04T11:05:24+00:00', $this->taskForUpdate->getDateTo()); - $this->assertEquals([8, 9, 23], $this->taskForUpdate->getLabelIds()); - } + $data = $this->data; + $data['stringIds'] = null; - public function checkData() - { - $this->assertEquals($this->data['id'], $this->taskForUpdate->getId()); - $this->assertEquals($this->data['projectId'], $this->taskForUpdate->getProjectId()); - $this->assertEquals($this->data['creatorId'], $this->taskForUpdate->getCreatorId()); - $this->assertEquals($this->data['type'], $this->taskForUpdate->getType()); - $this->assertEquals($this->data['vendor'], $this->taskForUpdate->getVendor()); - $this->assertEquals($this->data['status'], $this->taskForUpdate->getStatus()); - $this->assertEquals($this->data['title'], $this->taskForUpdate->getTitle()); - $this->assertEquals($this->data['assignees'], $this->taskForUpdate->getAssignees()); - $this->assertEquals($this->data['assignedTeams'], $this->taskForUpdate->getAssignedTeams()); - $this->assertEquals($this->data['fileIds'], $this->taskForUpdate->getFileIds()); - $this->assertEquals($this->data['progress'], $this->taskForUpdate->getProgress()); - $this->assertEquals($this->data['translateProgress'], $this->taskForUpdate->getTranslateProgress()); - $this->assertEquals($this->data['sourceLanguageId'], $this->taskForUpdate->getSourceLanguageId()); - $this->assertEquals($this->data['targetLanguageId'], $this->taskForUpdate->getTargetLanguageId()); - $this->assertEquals($this->data['description'], $this->taskForUpdate->getDescription()); - $this->assertEquals($this->data['hash'], $this->taskForUpdate->getHash()); - $this->assertEquals($this->data['translationUrl'], $this->taskForUpdate->getTranslationUrl()); - $this->assertEquals($this->data['wordsCount'], $this->taskForUpdate->getWordsCount()); - $this->assertEquals($this->data['filesCount'], $this->taskForUpdate->getFilesCount()); - $this->assertEquals($this->data['commentsCount'], $this->taskForUpdate->getCommentsCount()); - $this->assertEquals($this->data['deadline'], $this->taskForUpdate->getDeadline()); - $this->assertEquals($this->data['timeRange'], $this->taskForUpdate->getTimeRange()); - $this->assertEquals($this->data['workflowStepId'], $this->taskForUpdate->getWorkflowStepId()); - $this->assertEquals($this->data['buyUrl'], $this->taskForUpdate->getBuyUrl()); - $this->assertEquals($this->data['createdAt'], $this->taskForUpdate->getCreatedAt()); - $this->assertEquals($this->data['updatedAt'], $this->taskForUpdate->getUpdatedAt()); - $this->assertEquals($this->data['isArchived'], $this->taskForUpdate->isArchived()); + $taskForUpdate = new TaskForUpdate($data); + $taskForUpdate->setStatus($status); + $taskForUpdate->setTitle($title); + $taskForUpdate->setSplitFiles($splitFiles); + $taskForUpdate->setSplitContent($splitContent); + $taskForUpdate->setStringIds($stringIds); + $taskForUpdate->setSkipAssignedStrings($skipAssignedStrings); + $taskForUpdate->setDateFrom($dateFrom); + $taskForUpdate->setDateTo($dateTo); + $taskForUpdate->setTranslationsUpdatedDateFrom($translationsUpdatedDateFrom); + $taskForUpdate->setTranslationsUpdatedDateTo($translationsUpdatedDateTo); + $taskForUpdate->setLabelIds($labelIds); + + $this->assertEquals($status, $taskForUpdate->getStatus()); + $this->assertEquals($title, $taskForUpdate->getTitle()); + $this->assertEquals($splitFiles, $taskForUpdate->getSplitFiles()); + $this->assertEquals($splitContent, $taskForUpdate->getSplitContent()); + $this->assertEquals($stringIds, $taskForUpdate->getStringIds()); + $this->assertEquals($skipAssignedStrings, $taskForUpdate->getSkipAssignedStrings()); + $this->assertEquals($dateFrom, $taskForUpdate->getDateFrom()); + $this->assertEquals($dateTo, $taskForUpdate->getDateTo()); + $this->assertEquals($translationsUpdatedDateFrom, $taskForUpdate->getTranslationsUpdatedDateFrom()); + $this->assertEquals($translationsUpdatedDateTo, $taskForUpdate->getTranslationsUpdatedDateTo()); + $this->assertEquals($labelIds, $taskForUpdate->getLabelIds()); } } diff --git a/tests/CrowdinApiClient/Model/TaskTest.php b/tests/CrowdinApiClient/Model/TaskTest.php index 0bbdfe36..7962f280 100644 --- a/tests/CrowdinApiClient/Model/TaskTest.php +++ b/tests/CrowdinApiClient/Model/TaskTest.php @@ -12,104 +12,221 @@ class TaskTest extends TestCase 'projectId' => 2, 'creatorId' => 6, 'type' => 1, - 'vendor' => 'gengo', 'status' => 'todo', 'title' => 'French', + 'batchId' => 1, 'assignees' => [ [ 'id' => 1, - 'wordsCount' => 5, + 'username' => 'john.doe', + 'fullName' => 'John Doe', + 'avatarUrl' => '', + 'wordsCount' => 165, + 'wordsLeft' => 5, + 'timeSpent' => 56, ], ], 'assignedTeams' => [ [ 'id' => 1, 'wordsCount' => 5, - ] - ], - 'fileIds' => [ - 1, + 'timeSpent' => 3600, + ], ], 'progress' => [ 'total' => 24, 'done' => 15, 'percent' => 62, ], - 'translateProgress' => null, + 'translateProgress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], 'sourceLanguageId' => 'en', 'targetLanguageId' => 'fr', - 'description' => 'Proofrea all French strings', - 'hash' => 'dac37aff364d83899128e68afe0de4994', - 'translationUrl' => '/proofrea/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'description' => 'Proofread all French strings', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'webUrl' => 'https://crowdin.com/project/example/tasks/2', 'wordsCount' => 24, - 'filesCount' => 2, 'commentsCount' => 0, 'deadline' => '2019-09-27T07:00:14+00:00', + 'startedAt' => '2019-09-25T07:00:14+00:00', + 'resolvedAt' => '2019-09-26T07:00:14+00:00', 'timeRange' => 'string', + 'translationsUpdatedTimeRange' => 'string', 'workflowStepId' => 10, 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', 'createdAt' => '2019-09-23T09:04:29+00:00', 'updatedAt' => '2019-09-23T09:04:29+00:00', + 'sourceLanguage' => [ + 'id' => 'en', + 'name' => 'English', + ], + 'targetLanguages' => [ + [ + 'id' => 'fr', + 'name' => 'French', + ], + ], + 'labelIds' => [13, 27], + 'labelMatchRule' => 'all', + 'excludeLabelIds' => [], + 'excludeLabelMatchRule' => null, + 'precedingTaskId' => 1, + 'estimatedCost' => [ + 'cost' => 10.0, + 'date' => '2019-09-23T09:04:29+00:00', + 'currency' => 'USD', + ], + 'actualCost' => [ + 'cost' => 12.0, + 'date' => '2019-09-23T09:04:29+00:00', + 'currency' => 'USD', + ], + 'generateCostEstimate' => true, + 'generateTranslationCost' => false, + 'reportSettingsTemplateId' => null, + 'vendor' => 'gengo', + 'filesCount' => 2, + 'fileIds' => [1, 2], 'isArchived' => false, 'fields' => [ 'client-company' => 'ACME Corp', ], + 'hash' => 'd41d8cd98f00b204e9800998ecf8427e', ]; public function testLoadData(): void { $task = new Task($this->data); + $this->assertEquals($this->data['id'], $task->getId()); $this->assertEquals($this->data['projectId'], $task->getProjectId()); $this->assertEquals($this->data['creatorId'], $task->getCreatorId()); $this->assertEquals($this->data['type'], $task->getType()); - $this->assertEquals($this->data['vendor'], $task->getVendor()); $this->assertEquals($this->data['status'], $task->getStatus()); $this->assertEquals($this->data['title'], $task->getTitle()); + $this->assertEquals($this->data['batchId'], $task->getBatchId()); $this->assertEquals($this->data['assignees'], $task->getAssignees()); $this->assertEquals($this->data['assignedTeams'], $task->getAssignedTeams()); - $this->assertEquals($this->data['fileIds'], $task->getFileIds()); $this->assertEquals($this->data['progress'], $task->getProgress()); $this->assertEquals($this->data['translateProgress'], $task->getTranslateProgress()); $this->assertEquals($this->data['sourceLanguageId'], $task->getSourceLanguageId()); $this->assertEquals($this->data['targetLanguageId'], $task->getTargetLanguageId()); $this->assertEquals($this->data['description'], $task->getDescription()); - $this->assertEquals($this->data['hash'], $task->getHash()); $this->assertEquals($this->data['translationUrl'], $task->getTranslationUrl()); + $this->assertEquals($this->data['webUrl'], $task->getWebUrl()); $this->assertEquals($this->data['wordsCount'], $task->getWordsCount()); - $this->assertEquals($this->data['filesCount'], $task->getFilesCount()); $this->assertEquals($this->data['commentsCount'], $task->getCommentsCount()); $this->assertEquals($this->data['deadline'], $task->getDeadline()); + $this->assertEquals($this->data['startedAt'], $task->getStartedAt()); + $this->assertEquals($this->data['resolvedAt'], $task->getResolvedAt()); $this->assertEquals($this->data['timeRange'], $task->getTimeRange()); + $this->assertEquals($this->data['translationsUpdatedTimeRange'], $task->getTranslationsUpdatedTimeRange()); $this->assertEquals($this->data['workflowStepId'], $task->getWorkflowStepId()); $this->assertEquals($this->data['buyUrl'], $task->getBuyUrl()); $this->assertEquals($this->data['createdAt'], $task->getCreatedAt()); $this->assertEquals($this->data['updatedAt'], $task->getUpdatedAt()); + $this->assertEquals($this->data['sourceLanguage'], $task->getSourceLanguage()); + $this->assertEquals($this->data['targetLanguages'], $task->getTargetLanguages()); + $this->assertEquals($this->data['labelIds'], $task->getLabelIds()); + $this->assertEquals($this->data['labelMatchRule'], $task->getLabelMatchRule()); + $this->assertEquals($this->data['excludeLabelIds'], $task->getExcludeLabelIds()); + $this->assertEquals($this->data['excludeLabelMatchRule'], $task->getExcludeLabelMatchRule()); + $this->assertEquals($this->data['precedingTaskId'], $task->getPrecedingTaskId()); + $this->assertEquals($this->data['estimatedCost'], $task->getEstimatedCost()); + $this->assertEquals($this->data['actualCost'], $task->getActualCost()); + $this->assertEquals($this->data['generateCostEstimate'], $task->getGenerateCostEstimate()); + $this->assertEquals($this->data['generateTranslationCost'], $task->getGenerateTranslationCost()); + $this->assertEquals($this->data['reportSettingsTemplateId'], $task->getReportSettingsTemplateId()); + $this->assertEquals($this->data['vendor'], $task->getVendor()); + $this->assertEquals($this->data['filesCount'], $task->getFilesCount()); + $this->assertEquals($this->data['fileIds'], $task->getFileIds()); $this->assertEquals($this->data['isArchived'], $task->isArchived()); $this->assertEquals($this->data['fields'], $task->getFields()); + $this->assertEquals($this->data['hash'], $task->getHash()); } public function testSetData(): void { - $task = new Task(); - $task->setStatus($this->data['status']); - $task->setTitle($this->data['title']); - $task->setAssignees($this->data['assignees']); - $task->setAssignedTeams($this->data['assignedTeams']); - $task->setFileIds($this->data['fileIds']); - $task->setDescription($this->data['description']); - $task->setDeadline($this->data['deadline']); - $task->setIsArchived($this->data['isArchived']); - $task->setFields($this->data['fields']); + $status = 'in_progress'; + $title = 'New Title'; + $assignees = [ + [ + 'id' => 2, + 'wordsCount' => 10, + ], + ]; + $assignedTeams = [ + [ + 'id' => 2, + 'wordsCount' => 5, + 'timeSpent' => 7200, + ], + ]; + $fileIds = [3, 4]; + $description = 'New description'; + $deadline = '2021-12-31T23:59:59+00:00'; + $startedAt = '2021-06-01T10:00:00+00:00'; + $resolvedAt = '2021-06-15T10:00:00+00:00'; + $labelIds = [1, 2, 3]; + $labelMatchRule = 'any'; + $excludeLabelIds = [4, 5]; + $excludeLabelMatchRule = 'all'; + $generateCostEstimate = false; + $generateTranslationCost = true; + $reportSettingsTemplateId = 10; + $fields = ['key' => 'value']; + $buyUrl = 'https://example.com/buy'; + $vendor = 'lokalise'; + $isArchived = true; - $this->assertEquals($this->data['status'], $task->getStatus()); - $this->assertEquals($this->data['title'], $task->getTitle()); - $this->assertEquals($this->data['assignees'], $task->getAssignees()); - $this->assertEquals($this->data['assignedTeams'], $task->getAssignedTeams()); - $this->assertEquals($this->data['fileIds'], $task->getFileIds()); - $this->assertEquals($this->data['description'], $task->getDescription()); - $this->assertEquals($this->data['deadline'], $task->getDeadline()); - $this->assertEquals($this->data['isArchived'], $task->isArchived()); - $this->assertEquals($this->data['fields'], $task->getFields()); + $data = $this->data; + $data['excludeLabelMatchRule'] = 'any'; + $data['reportSettingsTemplateId'] = 8; + $task = new Task($data); + + $task->setStatus($status); + $task->setTitle($title); + $task->setAssignees($assignees); + $task->setAssignedTeams($assignedTeams); + $task->setFileIds($fileIds); + $task->setDescription($description); + $task->setDeadline($deadline); + $task->setStartedAt($startedAt); + $task->setResolvedAt($resolvedAt); + $task->setLabelIds($labelIds); + $task->setLabelMatchRule($labelMatchRule); + $task->setExcludeLabelIds($excludeLabelIds); + $task->setExcludeLabelMatchRule($excludeLabelMatchRule); + $task->setGenerateCostEstimate($generateCostEstimate); + $task->setGenerateTranslationCost($generateTranslationCost); + $task->setReportSettingsTemplateId($reportSettingsTemplateId); + $task->setFields($fields); + $task->setBuyUrl($buyUrl); + $task->setVendor($vendor); + $task->setIsArchived($isArchived); + + $this->assertEquals($status, $task->getStatus()); + $this->assertEquals($title, $task->getTitle()); + $this->assertEquals($assignees, $task->getAssignees()); + $this->assertEquals($assignedTeams, $task->getAssignedTeams()); + $this->assertEquals($fileIds, $task->getFileIds()); + $this->assertEquals($description, $task->getDescription()); + $this->assertEquals($deadline, $task->getDeadline()); + $this->assertEquals($startedAt, $task->getStartedAt()); + $this->assertEquals($resolvedAt, $task->getResolvedAt()); + $this->assertEquals($labelIds, $task->getLabelIds()); + $this->assertEquals($labelMatchRule, $task->getLabelMatchRule()); + $this->assertEquals($excludeLabelIds, $task->getExcludeLabelIds()); + $this->assertEquals($excludeLabelMatchRule, $task->getExcludeLabelMatchRule()); + $this->assertEquals($generateCostEstimate, $task->getGenerateCostEstimate()); + $this->assertEquals($generateTranslationCost, $task->getGenerateTranslationCost()); + $this->assertEquals($reportSettingsTemplateId, $task->getReportSettingsTemplateId()); + $this->assertEquals($fields, $task->getFields()); + $this->assertEquals($buyUrl, $task->getBuyUrl()); + $this->assertEquals($vendor, $task->getVendor()); + $this->assertEquals($isArchived, $task->isArchived()); } }