-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
composer.phar | ||
composer.lock | ||
.DS_Store | ||
.idea | ||
.idea | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="DB_CONNECTION" value="testing"/> | ||
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Sopamo\LaravelFilepond\Tests\Feature; | ||
|
||
use Illuminate\Http\UploadedFile; | ||
use Illuminate\Support\Facades\Storage; | ||
use Sopamo\LaravelFilepond\Filepond; | ||
use Sopamo\LaravelFilepond\Tests\TestCase; | ||
|
||
class SingleFileUploadTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function test_normal_file_upload() | ||
{ | ||
$tmpPath = config('filepond.temporary_files_path', 'filepond'); | ||
$diskName = config('filepond.temporary_files_disk', 'local'); | ||
|
||
Storage::fake($diskName); | ||
|
||
$response = $this->postJson('/filepond/api/process', [ | ||
'file' => UploadedFile::fake()->create('test.txt', 1), | ||
]); | ||
|
||
$response->assertStatus(200); | ||
$serverId = $response->content(); | ||
$this->assertGreaterThan(50, strlen($serverId)); | ||
|
||
/** @var Filepond $filepond */ | ||
$filepond = app(Filepond::class); | ||
$pathFromServerId = $filepond->getPathFromServerId($serverId); | ||
|
||
$this->assertStringStartsWith($tmpPath, $pathFromServerId, 'tmp file was not created in the temporary_files_path directory'); | ||
|
||
Storage::disk($diskName)->assertExists($pathFromServerId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Sopamo\LaravelFilepond\Tests; | ||
|
||
|
||
use Sopamo\LaravelFilepond\LaravelFilepondServiceProvider; | ||
|
||
class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
// additional setup | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
LaravelFilepondServiceProvider::class, | ||
]; | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
// perform environment setup | ||
} | ||
} |