class MockDrupalGatherContentClient in GatherContent 8.5
Same name and namespace in other branches
- 8.4 tests/modules/gathercontent_test/src/MockDrupalGatherContentClient.php \Drupal\gathercontent_test\MockDrupalGatherContentClient
Class to mock GC client.
Hierarchy
- class \Drupal\gathercontent\DrupalGatherContentClient extends \Cheppers\GatherContent\GatherContentClient
- class \Drupal\gathercontent_test\MockDrupalGatherContentClient
Expanded class hierarchy of MockDrupalGatherContentClient
2 files declare their use of MockDrupalGatherContentClient
- GcImportTestBase.php in tests/
src/ Kernel/ GcImportTestBase.php - GcMigrateTestBase.php in tests/
src/ Kernel/ GcMigrateTestBase.php
File
- tests/
modules/ gathercontent_test/ src/ MockDrupalGatherContentClient.php, line 11
Namespace
Drupal\gathercontent_testView source
class MockDrupalGatherContentClient extends DrupalGatherContentClient {
/**
* Chosen status.
*
* @var null|int
*/
public static $chosenStatus = NULL;
/**
* Mock download.
*/
public function downloadFiles(array $files, $directory, $language) {
$importedFiles = [];
foreach ($files as $file) {
$importedFile = File::create([
'filename' => $file->fileName,
'uri' => $file->url,
'status' => 1,
'gc_id' => $file->id,
'langcode' => $language,
'filesize' => $file->size,
]);
$importedFile
->save();
$importedFiles[] = $importedFile
->id();
}
return $importedFiles;
}
/**
* Mock files fetch.
*/
public function itemFilesGet($itemId) {
return [];
}
/**
* Mock status fetch.
*/
public function projectStatusGet($projectId, $statusId) {
$statuses = MockData::getStatuses();
return $statuses[$statusId];
}
/**
* Mock status change.
*/
public function itemChooseStatusPost($itemId, $statusId) {
if (static::$chosenStatus !== NULL) {
throw new \Exception("itemChooseStatusPost shouldn't be called twice");
}
static::$chosenStatus = $statusId;
}
}