class MockDrupalGatherContentClient in GatherContent 8.4
Same name and namespace in other branches
- 8.5 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 - ImporterTest.php in tests/
src/ Kernel/ ImporterTest.php
File
- tests/
modules/ gathercontent_test/ src/ MockDrupalGatherContentClient.php, line 11
Namespace
Drupal\gathercontent_testView source
class MockDrupalGatherContentClient extends DrupalGatherContentClient {
public static $choosenStatus = 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::$choosenStatus !== NULL) {
throw new \Exception("itemChooseStatusPost shouldn't be called twice");
}
static::$choosenStatus = $statusId;
}
}