Skip to content

Commit d3b4e5c

Browse files
committed
tests: Extend tests in MediaTest
1 parent 91fc3af commit d3b4e5c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Unit/MediaTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,30 @@ public function testFileMove(){
269269
$this->assertDatabaseHas('media',['id' => $media->id, 'model_id' => $folder2->id]);
270270
}
271271

272+
public function testFileCropp(){
273+
/* No idea how to test it */
274+
$this->assertSame(true, true);
275+
}
276+
277+
public function testFileCopy(){
278+
$user = factory('App\User')->states('admin')->create();
279+
Role::create(['name' => 'admin']);
280+
$user->assignRole('admin');
281+
$file = UploadedFile::fake()->image('file.jpg');
282+
$folder = new Folder();
283+
$folder->name = 'test1';
284+
$folder->save();
285+
$response = $this->actingAs($user)->post('/media/file/store', [
286+
'file' => $file,
287+
'thisFolder' => $folder->id
288+
]);
289+
$media = $folder->getMedia()->first();
290+
$this->assertDatabaseHas('media',[ 'id' => $media->id, 'model_id' => $folder->id ]);
291+
$response = $this->actingAs($user)->get('/media/file/copy?id=' . $media->id . '&thisFolder=' . $folder->id );
292+
$folder = Folder::first();
293+
$media = $folder->getMedia();
294+
$this->assertSame( 2, count($media));
295+
$this->assertSame( $media[0]->name, 'file.jpg');
296+
$this->assertSame( $media[1]->name, 'file.jpg');
297+
}
272298
}

0 commit comments

Comments
 (0)