Ejemplo n.º 1
0
 /**
  * @covers \Smartling\File\FileApi::import
  */
 public function testImport()
 {
     $locale = 'en-EN';
     $endpointUrl = vsprintf('%s/%s/locales/%s/file/import', [FileApi::ENDPOINT_URL, $this->projectId, $locale]);
     $this->client->expects(self::once())->method('request')->with('POST', $endpointUrl, ['headers' => ['Accept' => 'application/json', 'Authorization' => vsprintf(' %s %s', [$this->authProvider->getTokenType(), $this->authProvider->getAccessToken()])], 'http_errors' => false, 'multipart' => [['name' => 'file', 'contents' => $this->streamPlaceholder], ['name' => 'fileUri', 'contents' => 'test.xml'], ['name' => 'fileType', 'contents' => 'xml'], ['name' => 'translationState', 'contents' => 'PUBLISHED'], ['name' => 'overwrite', 'contents' => '0']]])->willReturn($this->responseMock);
     $this->invokeMethod($this->object, 'setAuth', [$this->authProvider]);
     $this->object->import($locale, 'test.xml', 'xml', 'tests/resources/test.xml', 'PUBLISHED', false);
 }
Ejemplo n.º 2
0
/**
 * @param string $userIdentifier
 * @param string $userSecretKey
 * @param string $projectId
 * @param array  $files
 */
function resetFiles($userIdentifier, $userSecretKey, $projectId, $files = [])
{
    $authProvider = \Smartling\AuthApi\AuthTokenProvider::create($userIdentifier, $userSecretKey);
    foreach ($files as $file) {
        try {
            $fileApi = \Smartling\File\FileApi::create($authProvider, $projectId);
            $fileApi->deleteFile($file);
        } catch (\Smartling\Exceptions\SmartlingApiException $e) {
        }
    }
}