Completed
Push — master ( 23423a...b8da20 )
by Damian
14s
created

FileFormBuilderTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 259
Duplicated Lines 6.18 %

Coupling/Cohesion

Components 1
Dependencies 11

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 10
c 2
b 0
f 0
lcom 1
cbo 11
dl 16
loc 259
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 16 16 1
A tearDown() 0 5 1
A testEditFileFormWithPermissions() 0 48 1
B testCreateFileForm() 0 24 1
A testEditImageForm() 0 22 1
A testInsertImageForm() 0 14 1
A testEditFileForm() 0 64 1
A testInsertFileForm() 0 16 1
B testFolderForm() 0 29 1
A testScaffolderFactory() 0 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 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 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' => FileFormFactory::TYPE_INSERT_MEDIA]);
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 testInsertFileForm()
224
    {
225
        $this->logInWithPermission('ADMIN');
226
227
        $image = $this->objFromFixture(Image::class, 'image1');
228
        $controller = new AssetAdmin();
229
        $builder = new ImageFormFactory();
230
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $image, 'Type' => FileFormFactory::TYPE_INSERT_LINK]);
231
232
        // Ensure form contains correct fields
233
        $this->assertNotNull($form->Fields()->dataFieldByName('Description'));
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...
234
        $this->assertNotNull($form->Fields()->dataFieldByName('TargetBlank'));
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...
235
236
        // Don't show dimension tags
237
        $this->assertNull($form->Fields()->dataFieldByName('InsertWidth'));
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...
238
    }
239
240
    public function testFolderForm()
241
    {
242
        $this->logInWithPermission('ADMIN');
243
244
        $folder = $this->objFromFixture(Folder::class, 'parent');
245
        $controller = new AssetAdmin();
246
        $builder = new FolderFormFactory();
247
        $form = $builder->getForm($controller, 'EditForm', ['Record' => $folder]);
248
249
        // Check fields
250
        $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...
251
        $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...
252
        $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...
253
254
        /** @var LiteralField $iconFullField */
255
        $iconFullField = $form->Fields()->fieldByName('PreviewImage');
256
        $state = $iconFullField->getSchemaStateDefaults();
257
        $this->assertEquals($folder->Parent()->ID, $state['data']['parentid']);
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...
258
        $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...
259
        $this->assertContains('folder_icon_large.png', $state['data']['preview']);
260
        $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...
261
262
        // Check actions
263
        $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...
264
        $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...
265
        $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...
266
        $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...
267
        $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...
268
    }
269
270
    public function testScaffolderFactory()
271
    {
272
        $controller = new AssetAdmin();
273
        $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...
274
        $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...
275
        $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...
276
    }
277
}
278