|
@@ -549,7 +549,36 @@ class UploadableEntityTest extends BaseTestCaseORM
|
|
|
$this->em->flush();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @expectedException Gedmo\Exception\InvalidArgumentException
|
|
|
+ * @dataProvider invalidFileInfoClassesProvider
|
|
|
+ */
|
|
|
+ public function test_setDefaultFileInfoClass_throwExceptionIfInvalidClassArePassed($class)
|
|
|
+ {
|
|
|
+ $this->listener->setDefaultFileInfoClass($class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test_setDefaultFileInfoClass_setClassIfClassIsValid()
|
|
|
+ {
|
|
|
+ $validClass = 'Gedmo\\Uploadable\\FileInfo\\FileInfoArray';
|
|
|
+
|
|
|
+ $this->listener->setDefaultFileInfoClass($validClass);
|
|
|
+
|
|
|
+ $this->assertEquals($validClass, $this->listener->getDefaultFileInfoClass());
|
|
|
+ }
|
|
|
+
|
|
|
// Data Providers
|
|
|
+ public function invalidFileInfoClassesProvider()
|
|
|
+ {
|
|
|
+ return array(
|
|
|
+ array(''),
|
|
|
+ array(false),
|
|
|
+ array(null),
|
|
|
+ array('FakeFileInfo'),
|
|
|
+ array(array()),
|
|
|
+ array(new \DateTime())
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
public function uploadExceptionsProvider()
|
|
|
{
|
|
@@ -566,6 +595,8 @@ class UploadableEntityTest extends BaseTestCaseORM
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// Util
|
|
|
|
|
|
private function generateUploadedFile($index = 'image', $filePath = false, $filename = false, array $info = array())
|
|
@@ -628,6 +659,10 @@ class UploadableEntityTest extends BaseTestCaseORM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+class FakeFileInfo
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
class FakeFilenameGenerator implements \Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorInterface
|
|
|
{
|
|
|
public static function generate($filename, $extension)
|