class ContextApiFunctionalTest in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.2 api-sdk-php/tests/functional/ContextApiFunctionalTest.php \Smartling\Tests\Functional\ContextApiFunctionalTest
- 8.2 vendor/smartling/api-sdk-php/tests/functional/ContextApiFunctionalTest.php \Smartling\Tests\Functional\ContextApiFunctionalTest
- 8.3 vendor/smartling/api-sdk-php/tests/functional/ContextApiFunctionalTest.php \Smartling\Tests\Functional\ContextApiFunctionalTest
Test class for Project API examples.
Hierarchy
- class \Smartling\Tests\Functional\ContextApiFunctionalTest extends \PHPUnit_Framework_TestCase
Expanded class hierarchy of ContextApiFunctionalTest
File
- vendor/
smartling/ api-sdk-php/ tests/ functional/ ContextApiFunctionalTest.php, line 16
Namespace
Smartling\Tests\FunctionalView source
class ContextApiFunctionalTest extends PHPUnit_Framework_TestCase {
/**
* @var ContextApi
*/
private $contextApi;
/**
* Test mixture.
*/
public function setUp() {
$projectId = getenv('project_id');
$userIdentifier = getenv('user_id');
$userSecretKey = getenv('user_key');
if (empty($projectId) || empty($userIdentifier) || empty($userSecretKey)) {
$this
->fail('Missing required parameters');
}
$authProvider = AuthTokenProvider::create($userIdentifier, $userSecretKey);
$this->contextApi = ContextApi::create($authProvider, $projectId);
}
/**
* Test for upload context.
*/
public function testUploadContext() {
try {
$params = new UploadContextParameters();
$params
->setContent('tests/resources/context.html');
$params
->setName('test_context.html');
$result = $this->contextApi
->uploadContext($params);
$this
->assertArrayHasKey('contextUid', $result);
$this
->assertArrayHasKey('contextType', $result);
$this
->assertArrayHasKey('name', $result);
$this
->assertArrayHasKey('created', $result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
/**
* Test for match context.
*/
public function testMatchContext() {
try {
$fileUri = 'tests/resources/context.html';
$params = new UploadContextParameters();
$params
->setContent($fileUri);
$params
->setName('test_context.html');
$contextInfo = $this->contextApi
->uploadContext($params);
$params = new MatchContextParameters();
$params
->setContentFileUri($fileUri);
$result = $this->contextApi
->matchContext($contextInfo['contextUid'], $params);
$this
->assertArrayHasKey('matchId', $result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
/**
* Test for upload and match context.
*/
public function testUploadAndMatchContext() {
try {
$fileUri = 'tests/resources/context.html';
$matchParams = new MatchContextParameters();
$matchParams
->setContentFileUri($fileUri);
$params = new UploadContextParameters();
$params
->setContent($fileUri);
$params
->setMatchParams($matchParams);
$params
->setName('test_context.html');
$result = $this->contextApi
->uploadAndMatchContext($params);
$this
->assertArrayHasKey('matchId', $result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
/**
* Test for get missing resources.
*/
public function testGetMissingResources() {
try {
$result = $this->contextApi
->getMissingResources();
$this
->assertArrayHasKey('items', $result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
/**
* Test for get all missing resources.
*/
public function testGetAllMissingResources() {
try {
$result = $this->contextApi
->getAllMissingResources();
$this
->assertArrayHasKey('items', $result);
$this
->assertArrayHasKey('all', $result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
/**
* Test for render context.
*/
public function testRenderContext() {
try {
$params = new UploadContextParameters();
$params
->setContent('tests/resources/context.html');
$params
->setName('test_context.html');
$contextInfo = $this->contextApi
->uploadContext($params);
$result = $this->contextApi
->renderContext($contextInfo['contextUid']);
$this
->assertTrue($result);
} catch (SmartlingApiException $e) {
$this
->fail($e
->getMessage());
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextApiFunctionalTest:: |
private | property | ||
ContextApiFunctionalTest:: |
public | function | Test mixture. | |
ContextApiFunctionalTest:: |
public | function | Test for get all missing resources. | |
ContextApiFunctionalTest:: |
public | function | Test for get missing resources. | |
ContextApiFunctionalTest:: |
public | function | Test for match context. | |
ContextApiFunctionalTest:: |
public | function | Test for render context. | |
ContextApiFunctionalTest:: |
public | function | Test for upload and match context. | |
ContextApiFunctionalTest:: |
public | function | Test for upload context. |