public function LingotekUnitTest::testUploadDocument in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 4.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.1.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.2.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.3.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.4.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.5.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.6.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.7.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
- 3.8.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testUploadDocument()
@covers ::uploadDocument
File
- tests/
src/ Unit/ LingotekUnitTest.php, line 270
Class
- LingotekUnitTest
- @coversDefaultClass \Drupal\lingotek\Lingotek @group lingotek @preserveGlobalState disabled
Namespace
Drupal\Tests\lingotek\UnitCode
public function testUploadDocument() {
$this->config
->expects($this
->any())
->method('get')
->will($this
->returnValueMap([
[
'default.project',
'default_project',
],
[
'default.vault',
'default_vault',
],
]));
// Vault id has the original value.
$this->api
->expects($this
->at(0))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'format' => 'JSON',
'project_id' => 'my_test_project',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'vault_id' => 'my_test_vault',
]);
// Vault id has changed.
$this->api
->expects($this
->at(1))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'format' => 'JSON',
'project_id' => 'another_test_project',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'vault_id' => 'another_test_vault',
]);
// If there is a profile with default vault, it must be replaced.
$this->api
->expects($this
->at(2))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'format' => 'JSON',
'project_id' => 'default_project',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'vault_id' => 'default_vault',
]);
// If there is no profile, vault should not be included.
$this->api
->expects($this
->at(3))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'format' => 'JSON',
'project_id' => 'default_project',
]);
// If there is an url, it should be included.
$this->api
->expects($this
->at(4))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'format' => 'JSON',
'project_id' => 'default_project',
'external_url' => 'http://example.com/node/1',
]);
// If there is a profile using the project default workflow template vault,
// vault should not be specified.
$this->api
->expects($this
->at(5))
->method('addDocument')
->with([
'title' => 'title',
'content' => 'content',
'locale_code' => 'es',
'fprm_subfilter_id' => '0e79f34d-f27b-4a0c-880e-cd9181a5d265',
'format' => 'JSON',
'project_id' => 'default_project',
]);
// We upload with a profile that has a vault and a project.
$profile = new LingotekProfile([
'id' => 'profile1',
'project' => 'my_test_project',
'vault' => 'my_test_vault',
], 'lingotek_profile');
$this->lingotek
->uploadDocument('title', 'content', 'es', NULL, $profile);
// We upload with a profile that has another vault and another project.
$profile = new LingotekProfile([
'id' => 'profile2',
'project' => 'another_test_project',
'vault' => 'another_test_vault',
], 'lingotek_profile');
$this->lingotek
->uploadDocument('title', 'content', 'es', NULL, $profile);
// We upload with a profile that has marked to use the default vault and project,
// so must be replaced.
$profile = new LingotekProfile([
'id' => 'profile2',
'project' => 'default',
'vault' => 'default',
], 'lingotek_profile');
$this->lingotek
->uploadDocument('title', 'content', 'es', NULL, $profile);
// We upload without a profile.
$this->lingotek
->uploadDocument('title', 'content', 'es', NULL, NULL);
// We upload without a profile, but with url.
$this->lingotek
->uploadDocument('title', 'content', 'es', 'http://example.com/node/1', NULL);
// We upload with a profile that has marked to use the project default
// workflow template vault, so must be omitted.
$profile = new LingotekProfile([
'id' => 'profile2',
'project' => 'default',
'vault' => 'project_workflow_vault',
], 'lingotek_profile');
$this->lingotek
->uploadDocument('title', 'content', 'es', NULL, $profile);
}