Completed
Push — master ( 847f18...ad1cdb )
by Nic
11s
created

ImageUploadFieldTest::testMaxUpload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * Class ImageUploadFieldTest
5
 */
6
class ImageUploadFieldTest extends SapphireTest
7
{
8
9
    /**
10
     *
11
     */
12
    public function test__construct()
0 ignored issues
show
Coding Style introduced by
Method name "ImageUploadFieldTest::test__construct" is not in camel caps format
Loading history...
13
    {
14
        $field = new ImageUploadField('Image');
15
        $this->assertInstanceOf('UploadField', $field);
1 ignored issue
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<ImageUploadFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16
    }
17
18
    /**
19
     *
20
     */
21
    public function testMaxUpload()
22
    {
23
        $this->assertEquals(Config::inst()->get('ImageUploadField', 'max_upload'), 1024000);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ImageUploadFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24
        Config::inst()->update('ImageUploadField', 'max_upload', 512000);
25
        $this->assertEquals(Config::inst()->get('ImageUploadField', 'max_upload'), 512000);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ImageUploadFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
    }
27
28
    /**
29
     *
30
     */
31
    public function testExtendedField()
32
    {
33
34
        $imageField = new CustomImageUploadField('testImageField');
35
        $this->assertEquals($imageField->getValidator()->getAllowedMaxFileSize(), 512000);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ImageUploadFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
36
37
        Config::inst()->update('CustomImageUploadField', 'max_upload', 256000);
38
        $imageField2 = new CustomImageUploadField('testImageField2');
39
        $this->assertEquals($imageField2->getValidator()->getAllowedMaxFileSize(), 256000);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<ImageUploadFieldTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
41
    }
42
43
}
44
45
/**
46
 * Class CustomImageUploadField
47
 */
48
class CustomImageUploadField extends ImageUploadField implements TestOnly
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
49
{
50
51
    /**
52
     * @var int
53
     */
54
    private static $max_upload = 512000;
0 ignored issues
show
Unused Code introduced by
The property $max_upload is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
55
56
}
57