MockDrupalGatherContentClient.php in GatherContent 8.5
File
tests/modules/gathercontent_test/src/MockDrupalGatherContentClient.php
View source
<?php
namespace Drupal\gathercontent_test;
use Drupal\file\Entity\File;
use Drupal\gathercontent\DrupalGatherContentClient;
class MockDrupalGatherContentClient extends DrupalGatherContentClient {
public static $chosenStatus = NULL;
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;
}
public function itemFilesGet($itemId) {
return [];
}
public function projectStatusGet($projectId, $statusId) {
$statuses = MockData::getStatuses();
return $statuses[$statusId];
}
public function itemChooseStatusPost($itemId, $statusId) {
if (static::$chosenStatus !== NULL) {
throw new \Exception("itemChooseStatusPost shouldn't be called twice");
}
static::$chosenStatus = $statusId;
}
}