public function SmartlingTestBase::setUp in TMGMT Translator Smartling 8.4
Same name in this branch
- 8.4 tests/src/Functional/SmartlingTestBase.php \Drupal\Tests\tmgmt_smartling\Functional\SmartlingTestBase::setUp()
- 8.4 tests/src/Kernel/SmartlingTestBase.php \Drupal\Tests\tmgmt_smartling\Kernel\SmartlingTestBase::setUp()
Same name and namespace in other branches
- 8.3 tests/src/Kernel/SmartlingTestBase.php \Drupal\Tests\tmgmt_smartling\Kernel\SmartlingTestBase::setUp()
Overrides TMGMTKernelTestBase::setUp
5 calls to SmartlingTestBase::setUp()
- BaseFlowTest::setUp in tests/
src/ Kernel/ BaseFlowTest.php - BufferLoggerTest::setUp in tests/
src/ Kernel/ BufferLoggerTest.php - SmartlingTranslatorTest::setUp in tests/
src/ Kernel/ SmartlingTranslatorTest.php - TranslationRequestManagerTest::setUp in tests/
src/ Kernel/ TranslationRequestManagerTest.php - XmlPluginTest::setUp in tests/
src/ Kernel/ XmlPluginTest.php
5 methods override SmartlingTestBase::setUp()
- BaseFlowTest::setUp in tests/
src/ Kernel/ BaseFlowTest.php - BufferLoggerTest::setUp in tests/
src/ Kernel/ BufferLoggerTest.php - SmartlingTranslatorTest::setUp in tests/
src/ Kernel/ SmartlingTranslatorTest.php - TranslationRequestManagerTest::setUp in tests/
src/ Kernel/ TranslationRequestManagerTest.php - XmlPluginTest::setUp in tests/
src/ Kernel/ XmlPluginTest.php
File
- tests/
src/ Kernel/ SmartlingTestBase.php, line 27
Class
- SmartlingTestBase
- Smartling kernel test base class.
Namespace
Drupal\Tests\tmgmt_smartling\KernelCode
public function setUp() : void {
parent::setUp();
// Suppress deprecation errors.
set_error_handler(function ($errno) {
if ($errno == E_USER_DEPRECATED) {
return TRUE;
}
return FALSE;
});
$this
->installConfig([
'tmgmt_smartling',
'tmgmt_extension_suit',
'tmgmt_file',
'file',
]);
$this
->installSchema('file', [
'file_usage',
]);
$this
->installEntitySchema('file');
$this
->installEntitySchema('tmgmt_remote');
$this->pluginMock = $this
->getMockBuilder('\\Drupal\\tmgmt_smartling\\Plugin\\tmgmt_file\\Format\\Xml')
->setMethods([
'validateImport',
'import',
])
->getMock();
$format_manager_mock = $this
->getMockBuilder('\\Drupal\\tmgmt_file\\Format\\FormatManager')
->disableOriginalConstructor()
->setMethods([
'createInstance',
])
->getMock();
$format_manager_mock
->expects($this
->any())
->method('createInstance')
->willReturn($this->pluginMock);
$api_factory_mock = $this
->getMockBuilder('\\Drupal\\tmgmt_smartling\\Smartling\\SmartlingApiFactory')
->setMethods(NULL)
->getMock();
$this->loggerMock = $this
->getMockBuilder('\\Drupal\\Core\\Logger\\LoggerChannel')
->setMethods(NULL)
->disableOriginalConstructor()
->getMock();
$this->batchApiMock = $this
->getMockBuilder(BatchApi::class)
->disableOriginalConstructor()
->setMethods([
'uploadBatchFile',
])
->getMock();
$this->fileApiMock = $this
->getMockBuilder(FileApi::class)
->disableOriginalConstructor()
->getMock();
$this->translationRequestManagerMock = $this
->getMockBuilder(TranslationRequestManager::class)
->disableOriginalConstructor()
->setMethods([
'getSubmitterName',
'getBucketName',
'upsertTranslationRequest',
'getTranslationRequest',
'commitSuccessfulDownload',
'commitSuccessfulUpload',
'commitError',
])
->getMock();
$this->translationRequestManagerMock
->expects($this
->any())
->method('getSubmitterName')
->willReturn('test_submitter_name');
$this->translationRequestManagerMock
->expects($this
->any())
->method('getBucketName')
->willReturn('test_bucket_name');
$this->apiWrapperMock = $this
->getMockBuilder('\\Drupal\\tmgmt_smartling\\Smartling\\SmartlingApiWrapper')
->setMethods([
'createFirebaseRecord',
'getApi',
'executeBatch',
'searchTranslationRequest',
'createAuditLogRecord',
])
->setConstructorArgs([
$api_factory_mock,
$this->loggerMock,
])
->getMock();
\Drupal::getContainer()
->set('tmgmt_smartling.smartling_api_wrapper', $this->apiWrapperMock);
\Drupal::getContainer()
->set('tmgmt_smartling.translation_request_manager', $this->translationRequestManagerMock);
\Drupal::getContainer()
->set('plugin.manager.tmgmt_file.format', $format_manager_mock);
}