MockDrupalGatherContentClient.php in GatherContent 8.4
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 $choosenStatus = 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::$choosenStatus !== NULL) {
throw new \Exception("itemChooseStatusPost shouldn't be called twice");
}
static::$choosenStatus = $statusId;
}
}