Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(filesytem): add tests for filesystem
- Loading branch information
1 parent
e74c68a
commit 10edab6
Showing
5 changed files
with
191 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the ************************ package. | ||
* _____________ _______________ | ||
* ______/ \__ _____ ____ ______ / /_ _________ | ||
* ____/ __ / / / / _ \/ __`\/ / __ \/ __ \/ __ \___ | ||
* __/ / / / /_/ / __/ / \ / /_/ / / / / /_/ /__ | ||
* \_\ \_/\____/\___/_/ / / .___/_/ /_/ .___/ | ||
* \_\ /_/_/ /_/ | ||
* | ||
* The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple> | ||
* (c) 2010-2020 http://queryphp.com All rights reserved. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Filesystem; | ||
|
||
use League\Flysystem\Filesystem as LeagueFilesystem; | ||
use Leevel\Filesystem\Ftp; | ||
use Tests\TestCase; | ||
|
||
class FtpTest extends TestCase | ||
{ | ||
public function testBaseUse(): void | ||
{ | ||
$this->expectException(\League\Flysystem\ConnectionRuntimeException::class); | ||
$this->expectExceptionMessage( | ||
'Could not connect to host: ftp.example.com, port:21' | ||
); | ||
|
||
$ftp = new Ftp(); | ||
$this->assertInstanceof(LeagueFilesystem::class, $ftp->getFilesystem()); | ||
$ftp->put('hello.txt', 'foo'); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the ************************ package. | ||
* _____________ _______________ | ||
* ______/ \__ _____ ____ ______ / /_ _________ | ||
* ____/ __ / / / / _ \/ __`\/ / __ \/ __ \/ __ \___ | ||
* __/ / / / /_/ / __/ / \ / /_/ / / / / /_/ /__ | ||
* \_\ \_/\____/\___/_/ / / .___/_/ /_/ .___/ | ||
* \_\ /_/_/ /_/ | ||
* | ||
* The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple> | ||
* (c) 2010-2020 http://queryphp.com All rights reserved. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Filesystem; | ||
|
||
use League\Flysystem\Filesystem as LeagueFilesystem; | ||
use Leevel\Filesystem\Sftp; | ||
use Tests\TestCase; | ||
|
||
class SftpTest extends TestCase | ||
{ | ||
public function testBaseUse(): void | ||
{ | ||
$this->expectException(\League\Flysystem\Sftp\ConnectionErrorException::class); | ||
$this->expectExceptionMessage( | ||
'Could not login with username: your-username, host: sftp.example.com' | ||
); | ||
|
||
set_error_handler(function ($type, $msg) {}); | ||
$sftp = new Sftp(); | ||
$this->assertInstanceof(LeagueFilesystem::class, $sftp->getFilesystem()); | ||
$sftp->put('hello.txt', 'foo'); | ||
restore_error_handler(); | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the ************************ package. | ||
* _____________ _______________ | ||
* ______/ \__ _____ ____ ______ / /_ _________ | ||
* ____/ __ / / / / _ \/ __`\/ / __ \/ __ \/ __ \___ | ||
* __/ / / / /_/ / __/ / \ / /_/ / / / / /_/ /__ | ||
* \_\ \_/\____/\___/_/ / / .___/_/ /_/ .___/ | ||
* \_\ /_/_/ /_/ | ||
* | ||
* The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple> | ||
* (c) 2010-2020 http://queryphp.com All rights reserved. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Tests\Filesystem; | ||
|
||
use League\Flysystem\Filesystem as LeagueFilesystem; | ||
use Leevel\Filesystem\Zip; | ||
use Tests\TestCase; | ||
|
||
class ZipTest extends TestCase | ||
{ | ||
public function testBaseUse(): void | ||
{ | ||
$zip = new Zip([ | ||
'path' => $path = __DIR__.'/hello.zip', | ||
]); | ||
$this->assertInstanceof(LeagueFilesystem::class, $zip->getFilesystem()); | ||
|
||
$zip->put('hello.txt', 'foo'); | ||
$this->assertTrue(is_file($path)); | ||
unlink($path); | ||
} | ||
|
||
public function testPathNotFound(): void | ||
{ | ||
$this->expectException(\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('The zip driver requires path option.'); | ||
|
||
$zip = new zip([ | ||
'path' => '', | ||
]); | ||
} | ||
} |