commit 01dece36f7b2ec27d2122a089c5674973a96ea67
parent 9a0e8d9bcd46f1d99ecc1a47fc59e2968f293cd1
Author: Felicitus <felicitus@felicitus.org>
Date: Sun, 13 Sep 2015 16:39:17 +0200
Added unit tests for URL file upload and exception handling
Diffstat:
1 file changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/PartKeepr/UploadedFileBundle/Tests/UploadTest.php b/src/PartKeepr/UploadedFileBundle/Tests/UploadTest.php
@@ -78,4 +78,39 @@ class UploadTest extends WebTestCase
$this->assertEquals("TempUploadedFile", $response->response->$property);
}
+
+ public function testURLUploadAction()
+ {
+ $client = static::createClient();
+
+ $client->request(
+ 'POST',
+ '/api/temp_uploaded_files/upload',
+ array("url" => "https://www.partkeepr.org/images/pklogo.svg")
+ );
+
+ $response = json_decode($client->getResponse()->getContent());
+
+ $this->assertObjectHasAttribute("success", $response);
+ $this->assertObjectHasAttribute("image", $response);
+ $this->assertObjectHasAttribute("response", $response);
+ }
+
+ public function testUploadException()
+ {
+ $client = static::createClient();
+
+ $client->request(
+ 'POST',
+ '/api/temp_uploaded_files/upload',
+ array()
+ );
+
+ $response = json_decode($client->getResponse()->getContent());
+
+ $attribute = "@type";
+
+ $this->assertObjectHasAttribute($attribute, $response);
+ $this->assertEquals("Error",$response->$attribute);
+ }
}