Skip to content

Commit

Permalink
Merge pull request #33 from lazzard/intergation-tests-remove-connecti…
Browse files Browse the repository at this point in the history
…on-helper

v1.6.1
  • Loading branch information
AmraniCh authored Feb 27, 2022
2 parents d910e62 + f78cc9e commit 29c8f40
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 205 deletions.
15 changes: 10 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 1.6.1 (2022-02-27)

* Integrated the GitHub actions to run the integration tests automatically ([#31](https://github.com/lazzard/php-ftp-client/pull/31) - [#32](https://github.com/lazzard/php-ftp-client/pull/32)).
* `FtpClient::copyToLocal` now throws an exception if the source remote path is file type and the local destionation directory is not found.

## 1.6.0 (2022-01-31)

* Upgraded the code base to PHP `^7.4`.
Expand Down Expand Up @@ -38,8 +43,8 @@

* `FtpClient::fileSize` fixed for servers that not support `SIZE` feature.
* `FtpClient::listDir` fixed compatibility issue with some FTP servers.
* `Connection::isConnected` fixed bug : if the connection is not established yet the method was returned
a NULL value instead of false.
* `Connection::isConnected` fixed bug : if the connection is not established yet the method was returned
a NULL value instead of false.
* `FtpCommand::raw` improved and added the `end-message` to the returned array.
* `FtpClient::isDir` performance optimized.
* `FtpClient::listDirDetails` improved (No Breaking Change).
Expand Down Expand Up @@ -69,7 +74,7 @@ a NULL value instead of false.
* `FtpClient::copyToLocal` method added.
* `FtpClient::find` method added.

### Renamed
### Renamed

* `FtpClient::setCurrentDir` renamed to `FtpClient::changeDir`.
* `FtpClient::createDirectory` renamed to `FtpClient::createDir`.
Expand Down Expand Up @@ -119,7 +124,7 @@ a NULL value instead of false.
## v1.2.0 (2021-01-12)

* Upgraded to PHP 5.6.0 version.
* Supported the `usePassiveAddress` runtime option.
* Supported the `usePassiveAddress` runtime option.
* Added more options for unit testing (`PASSIVE`, `INITIAL_DIR`).
* Removed `USESSL` option for unit testing.

Expand All @@ -132,7 +137,7 @@ a NULL value instead of false.
* Removed `FtpClient::isEmptyDirectory` & `FtpClient::isEmptyFile` use `FtpClient::isEmpty` instead for both files and directories.

### Behavior changed

* `FtpClient::removeFile` & `FtpClient::removeDirectory` methods now doesn't throw an exception if the given file doesn't exist, but instead returns false.
* `FtpClient::createFile` now doesn't throw an exception if the file name already exists on the server, instead, the remote file will be overwritten.
* `FtpClient::createDirectory` now returns true if the giving directory already exists instead of throwing an exception.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Downloads](https://img.shields.io/packagist/dt/lazzard/php-ftp-client?style=flat-square)](https://packagist.org/packages/lazzard/php-ftp-client)
[![Packagist Version](https://img.shields.io/packagist/v/lazzard/php-ftp-client?style=flat-square)](https://packagist.org/packages/lazzard/php-ftp-client)
[![Minimum PHP version](https://img.shields.io/packagist/php-v/lazzard/php-ftp-client?style=flat-square)](https://packagist.org/packages/lazzard/php-ftp-client)
![License](https://img.shields.io/packagist/l/lazzard/php-ftp-client?style=flat-square)
[![tests](https://img.shields.io/github/workflow/status/lazzard/php-ftp-client/tests?label=tests&style=flat-square)](https://github.com/lazzard/php-ftp-client/actions/workflows/tests.yml)
[![Minimum PHP version](https://img.shields.io/packagist/php-v/lazzard/php-ftp-client?style=flat-square&color=blue)](https://packagist.org/packages/lazzard/php-ftp-client)
![License](https://img.shields.io/packagist/l/lazzard/php-ftp-client?style=flat-square&color=red)

# Lazzard/FtpClient

Expand All @@ -24,7 +25,6 @@ require __DIR__ . '/vendor/autoload.php';
use Lazzard\FtpClient\Connection\FtpSSLConnection;
use Lazzard\FtpClient\Config\FtpConfig;
use Lazzard\FtpClient\FtpClient;
use Lazzard\FtpClient\Exception\FtpClientException;

try {
if (!extension_loaded('ftp')) {
Expand All @@ -38,12 +38,12 @@ try {
$config->setPassive(true);

$client = new FtpClient($connection);

print_r($client->getFeatures());

$connection->close();
} catch (\Throwable $ex) {

} catch (Throwable $ex) {
print_r($ex->getMessage());
}
```
Expand Down Expand Up @@ -266,15 +266,15 @@ $client->keepAlive();
| 1.0.x | EOL | [v1.0.2][7] | >= 5.5 |
| 1.4.x | EOL | [v1.4.2][9] | >= 5.6 |
| 1.5.x | EOL | [v1.5.3][9] | ^7.2 \| 8.0.* |
| 1.6.x | Latest | [v1.6.0][10] | ^7.4 \| 8.0.* |
| 1.6.x | Latest | [v1.6.1][10] | ^7.4 \| 8.0.* |

[7]: https://github.com/lazzard/php-ftp-client/releases/tag/v1.0.2

[8]: https://github.com/lazzard/php-ftp-client/releases/tag/v1.1.0

[9]: https://github.com/lazzard/php-ftp-client/releases/tag/v1.5.3

[10]: https://github.com/lazzard/php-ftp-client/releases/tag/v1.6.0
[10]: https://github.com/lazzard/php-ftp-client/releases/tag/v1.6.1

## Contribution

Expand All @@ -283,7 +283,7 @@ you facing while using the library will be very appreciated, Thank you!

## They support this project

<img width="150" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png?_gl=1*1evhn6q*_ga*MzA3MTk5NzQ3LjE2MzU3OTk3MDA.*_ga_V0XZL7QHEB*MTYzNTg5MzE3NS4yLjEuMTYzNTg5MzkzNC4xNg..&_ga=2.162913596.1450626373.1635893177-307199747.1635799700"/>
<img width="150px" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_square.png"/>

## License

Expand Down
45 changes: 23 additions & 22 deletions tests/integration/Command/FtpCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@

namespace Lazzard\FtpClient\Tests\Integration\Command;

use PHPUnit\Framework\TestCase;
use Lazzard\FtpClient\Command\FtpCommand;
use Lazzard\FtpClient\Tests\Integration\ConnectionHelper;
use Lazzard\FtpClient\Exception\CommandException;
use Lazzard\FtpClient\Tests\Integration\FtpConnectionFactory;
use PHPUnit\Framework\TestCase;

class FtpCommandTest extends TestCase
{
public function testConstructor() : void
{
$this->assertInstanceOf(FtpCommand::class, new FtpCommand(ConnectionHelper::getConnection()));
}
{

public function testRaw() : void
public function testRaw(): void
{
$command = new FtpCommand(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$command = new FtpCommand($factory->create());

$this->assertIsArray($command->raw('HELP'));
}

public function testSite() : void
public function testSite(): void
{
$command = new FtpCommand(ConnectionHelper::getConnection());

$factory = new FtpConnectionFactory();
$command = new FtpCommand($factory->create());

$this->assertTrue($command->site('HELP'));
}

public function testExecThrowsExceptionIfTheExecFeatureNotSupported() : void
public function testExecThrowsExceptionIfTheExecFeatureNotSupported(): void
{
$command = new FtpCommand(ConnectionHelper::getConnection());

$factory = new FtpConnectionFactory();
$command = new FtpCommand($factory->create());

if (in_array('EXEC', $command->supportedSiteCommands())) {
$this->markTestSkipped("SITE EXEC feature already supported.");
}
Expand All @@ -42,24 +41,26 @@ public function testExecThrowsExceptionIfTheExecFeatureNotSupported() : void
$command->exec('SITE EXEC test.sh');
}

public function testExecIfTheExecFeatureIsSupported() : void
public function testExecIfTheExecFeatureIsSupported(): void
{
$command = new FtpCommand(ConnectionHelper::getConnection());

$factory = new FtpConnectionFactory();
$command = new FtpCommand($factory->create());

if (!in_array('EXEC', $command->supportedSiteCommands())) {
$this->markTestSkipped("SITE EXEC feature is not supported.");
}

$this->expectException(CommandException::class);
$this->expectExceptionMessage("SITE EXEC command feature not provided by the FTP server.");

$this->assertTrue($command->exec('SITE EXEC test.sh'));
}

public function testSupportedSiteCommands() : void
public function testSupportedSiteCommands(): void
{
$command = new FtpCommand(ConnectionHelper::getConnection());

$factory = new FtpConnectionFactory();
$command = new FtpCommand($factory->create());

$this->assertIsArray($command->supportedSiteCommands());
}
}
23 changes: 12 additions & 11 deletions tests/integration/Config/FtpConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,52 @@

namespace Lazzard\FtpClient\Tests\Integration\Config;

use PHPUnit\Framework\TestCase;
use Lazzard\FtpClient\Config\FtpConfig;
use Lazzard\FtpClient\Tests\Integration\ConnectionHelper;
use Lazzard\FtpClient\Tests\Integration\FtpConnectionFactory;
use PHPUnit\Framework\TestCase;

class FtpConfigTest extends TestCase
{
public function testConstructor() : void
{
$this->assertInstanceOf(FtpConfig::class, new FtpConfig(ConnectionHelper::getConnection()));
}

public function testSetPassive() : void
{
$config = new FtpConfig(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$config = new FtpConfig($factory->create());

$this->assertTrue($config->setPassive(true));
}

public function testSetAutoSeek() : void
{
$config = new FtpConfig(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$config = new FtpConfig($factory->create());

$this->assertTrue($config->setAutoSeek(false));
$this->assertFalse($config->isAutoSeek());
}

public function testSetTimeout() : void
{
$config = new FtpConfig(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$config = new FtpConfig($factory->create());

$this->assertTrue($config->setTimeout(64));
$this->assertSame(64, $config->getTimeout());
}

public function testGetTimeout() : void
{
$config = new FtpConfig(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$config = new FtpConfig($factory->create());

$config->setTimeout(32);
$this->assertSame(32, $config->getTimeout());
}

public function testIsAutoSeek() : void
{
$config = new FtpConfig(ConnectionHelper::getConnection());
$factory = new FtpConnectionFactory();
$config = new FtpConfig($factory->create());

$config->setAutoSeek(true);
$this->assertTrue($config->isAutoSeek());
Expand Down
8 changes: 1 addition & 7 deletions tests/integration/Connection/FtpConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@

namespace Lazzard\FtpClient\Tests\Integration\Connection;

use PHPUnit\Framework\TestCase;
use Lazzard\FtpClient\Config\FtpConfig;
use Lazzard\FtpClient\Connection\ConnectionInterface;
use Lazzard\FtpClient\Connection\FtpConnection;
use Lazzard\FtpClient\Exception\ConnectionException;
use PHPUnit\Framework\TestCase;

class FtpConnectionTest extends TestCase
{
public function testConstructor() : void
{
$this->assertInstanceOf(ConnectionInterface::class, new FtpConnection(HOST, USERNAME, PASSWORD, PORT, TIMEOUT));
}

public function testGetStreamWithOpenedConnection() : void
{
Expand Down
Loading

0 comments on commit 29c8f40

Please sign in to comment.