Commit 30201dff authored by Loparev's avatar Loparev
Browse files

Fixed tests

parent 9dd31bdc
......@@ -11,6 +11,27 @@ use Smartling\AuditLog\Params\CreateRecordParameters;
*/
class UploadFlowTest extends SmartlingTestBase {
/**
* Asserts upload parameters.
*
* @param $subject
* @return bool
*/
public function assertUploadParameters($subject) {
$params = $subject->exportToArray();
return $params['authorize'] == 0 &&
preg_match('/^{"client":"drupal-tmgmt-connector","version":"(\d+\.x-\d+\.\d+|\d+\.x-\d+\.x-dev|unknown)"}$/', $params['smartling.client_lib_id']) &&
$params['localeIdsToAuthorize'][0] == 'de' &&
$params['smartling.translate_paths'] == 'html/body/div/div, html/body/div/span' &&
$params['smartling.string_format_paths'] == 'html : html/body/div/div, @default : html/body/div/span' &&
$params['smartling.variants_enabled'] == TRUE &&
$params['smartling.source_key_paths'] == 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}' &&
$params['smartling.character_limit_paths'] == 'html/body/div/limit' &&
$params['smartling.placeholder_format_custom'] == '(@|%|!)[\w-]+' &&
$params['smartling.include_translatable_attributes'] == 'title, alt';
}
/**
* Upload success flow with batch execution.
*/
......@@ -45,26 +66,11 @@ class UploadFlowTest extends SmartlingTestBase {
$this->batchApiMock->expects($this->once())
->method('uploadBatchFile')
->with(
$this->callback(function($subject) {
return strstr($subject, '/files/tmgmt_sources/JobID1_en_de.xml') !== FALSE;
}),
'public://tmgmt_sources/JobID1_en_de.xml',
'JobID1_en_de.xml',
'xml',
'uid',
$this->callback(function($subject) {
$params = $subject->exportToArray();
return $params['authorize'] == 0 &&
preg_match('/^{"client":"drupal-tmgmt-connector","version":"(\d+\.x-\d+\.\d+|\d+\.x-\d+\.x-dev|unknown)"}$/', $params['smartling.client_lib_id']) &&
$params['localeIdsToAuthorize'][0] == 'de' &&
$params['smartling.translate_paths'] == 'html/body/div/div, html/body/div/span' &&
$params['smartling.string_format_paths'] == 'html : html/body/div/div, @default : html/body/div/span' &&
$params['smartling.variants_enabled'] == TRUE &&
$params['smartling.source_key_paths'] == 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}' &&
$params['smartling.character_limit_paths'] == 'html/body/div/limit' &&
$params['smartling.placeholder_format_custom'] == '(@|%|!)[\w-]+' &&
$params['smartling.include_translatable_attributes'] == 'title, alt';
})
$this->callback([$this, 'assertUploadParameters'])
);
$this->apiWrapperMock->expects($this->once())
......@@ -134,25 +140,11 @@ class UploadFlowTest extends SmartlingTestBase {
$this->batchApiMock->expects($this->once())
->method('uploadBatchFile')
->with(
$this->callback(function($subject) {
return strstr($subject, '/files/tmgmt_sources/JobID1_en_de.xml') !== FALSE;
}),
'public://tmgmt_sources/JobID1_en_de.xml',
'JobID1_en_de.xml',
'xml',
'uid',
$this->callback(function($subject) {
$params = $subject->exportToArray();
return $params['authorize'] == 0 &&
preg_match('/^{"client":"drupal-tmgmt-connector","version":"(\d+\.x-\d+\.\d+|\d+\.x-\d+\.x-dev|unknown)"}$/', $params['smartling.client_lib_id']) &&
$params['localeIdsToAuthorize'][0] == 'de' &&
$params['smartling.translate_paths'] == 'html/body/div/div, html/body/div/span' &&
$params['smartling.string_format_paths'] == 'html : html/body/div/div, @default : html/body/div/span' &&
$params['smartling.variants_enabled'] == TRUE &&
$params['smartling.source_key_paths'] == 'html/body/div/{div.sl-variant}, html/body/div/{span.sl-variant}' &&
$params['smartling.character_limit_paths'] == 'html/body/div/limit' &&
$params['smartling.placeholder_format_custom'] == '(@|%|!)[\w-]+';
})
$this->callback([$this, 'assertUploadParameters'])
);
$this->apiWrapperMock->expects($this->never())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment