Source of file MockBucket.php
Size: 2,323 Bytes - Last Modified: 2021-12-23T10:03:12+00:00
/var/www/docs.ssmods.com/process/src/tests/MockBucket.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 | <?php /** * Stubs out all the cloud calls for testing. * * @author Mark Guinn <mark@adaircreative.com> * @date 01.10.2014 * @package cloudassets * @subpackage buckets */ class MockBucket extends CloudBucket { public $uploads = array(); public $deletes = array(); public $renames = array(); public $uploadContents = array(); /** * @param File $f */ public function put(File $f) { $this->uploads[] = $f->Filename; $this->uploadContents[ $f->Filename ] = file_get_contents($f->getFullPath()); } /** * @param File|string $f */ public function delete($f) { $this->deletes[] = is_object($f) ? $f->Filename : $f; } /** * @param File $f * @param string $beforeName - contents of the Filename property (i.e. relative to site root) * @param string $afterName - contents of the Filename property (i.e. relative to site root) */ public function rename(File $f, $beforeName, $afterName) { $this->renames[$beforeName] = $afterName; } /** * @param File $f * @throws Exception * @return string */ public function getContents(File $f) { if (isset($this->uploadContents[$f->Filename])) { return $this->uploadContents[$f->Filename]; } throw new Exception("Remote file not found"); } /** * @param string|File $f * @return bool */ public function wasDeleted($f) { return in_array(is_object($f) ? $f->Filename : $f, $this->deletes); } /** * @param string|File $f * @return bool */ public function wasUploaded($f) { return in_array(is_object($f) ? $f->Filename : $f, $this->uploads); } /** * @param string|File $newName * @param string $oldName * @return bool */ public function wasRenamed($newName, $oldName) { if (is_object($newName)) { $newName = $newName->Filename; } return $newName == $this->renames[$oldName]; } /** * Wipes upload/delete/etc log */ public function clearActivityLog() { $this->uploads = array(); $this->deletes = array(); $this->renames = array(); $this->uploadContents = array(); } } |