Skip to content

Commit 29c8f40

Browse files
authored
Merge pull request #33 from lazzard/intergation-tests-remove-connection-helper
v1.6.1
2 parents d910e62 + f78cc9e commit 29c8f40

File tree

11 files changed

+198
-205
lines changed

11 files changed

+198
-205
lines changed

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 1.6.1 (2022-02-27)
4+
5+
* 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)).
6+
* `FtpClient::copyToLocal` now throws an exception if the source remote path is file type and the local destionation directory is not found.
7+
38
## 1.6.0 (2022-01-31)
49

510
* Upgraded the code base to PHP `^7.4`.
@@ -38,8 +43,8 @@
3843

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

72-
### Renamed
77+
### Renamed
7378

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

121126
* Upgraded to PHP 5.6.0 version.
122-
* Supported the `usePassiveAddress` runtime option.
127+
* Supported the `usePassiveAddress` runtime option.
123128
* Added more options for unit testing (`PASSIVE`, `INITIAL_DIR`).
124129
* Removed `USESSL` option for unit testing.
125130

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

134139
### Behavior changed
135-
140+
136141
* `FtpClient::removeFile` & `FtpClient::removeDirectory` methods now doesn't throw an exception if the given file doesn't exist, but instead returns false.
137142
* `FtpClient::createFile` now doesn't throw an exception if the file name already exists on the server, instead, the remote file will be overwritten.
138143
* `FtpClient::createDirectory` now returns true if the giving directory already exists instead of throwing an exception.

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[![Downloads](https://img.shields.io/packagist/dt/lazzard/php-ftp-client?style=flat-square)](https://packagist.org/packages/lazzard/php-ftp-client)
22
[![Packagist Version](https://img.shields.io/packagist/v/lazzard/php-ftp-client?style=flat-square)](https://packagist.org/packages/lazzard/php-ftp-client)
3-
[![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)
4-
![License](https://img.shields.io/packagist/l/lazzard/php-ftp-client?style=flat-square)
3+
[![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)
4+
[![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)
5+
![License](https://img.shields.io/packagist/l/lazzard/php-ftp-client?style=flat-square&color=red)
56

67
# Lazzard/FtpClient
78

@@ -24,7 +25,6 @@ require __DIR__ . '/vendor/autoload.php';
2425
use Lazzard\FtpClient\Connection\FtpSSLConnection;
2526
use Lazzard\FtpClient\Config\FtpConfig;
2627
use Lazzard\FtpClient\FtpClient;
27-
use Lazzard\FtpClient\Exception\FtpClientException;
2828

2929
try {
3030
if (!extension_loaded('ftp')) {
@@ -38,12 +38,12 @@ try {
3838
$config->setPassive(true);
3939

4040
$client = new FtpClient($connection);
41-
41+
4242
print_r($client->getFeatures());
43-
43+
4444
$connection->close();
45-
46-
} catch (\Throwable $ex) {
45+
46+
} catch (Throwable $ex) {
4747
print_r($ex->getMessage());
4848
}
4949
```
@@ -266,15 +266,15 @@ $client->keepAlive();
266266
| 1.0.x | EOL | [v1.0.2][7] | >= 5.5 |
267267
| 1.4.x | EOL | [v1.4.2][9] | >= 5.6 |
268268
| 1.5.x | EOL | [v1.5.3][9] | ^7.2 \| 8.0.* |
269-
| 1.6.x | Latest | [v1.6.0][10] | ^7.4 \| 8.0.* |
269+
| 1.6.x | Latest | [v1.6.1][10] | ^7.4 \| 8.0.* |
270270

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

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

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

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

279279
## Contribution
280280

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

284284
## They support this project
285285

286-
<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"/>
286+
<img width="150px" src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_square.png"/>
287287

288288
## License
289289

tests/integration/Command/FtpCommandTest.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,35 @@
22

33
namespace Lazzard\FtpClient\Tests\Integration\Command;
44

5-
use PHPUnit\Framework\TestCase;
65
use Lazzard\FtpClient\Command\FtpCommand;
7-
use Lazzard\FtpClient\Tests\Integration\ConnectionHelper;
86
use Lazzard\FtpClient\Exception\CommandException;
7+
use Lazzard\FtpClient\Tests\Integration\FtpConnectionFactory;
8+
use PHPUnit\Framework\TestCase;
99

1010
class FtpCommandTest extends TestCase
11-
{
12-
public function testConstructor() : void
13-
{
14-
$this->assertInstanceOf(FtpCommand::class, new FtpCommand(ConnectionHelper::getConnection()));
15-
}
11+
{
1612

17-
public function testRaw() : void
13+
public function testRaw(): void
1814
{
19-
$command = new FtpCommand(ConnectionHelper::getConnection());
15+
$factory = new FtpConnectionFactory();
16+
$command = new FtpCommand($factory->create());
2017

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

24-
public function testSite() : void
21+
public function testSite(): void
2522
{
26-
$command = new FtpCommand(ConnectionHelper::getConnection());
27-
23+
$factory = new FtpConnectionFactory();
24+
$command = new FtpCommand($factory->create());
25+
2826
$this->assertTrue($command->site('HELP'));
2927
}
3028

31-
public function testExecThrowsExceptionIfTheExecFeatureNotSupported() : void
29+
public function testExecThrowsExceptionIfTheExecFeatureNotSupported(): void
3230
{
33-
$command = new FtpCommand(ConnectionHelper::getConnection());
34-
31+
$factory = new FtpConnectionFactory();
32+
$command = new FtpCommand($factory->create());
33+
3534
if (in_array('EXEC', $command->supportedSiteCommands())) {
3635
$this->markTestSkipped("SITE EXEC feature already supported.");
3736
}
@@ -42,24 +41,26 @@ public function testExecThrowsExceptionIfTheExecFeatureNotSupported() : void
4241
$command->exec('SITE EXEC test.sh');
4342
}
4443

45-
public function testExecIfTheExecFeatureIsSupported() : void
44+
public function testExecIfTheExecFeatureIsSupported(): void
4645
{
47-
$command = new FtpCommand(ConnectionHelper::getConnection());
48-
46+
$factory = new FtpConnectionFactory();
47+
$command = new FtpCommand($factory->create());
48+
4949
if (!in_array('EXEC', $command->supportedSiteCommands())) {
5050
$this->markTestSkipped("SITE EXEC feature is not supported.");
5151
}
5252

5353
$this->expectException(CommandException::class);
5454
$this->expectExceptionMessage("SITE EXEC command feature not provided by the FTP server.");
55-
55+
5656
$this->assertTrue($command->exec('SITE EXEC test.sh'));
5757
}
5858

59-
public function testSupportedSiteCommands() : void
59+
public function testSupportedSiteCommands(): void
6060
{
61-
$command = new FtpCommand(ConnectionHelper::getConnection());
62-
61+
$factory = new FtpConnectionFactory();
62+
$command = new FtpCommand($factory->create());
63+
6364
$this->assertIsArray($command->supportedSiteCommands());
6465
}
6566
}

tests/integration/Config/FtpConfigTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,52 @@
22

33
namespace Lazzard\FtpClient\Tests\Integration\Config;
44

5-
use PHPUnit\Framework\TestCase;
65
use Lazzard\FtpClient\Config\FtpConfig;
7-
use Lazzard\FtpClient\Tests\Integration\ConnectionHelper;
6+
use Lazzard\FtpClient\Tests\Integration\FtpConnectionFactory;
7+
use PHPUnit\Framework\TestCase;
88

99
class FtpConfigTest extends TestCase
1010
{
11-
public function testConstructor() : void
12-
{
13-
$this->assertInstanceOf(FtpConfig::class, new FtpConfig(ConnectionHelper::getConnection()));
14-
}
1511

1612
public function testSetPassive() : void
1713
{
18-
$config = new FtpConfig(ConnectionHelper::getConnection());
14+
$factory = new FtpConnectionFactory();
15+
$config = new FtpConfig($factory->create());
1916

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

2320
public function testSetAutoSeek() : void
2421
{
25-
$config = new FtpConfig(ConnectionHelper::getConnection());
22+
$factory = new FtpConnectionFactory();
23+
$config = new FtpConfig($factory->create());
2624

2725
$this->assertTrue($config->setAutoSeek(false));
2826
$this->assertFalse($config->isAutoSeek());
2927
}
3028

3129
public function testSetTimeout() : void
3230
{
33-
$config = new FtpConfig(ConnectionHelper::getConnection());
31+
$factory = new FtpConnectionFactory();
32+
$config = new FtpConfig($factory->create());
3433

3534
$this->assertTrue($config->setTimeout(64));
3635
$this->assertSame(64, $config->getTimeout());
3736
}
3837

3938
public function testGetTimeout() : void
4039
{
41-
$config = new FtpConfig(ConnectionHelper::getConnection());
40+
$factory = new FtpConnectionFactory();
41+
$config = new FtpConfig($factory->create());
4242

4343
$config->setTimeout(32);
4444
$this->assertSame(32, $config->getTimeout());
4545
}
4646

4747
public function testIsAutoSeek() : void
4848
{
49-
$config = new FtpConfig(ConnectionHelper::getConnection());
49+
$factory = new FtpConnectionFactory();
50+
$config = new FtpConfig($factory->create());
5051

5152
$config->setAutoSeek(true);
5253
$this->assertTrue($config->isAutoSeek());

tests/integration/Connection/FtpConnectionTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22

33
namespace Lazzard\FtpClient\Tests\Integration\Connection;
44

5-
use PHPUnit\Framework\TestCase;
6-
use Lazzard\FtpClient\Config\FtpConfig;
7-
use Lazzard\FtpClient\Connection\ConnectionInterface;
85
use Lazzard\FtpClient\Connection\FtpConnection;
96
use Lazzard\FtpClient\Exception\ConnectionException;
7+
use PHPUnit\Framework\TestCase;
108

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

1812
public function testGetStreamWithOpenedConnection() : void
1913
{

0 commit comments

Comments
 (0)