Completed
Pull Request — master (#458)
by Roman
02:25
created

FileFormBuilderTest::testEditFileForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 64
rs 9.3956
cc 1
eloc 38
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace SilverStripe\AssetAdmin\Tests\Forms;
4
5
use SilverStripe\AssetAdmin\Controller\AssetAdmin;
6
use SilverStripe\AssetAdmin\Extensions\CampaignAdminExtension;
7
use SilverStripe\AssetAdmin\Forms\FileFormFactory;
8
use SilverStripe\AssetAdmin\Forms\FolderFormFactory;
9
use SilverStripe\AssetAdmin\Forms\ImageFormFactory;
10
use SilverStripe\AssetAdmin\Tests\Forms\FileFormBuilderTest\FileExtension;
11
use SilverStripe\Assets\File;
12
use SilverStripe\Assets\Folder;
13
use SilverStripe\Assets\Image;
14
use SilverStripe\Assets\Tests\Storage\AssetStoreTest\TestAssetStore;
15
use SilverStripe\Core\Config\Config;
16
use SilverStripe\Dev\SapphireTest;
17
use SilverStripe\Forms\LiteralField;
18
19
class FileFormBuilderTest extends SapphireTest
20
{
21
    protected static $fixture_file = 'FileFormBuilderTest.yml';
22
23 View Code Duplication
    public function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        parent::setUp();
26
27
        // Set backend and base url
28
        TestAssetStore::activate('FileFormBuilderTest');
29
30
        /** @var File $testfile */
31
        $testfile = $this->objFromFixture(File::class, 'file1');
32
        $testfile->setFromLocalFile(__DIR__ .'/fixtures/testfile.txt', 'files/testfile.txt');
33
        $testfile->write();
34
35
        /** @var Image $testimage */
36
        $testimage = $this->objFromFixture(Image::class, 'image1');
37
        $testimage->setFromLocalFile(__DIR__.'/fixtures/testimage.png', 'files/testimage.png');
38
    }
39
40
    public function tearDown()
41
    {
42
        TestAssetStore::reset();
43
        parent::tearDown();
44
    }
45
46
    public function testEditFileForm()
47
    {
48
        // Ensure campaign-admin extension is not applied!
49
        Config::modify()->remove(FileFormFactory::class, 'extensions');
50
51
        $this->logInWithPermission('ADMIN');
52
53
        $file = $this->objFromFixture(File::class, 'file1');
54
        $controller = new AssetAdmin();
55
        $builder = new FileFormFactory();
56
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
57
58
        // Verify file form is scaffolded correctly
59
        $this->assertEquals('EditForm', $form->getName());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
60
61
        // Test fields exist
62
        /** @var LiteralField $fileSpecsField */
63
        $fileSpecsField = $form->Fields()->fieldByName('FileSpecs');
64
        $fileSpecs = $fileSpecsField->getContent();
65
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
66
            '<div class="editor__specs">11 bytes <span class="editor__status-flag">Draft</span></div>',
67
            $fileSpecs
68
        );
69
        $filePath = $form->Fields()->fieldByName('Editor.Details.Path')->Value();
70
        $this->assertEquals('files/', $filePath);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
71
72
        /** @var LiteralField $iconFullField */
73
        $iconFullField = $form->Fields()->fieldByName('PreviewImage');
74
        $state = $iconFullField->getSchemaStateDefaults();
75
        $this->assertEquals($file->Parent()->ID, $state['data']['parentid']);
0 ignored issues
show
Bug introduced by
The method Parent() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean parentClass()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
76
        $this->assertContains('testfile.txt', $state['data']['url']);
77
        $this->assertTrue($state['data']['exists']);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
78
        $this->assertContains('document_92.png', $state['data']['preview']);
79
        $this->assertEquals('document', $state['data']['category']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
80
81
        // Usage tab
82
        $uploaded = $form->Fields()->fieldByName('Editor.Usage.Created');
83
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
84
            $file->Created,
85
            $uploaded->dataValue()
86
        );
87
88
        // Test actions exist
89
        $this->assertNotNull($form->Actions()->fieldByName('Actions.action_save'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
90
        $this->assertNotNull($form->Actions()->fieldByName('Actions.action_publish'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
91
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
92
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
93
94
        // Add to campaign should not be there by default
95
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
96
97
        // Add extension for campaign-admin
98
        Config::modify()->merge(
99
            FileFormFactory::class,
100
            'extensions',
101
            [ CampaignAdminExtension::class ]
102
        );
103
104
        $builder = new FileFormFactory();
105
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
106
107
        // Add to campaign should now be available
108
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
109
    }
110
111
    public function testEditFileFormWithPermissions()
112
    {
113
        // Add extension for campaign-admin
114
        FileFormFactory::add_extension(CampaignAdminExtension::class);
115
        // Add extension to simulate different permissions
116
        File::add_extension(FileExtension::class);
117
118
        $this->logInWithPermission('ADMIN');
119
120
        /** @var File $file */
121
        $file = $this->objFromFixture(File::class, 'file1');
122
        $controller = new AssetAdmin();
123
        $builder = new FileFormFactory();
124
125
        FileExtension::$canDelete = false;
126
        FileExtension::$canPublish = false;
127
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
128
        $this->assertNull($form->Actions()->fieldByName('PopoverActions'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
129
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
130
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
131
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
132
133
        FileExtension::$canDelete = false;
134
        FileExtension::$canPublish = true;
135
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
136
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
137
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
138
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
139
140
        FileExtension::$canDelete = true;
141
        FileExtension::$canPublish = false;
142
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
143
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
144
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
145
        $this->assertNull($form->Actions()->fieldByName('PopoverActions.action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
146
147
        FileExtension::$canDelete = true;
148
        FileExtension::$canPublish = true;
149
        FileExtension::$canUnpublish = true;
150
        $file->publishSingle();
151
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
152
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
153
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_addtocampaign'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
154
        $this->assertNotNull($form->Actions()->fieldByName('PopoverActions.action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
155
156
        FileFormFactory::remove_extension(CampaignAdminExtension::class);
157
        File::remove_extension(FileExtension::class);
158
    }
159
160
    public function testCreateFileForm()
161
    {
162
        $this->logInWithPermission('ADMIN');
163
164
        $file = $this->objFromFixture(File::class, 'file1');
165
        $controller = new AssetAdmin();
166
        $builder = new FileFormFactory();
167
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $file]);
168
169
        // Test fields
170
        /** @var LiteralField $fileSpecsField */
171
        $fileSpecsField = $form->Fields()->fieldByName('FileSpecs');
172
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
173
            '<div class="editor__specs">11 bytes <span class="editor__status-flag">Draft</span></div>',
174
            $fileSpecsField->getContent()
175
        );
176
        $this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
177
            'files/',
178
            $form->Fields()->fieldByName('Editor.Details.Path')->dataValue()
179
        );
180
181
        // Test actions
182
        $this->assertNotNull($form->Actions()->fieldByName('Actions.action_save'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
183
    }
184
185
    public function testEditImageForm()
186
    {
187
        $this->logInWithPermission('ADMIN');
188
189
        $image = $this->objFromFixture(Image::class, 'image1');
190
        // write so that PreviewImageField could load this later on
191
        $image->write();
192
        $controller = new AssetAdmin();
193
        $builder = new ImageFormFactory();
194
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $image]);
195
196
        // Check thumbnail
197
        // Note: force_resample is turned off for testing
198
        /** @var LiteralField $iconFullField */
199
        $iconFullField = $form->Fields()->fieldByName('PreviewImage');
200
        $state = $iconFullField->getSchemaStateDefaults();
201
        $this->assertEquals($image->Parent()->ID, $state['data']['parentid']);
0 ignored issues
show
Bug introduced by
The method Parent() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean parentClass()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
202
        $this->assertContains('testimage.png', $state['data']['url']);
203
        $this->assertTrue($state['data']['exists']);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
204
        $this->assertContains('testimage.png', $state['data']['preview']);
205
        $this->assertEquals('image', $state['data']['category']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
206
    }
207
208
    public function testInsertImageForm()
209
    {
210
        $this->logInWithPermission('ADMIN');
211
212
        $image = $this->objFromFixture(Image::class, 'image1');
213
        $controller = new AssetAdmin();
214
        $builder = new ImageFormFactory();
215
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $image, 'Type' => 'insert']);
216
217
        // Check thumbnail
218
        // Note: force_resample is turned off for testing
219
        $altTextField = $form->Fields()->dataFieldByName('AltText');
220
        $this->assertNotNull($altTextField);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
221
    }
222
223
    public function testFolderForm()
224
    {
225
        $this->logInWithPermission('ADMIN');
226
227
        $folder = $this->objFromFixture(Folder::class, 'parent');
228
        $controller = new AssetAdmin();
229
        $builder = new FolderFormFactory($controller, $folder);
0 ignored issues
show
Unused Code introduced by
The call to FolderFormFactory::__construct() has too many arguments starting with $controller.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
230
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $folder]);
231
232
        // Check fields
233
        $this->assertNull($form->Fields()->fieldByName('FileSpecs'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
234
        $this->assertNull($form->Fields()->fieldByName('Editor.Details.ClickableURL'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
235
        $this->assertNull($form->Fields()->fieldByName('Editor.Usage'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
236
237
        /** @var LiteralField $iconFullField */
238
        $iconFullField = $form->Fields()->fieldByName('PreviewImage');
239
        $state = $iconFullField->getSchemaStateDefaults();
240
        $this->assertEquals($folder->Parent()->ID, $state['data']['parentid']);
0 ignored issues
show
Bug introduced by
The method Parent() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean parentClass()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
241
        $this->assertTrue($state['data']['exists']);
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
242
        $this->assertContains('folder_icon_large.png', $state['data']['preview']);
243
        $this->assertEquals('folder', $state['data']['category']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
244
245
        // Check actions
246
        $this->assertNotNull($form->Actions()->fieldByName('action_save'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
247
        $this->assertNotNull($form->Actions()->dataFieldByName('action_delete'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
248
        $this->assertNull($form->Actions()->fieldByName('action_publish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
249
        $this->assertNull($form->Actions()->dataFieldByName('action_publish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
250
        $this->assertNull($form->Actions()->dataFieldByName('action_unpublish'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
251
    }
252
253
    public function testScaffolderFactory()
254
    {
255
        $controller = new AssetAdmin();
256
        $this->assertInstanceOf(FileFormFactory::class, $controller->getFormFactory(File::singleton()));
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
257
        $this->assertInstanceOf(ImageFormFactory::class, $controller->getFormFactory(Image::singleton()));
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
258
        $this->assertInstanceOf(FolderFormFactory::class, $controller->getFormFactory(Folder::singleton()));
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<SilverStripe\Asse...ms\FileFormBuilderTest>.

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...
259
    }
260
}
261