/** * Register a set of values to be merged within the template. * You can either pass a Block, an array of values or a single value * * @param string|array|Block $fieldname * @param string|Image $value * * @return Container * * @throws ContainerException */ public function assign($fieldname, $value = null) { if ($fieldname instanceof Block) { $this->blocks[] = $fieldname; return $this; } if (is_array($fieldname) && !empty($fieldname)) { // bulk fields assignment foreach ($fieldname as $field => $val) { $this->fields[$field] = $val; } return $this; } if (is_string($fieldname) && $value instanceof Image) { $this->images['image:' . $fieldname] = $value->getName(); return $this; } if (is_string($fieldname) && !is_null($value)) { $this->fields[$fieldname] = $value; return $this; } throw new ContainerException('Incorrect parameters for assignment'); }
/** * */ public function test_upload_throw_exception_when_soap_error() { $mock = $this->scaffoldMock(); $mock->getMockController()->UploadImage = function () { throw new Exceptions\SoapException('random exception'); }; $image = new LdxImage($mock); $image->setFilename('test-image-3.dat', __DIR__); file_put_contents(__DIR__ . '/test-image-3.dat', 'some random content'); $this->exception(function () use($image) { $image->upload(); })->isInstanceOf('Awakenweb\\Livedocx\\Exceptions\\Image\\UploadException')->hasMessage('Error while uploading the image')->hasNestedException(); if (file_exists(__DIR__ . '/test-image-3.dat')) { unlink(__DIR__ . '/test-image-3.dat'); } }