1 | <?php |
||
2 | |||
3 | namespace Dynamic\ImageUpload\Tests; |
||
4 | |||
5 | use Dynamic\ImageUpload\ImageUploadField; |
||
6 | use Dynamic\ImageUpload\Tests\Field\CustomImageUploadField; |
||
7 | use SilverStripe\AssetAdmin\Forms\UploadField; |
||
0 ignored issues
–
show
|
|||
8 | use SilverStripe\Core\Config\Config; |
||
9 | use SilverStripe\Core\Convert; |
||
10 | use SilverStripe\Dev\SapphireTest; |
||
11 | |||
12 | /** |
||
13 | * Class ImageUploadFieldTest |
||
14 | */ |
||
15 | class ImageUploadFieldTest extends SapphireTest |
||
16 | { |
||
17 | /** |
||
18 | * |
||
19 | */ |
||
20 | public function test__construct() |
||
21 | { |
||
22 | $field = ImageUploadField::create('Image'); |
||
23 | $this->assertInstanceOf(UploadField::class, $field); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | */ |
||
29 | public function testMaxUpload() |
||
30 | { |
||
31 | $this->markTestSkipped('Issue with fetching config values'); |
||
32 | |||
33 | $this->assertEquals(ImageUploadField::config()->get('ImageUploadField', 'max_upload'), 1024000); |
||
34 | Config::modify()->set(ImageUploadField::class, 'max_upload', 512000); |
||
35 | $this->assertEquals(ImageUploadField::config()->get('ImageUploadField', 'max_upload'), 512000); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * |
||
40 | */ |
||
41 | public function testINIUploadLimitCheck() |
||
42 | { |
||
43 | $iniMax = Convert::memstring2bytes(ini_get('post_max_size')); |
||
44 | $over = $iniMax * 2; |
||
45 | $under = $iniMax / 2; |
||
46 | |||
47 | Config::modify()->set(ImageUploadField::class, 'max_upload', $over); |
||
48 | $imageField = ImageUploadField::create('testField'); |
||
49 | $this->assertEquals($imageField->getValidator()->getAllowedMaxFileSize(), $iniMax); |
||
50 | |||
51 | Config::modify()->set(ImageUploadField::class, 'max_upload', $under); |
||
52 | $imageField2 = ImageUploadField::create('testField2'); |
||
53 | $this->assertEquals($imageField2->getValidator()->getAllowedMaxFileSize(), $under); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | */ |
||
59 | public function testExtendedField() |
||
60 | { |
||
61 | $this->markTestSkipped('Subclasses currenlty don\'t override the config value'); |
||
62 | |||
63 | $imageField = CustomImageUploadField::create('testImageField'); |
||
64 | $this->assertEquals($imageField->getValidator()->getAllowedMaxFileSize(), 512000); |
||
65 | |||
66 | Config::inst()->update('CustomImageUploadField', 'max_upload', 256000); |
||
67 | $imageField2 = new CustomImageUploadField('testImageField2'); |
||
68 | $this->assertEquals($imageField2->getValidator()->getAllowedMaxFileSize(), 256000); |
||
69 | } |
||
70 | } |
||
71 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths