Skip to content

Commit

Permalink
Add textmasters parameters on translation creation (#32)
Browse files Browse the repository at this point in the history
* Add textmasters parameters on translation creation

* Fix behat tests
  • Loading branch information
LaetitiaRiffaud authored and Pierre Ducoudray committed Feb 8, 2017
1 parent 570ba23 commit 9a9df2e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 12 deletions.
15 changes: 13 additions & 2 deletions Features/Context/TranslationContextTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function assertJobs(TableNode $table)
public function createTranslationProject(TableNode $table)
{
foreach ($table->getHash() as $data) {
$this->getTranslationGenerator()->generate(
$project = $this->getTranslationGenerator()->generate(
$data['finder'],
json_decode($data['filter'], true),
$data['languageFrom'],
Expand All @@ -97,8 +97,19 @@ public function createTranslationProject(TableNode $table)
$data['briefing'],
isset($data['languageTo']) ? $data['languageTo'] : null,
json_decode($data['options'], true),
isset($data['activity']) ? $data['activity'] : null
isset($data['activity']) ? $data['activity'] : null,
isset($data['workTemplate']) ? $data['workTemplate'] : null,
json_decode($data['textmasters'], true)
);

PHPUnit_Framework_Assert::assertSame($data['name'], $project->getName());
PHPUnit_Framework_Assert::assertSame(isset($data['activity']) ? $data['activity'] : null, $project->getActivity());
PHPUnit_Framework_Assert::assertSame($data['languageFrom'], $project->getLanguageFrom());
PHPUnit_Framework_Assert::assertSame(isset($data['languageTo']) ? $data['languageTo'] : null, $project->getLanguageTo());
PHPUnit_Framework_Assert::assertSame($data['category'], $project->getCategory());
PHPUnit_Framework_Assert::assertSame($data['briefing'], $project->getBriefing());
PHPUnit_Framework_Assert::assertSame(json_decode($data['options'], true), $project->getOptions());
PHPUnit_Framework_Assert::assertSame(json_decode($data['textmasters'], true), $project->getTextmasters());
}
}

Expand Down
4 changes: 2 additions & 2 deletions Features/copywriting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Feature: Copywriting management
| Hello NYC | NYC is the big apple | en |
Then I should have "0" translatables with job for class "Worldia\Bundle\ProductTestBundle\Entity\Product"
When I generate a translation batch with the following parameters:
| finder | filter | name | languageFrom | category | briefing | options | activity |
| product | {} | PROJECT-1 | en | C054 | Nothing | {"language_level": "premium"} | copywriting |
| finder | filter | name | languageFrom | category | briefing | options | activity | textmasters |
| product | {} | PROJECT-1 | en | C054 | Nothing | {"language_level": "premium"} | copywriting | [] |
Then I should have "2" translatables with job for class "Worldia\Bundle\ProductTestBundle\Entity\Product"
When I receive the request '{ "id": "PROJECT-1", "name": "PROJECT-1", "status": "in_progress"}'
Then I should have the following jobs:
Expand Down
4 changes: 2 additions & 2 deletions Features/translation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Feature: Translation management
| Hello NYC | NYC is the big apple | en |
Then I should have "0" translatables with job for class "Worldia\Bundle\ProductTestBundle\Entity\Product"
When I generate a translation batch with the following parameters:
| finder | filter | name | languageFrom | languageTo | category | briefing | options | activity |
| product | {} | PROJECT-1 | en | fr | C054 | Nothing | {"language_level": "premium"} | translation |
| finder | filter | name | languageFrom | languageTo | category | briefing | options | activity | textmasters |
| product | {} | PROJECT-1 | en | fr | C054 | Nothing | {"language_level": "premium"} | translation | ["55c3763e656462000b000027"] |
Then I should have "2" translatables with job for class "Worldia\Bundle\ProductTestBundle\Entity\Product"
When I receive the request '{ "id": "PROJECT-1", "name": "PROJECT-1", "status": "in_progress"}'
Then I should have the following jobs:
Expand Down
3 changes: 3 additions & 0 deletions Tests/Units/Translation/TranslationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public function shouldCreateProject()
$projectMock->expects($this->once())
->method('setWorkTemplate')
->willReturn($projectMock);
$projectMock->expects($this->once())
->method('setTextmasters')
->willReturn($projectMock);
$projectMock->expects($this->once())
->method('save')
->willReturn($projectMock);
Expand Down
5 changes: 3 additions & 2 deletions Translation/TranslationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function generate(
$languageTo = null,
array $options = [],
$activity = ProjectInterface::ACTIVITY_TRANSLATION,
$workTemplate = null
$workTemplate = null,
$textmasters = []
) {
if (null === $locale = $languageTo) {
$locale = $languageFrom;
Expand All @@ -60,7 +61,7 @@ public function generate(
return;
}

$project = $this->translationManager->create($translatables, $name, $languageFrom, $category, $briefing, $languageTo, $options, $activity, $workTemplate);
$project = $this->translationManager->create($translatables, $name, $languageFrom, $category, $briefing, $languageTo, $options, $activity, $workTemplate, $textmasters);

if (!array_key_exists('translation_memory', $project->getOptions())) {
$project->launch();
Expand Down
4 changes: 3 additions & 1 deletion Translation/TranslationGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface TranslationGeneratorInterface
* @param array $options textmaster project options
* @param string $activity textmaster project activity
* @param string $workTemplate textmaster project work template
* @param array $textmasters ids of the authors
*
* @return ProjectInterface|null
*/
Expand All @@ -32,6 +33,7 @@ public function generate(
$languageTo = null,
array $options = [],
$activity,
$workTemplate = null
$workTemplate = null,
$textmasters = []
);
}
4 changes: 3 additions & 1 deletion Translation/TranslationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function create(
$languageTo = null,
array $options = [],
$activity = ProjectInterface::ACTIVITY_TRANSLATION,
$workTemplate = null
$workTemplate = null,
$textmasters = []
) {
$translationMemory = false;
if (array_key_exists('translation_memory', $options)) {
Expand All @@ -81,6 +82,7 @@ public function create(
->setOptions($options)
->setWorkTemplate($workTemplate)
->setCallback($this->generateProjectCallback())
->setTextmasters($textmasters)
;

$project->save();
Expand Down
3 changes: 2 additions & 1 deletion Translation/TranslationManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function create(
$languageTo = null,
array $options = [],
$activity = ProjectInterface::ACTIVITY_TRANSLATION,
$workTemplate = null
$workTemplate = null,
$textmasters = []
);

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=5.6.0",
"worldia/textmaster-api": "^0.4",
"worldia/textmaster-api": "^0.5",
"symfony/framework-bundle": "^3.2",
"symfony/property-access": "^3.2",
"symfony/validator": "^3.2",
Expand Down

0 comments on commit 9a9df2e

Please sign in to comment.