Skip to content

Commit

Permalink
Fix key for array callback for project (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Ducoudray authored and cdaguerre committed May 20, 2016
1 parent 28e75e7 commit 9aefd4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/Textmaster/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ public function getCallback()
*/
public function setCallback(array $callback)
{
if (!array_key_exists(ProjectInterface::STATUS_IN_PROGRESS, $callback)) {
if (!array_key_exists(self::CALLBACK_KEY, $callback) || 1 < count($callback)) {
throw new InvalidArgumentException(sprintf(
'Only key for array callback allowed is "%s"',
ProjectInterface::STATUS_IN_PROGRESS
));
self::CALLBACK_KEY
));
}

$this->data['callback'] = $callback;
Expand Down
2 changes: 2 additions & 0 deletions lib/Textmaster/Model/ProjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ interface ProjectInterface
const STATUS_PAUSED = 'paused';
const STATUS_CANCELED = 'canceled';

const CALLBACK_KEY = 'project_in_progress';

/**
* Get id.
*
Expand Down
2 changes: 1 addition & 1 deletion test/Textmaster/Unit/Model/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function shouldCreateEmpty()
$category = 'C014';
$briefing = 'Lorem ipsum...';
$options = array('language_level' => 'premium');
$callback = array(ProjectInterface::STATUS_IN_PROGRESS => 'http://callback.url');
$callback = array(ProjectInterface::CALLBACK_KEY => 'http://callback.url');

$project = new Project($this->clientMock);
$project
Expand Down

0 comments on commit 9aefd4b

Please sign in to comment.