You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
2.1 KiB

<?php
namespace Tests\Feature;
use App\Image\ImageProcessor;
use App\Models\Collection;
use App\Models\File;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Storage;
use Tests\Feature\Traits\FileImageTrait;
use Tests\Feature\Traits\FileShowTrait;
use Tests\TestCase;
class FileShowTest extends TestCase
{
use FileShowTrait, FileImageTrait;
public function test_user_can_resize_image_with_width_and_height_fields_ok()
{
$models = $this->createCollectionAndFileModelWithImage();
$w = rand(10, 2000);
$h = rand(10, 2000);
$canv = rand(0, 1);
$response = $this->loginAs()->getJson(route('api.files.show', ['collection_name' => $models['collection']->name, 'uuid' => $models['file']->uuid, 'extention' => $models['collection']->ext, 'w' => $w, 'h' => $h, 'canv' => $canv]));
$response->assertOk()->assertHeader('content-type', $response->headers->get('content-type'));
$this->assertEquals($w, getimagesize($response->getFile()->getPathname())[0]);
$this->assertEquals($h, getimagesize($response->getFile()->getPathname())[1]);
$this->deleteFakeImageForModel($models['file']);
}
// /**
// * @testWith ["test", 4,'1:fgvjjf']
// * ["longer-string", 13,'1:fgvjjf']
// */
// public function test_user_send_not_currect_value_to_file($w, $h, $r)
// {
// $models = $this->createCollectionAndFileModelWithImage();
// $canv = rand(0, 1);
// $response = $this->loginAs()->getJson(route('api.files.show', ['collection_name' => $models['collection']->name, 'uuid' => $models['file']->uuid, 'extention' => $models['collection']->ext, 'w' => $w, 'h' => $h, 'canv' => $canv]));
// $response->assertOk()->assertHeader('content-type', $response->headers->get('content-type'));
// $this->assertNotEquals($w, getimagesize($response->getFile()->getPathname())[0]);
// $this->assertNotEquals($h, getimagesize($response->getFile()->getPathname())[1]);
// $this->deleteFakeImageForModel($models['file']);
// }
}