/** * Method to test validateUploadedFiles(). * * @return void * * @covers \Windwalker\Http\Helper\ServerHelper::validateUploadedFiles */ public function testValidateUploadedFiles() { $files = array(new UploadedFile('php://memory')); $this->assertTrue(ServerHelper::validateUploadedFiles($files)); // Nested array $files[] = $files; $this->assertTrue(ServerHelper::validateUploadedFiles($files)); }
/** * Create a new instance with the specified uploaded files. * * This method MUST be implemented in such a way as to retain the * immutability of the message, and MUST return an instance that has the * updated body parameters. * * @param array $uploadedFiles An array tree of UploadedFileInterface instances. * * @return static * @throws \InvalidArgumentException if an invalid structure is provided. */ public function withUploadedFiles(array $uploadedFiles) { if (!ServerHelper::validateUploadedFiles($uploadedFiles)) { throw new \InvalidArgumentException('Invalid uploaded files, every file should be an UploadedInterface'); } $new = clone $this; $new->uploadedFiles = $uploadedFiles; return $new; }