homepagePHP/lara/tests/Feature/UploadTest.php

25 lines
677 B
PHP
Executable File

<?php
namespace Lara\Tests\Feature;
use Illuminate\Http\UploadedFile;
use Lara\Tests\TestCase;
class UploadTest extends TestCase {
public function testUploadImage(){
$data = [
'file' => UploadedFile::fake()->image('test.jpg', 100, 100)
];
$content = $this->post('api/upload/uploadImage', $data);
$content = json_decode($content, true);
$this->assertTrue($content['Status'] == 1);
$this->assertDatabaseHas('tz_file_pic', [
'title' => 'test.jpg',
'file' => $content['file']
]);
$this->assertFileExists($this->laraPath() . '/../www/Uploads/' . $content['file']);
}
}