Before proposing a pull request, please check the following:
- Your code should follow the PSR-2 coding standard. Use php-cs-fixer to fix inconsistencies.
- If you commit a new feature, be prepared to help maintaining it. Watch the project on GitHub, and please comment on issues or PRs regarding the feature you contributed.
- You should test your feature well.
- You should run
php build
and commit the PHAR file so it is part of your pull request. You may need to changephar.readonly
php.ini setting to0
or run the command asphp -d phar.readonly=0 build
.
Once your code is merged, it is available for free to everybody under the MIT License. Publishing your pull request on the PHPloy GitHub repository means that you agree with this license for your contribution.
Thank you for your contribution! PHPloy wouldn't be so great without you.
Special thanks to @mbrugger for implementing the testing functionality, a long awaited feature.
The integration tests provide a docker configuration for a SFTP and FTP server you can use to test the synchronization. A folder in /tmp is mounted into the docker container which can be used to compare the result after running PHPloy.
To get started with testing, please follow the steps below:
- Install docker
- Start the test server
vagrant@vagrant-ubuntu-trusty-64:/vagrant/PHPloy$ ./tests/start_test_server.sh
- run the tests
vagrant@vagrant-ubuntu-trusty-64:/vagrant/PHPloy$ vendor/bin/phpunit tests
PHPUnit 4.8.26 by Sebastian Bergmann and contributors.
...
Time: 2.32 seconds, Memory: 4.25MB
OK (3 tests, 4 assertions)
vagrant@vagrant-ubuntu-trusty-64:/vagrant/PHPloy$
- Stop the sftp server
vagrant@vagrant-ubuntu-trusty-64:/vagrant/PHPloy$ ./tests/stop_test_server.sh
Basically each test should be structured in the following way
- Prepare a test repository and phploy.ini configuration
- Run PHPLoy
- Verify the result of the execution by comparing the source folder with the synchronization result
public function testSyncAddedFileShouldSucceed($testHelper)
{
$this->testHelper = new PHPLoyTestHelper($testHelper);
$this->testHelper->givenRepositoryWithConfiguration();
$this->whenFileIsAdded();
$this->thenRepositoryIsSynchronizedSuccessfully();
}
For testing FTP and SFTP at the same time tests can be parametrized. Take a look at the CommitFileTest.php:
class CommitFileTest extends PHPUnit_Framework_TestCase
{
public function provider()
{
return array(
array('ftp'),
array('sftp')
);
}
protected $testHelper;
/**
* @dataProvider provider
*/
public function testSyncAddedFileShouldSucceed($testType)
{
$this->testHelper = new PHPLoyTestHelper($testHelper);
// implement the test here
}
}
The PHPLoyTestHelper is parametrized to provide different configurations based on the type passed to the test method by the PHPunit framework. This is especially helpful if you want to test shared functionality available for multiple protocols.