Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit ebd6a45

Browse files
authored
Merge pull request #3 from mjrider/php54-tests
travis php5.4 support
2 parents 6153c4d + d2d1e4a commit ebd6a45

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

.travis.yml

+20-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: php
33
sudo: required
44
env:
55
global:
6-
- TEST_S3_LOCATION='s3://TRAVISACCESSPHPUNIT:wJalrXUtnFEMI%2FSECRET%2FTRAVISPHPUNIT@us-east-1/?endpoint=http%3A%2F%2F127.0.0.1%3A9999&use_path_style_endpoint=1'
6+
- TEST_S3_LOCATION='//TRAVISACCESSPHPUNIT:wJalrXUtnFEMI%2FSECRET%2FTRAVISPHPUNIT@us-east-1/?endpoint=http%3A%2F%2F127.0.0.1%3A9999&use_path_style_endpoint=1'
77

88
services:
99
- docker
@@ -22,8 +22,10 @@ php:
2222
- 7.1
2323
- 7.0
2424
- 5.6
25+
- 5.4
2526

2627
before_install:
28+
- env
2729
- echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
2830
- wget https://scrutinizer-ci.com/ocular.phar -O ~/.ocular/ocular.phar
2931
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
@@ -33,28 +35,39 @@ install:
3335
- curl https://bootstrap.pypa.io/get-pip.py >> ~/get-pip.py
3436
- sudo python ~/get-pip.py
3537
- sudo pip install yamllint
36-
- composer global require "dealerdirect/qa-tools:*"
38+
- 'if [[ ${TRAVIS_PHP_VERSION} != "5.4" ]] ; then composer global require "dealerdirect/qa-tools:*" ; fi'
3739
- "docker run -p 9999:9999 --name minio --rm \
3840
-e 'MINIO_ACCESS_KEY=TRAVISACCESSPHPUNIT' \
3941
-e 'MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/TRAVISKEYPHPUNIT' \
4042
--detach minio/minio server /data"
4143

4244
script:
4345
- composer validate
46+
- >
47+
if [[ ${TRAVIS_PHP_VERSION} == "5.4" ]] ; then
48+
composer remove --dev --no-update --no-interaction league/flysystem-aws-s3-v3 ;
49+
composer remove --dev --no-update --no-interaction mhetreramesh/flysystem-backblaze ;
50+
composer require --dev --no-update --no-interaction league/flysystem-aws-s3-v2 ;
51+
fi
4452
- composer install -o --prefer-dist --no-scripts
4553
- >
54+
if [[ -e ~/.composer/vendor/bin/jsonlint ]] ; then
4655
find . -type f -name "*.json" -not -path "./vendor/*" -print0 |
47-
xargs -0 --no-run-if-empty -n1 ~/.composer/vendor/bin/jsonlint -c -q
56+
xargs -0 --no-run-if-empty -n1 ~/.composer/vendor/bin/jsonlint -c -q ;
57+
fi
4858
- >
4959
find . -type f -name "*.yml" -not -path "./vendor/*" -print0 |
5060
xargs -0 --no-run-if-empty -n1 yamllint
5161
- >
5262
find . -type f -name "*.xml" -not -path "./vendor/*" -print0 |
5363
xargs -0 --no-run-if-empty -n1 xmllint --noout --encode utf-8
54-
- ~/.composer/vendor/bin/parallel-lint ./src
55-
- ~/.composer/vendor/bin/phpcs -p -n ./src
56-
- ~/.composer/vendor/bin/security-checker -n security:check --end-point=http://security.sensiolabs.org/check_lock
64+
- 'if [[ -e ~/.composer/vendor/bin/parallel-lint ]] ; then ~/.composer/vendor/bin/parallel-lint ./src ; fi'
65+
- 'if [[ -e ~/.composer/vendor/bin/phpcs ]] ; then ~/.composer/vendor/bin/phpcs -p -n ./src ; fi'
66+
- 'if [[ -e ~/.composer/vendor/bin/security-checker ]] ; then ~/.composer/vendor/bin/security-checker -n security:check --end-point=http://security.sensiolabs.org/check_lock ; fi'
5767
- php -dxdebug.coverage_enable=1 ./vendor/bin/phpunit
5868

5969
after_script:
60-
- php ~/.ocular/ocular.phar code-coverage:upload --format=php-clover coverage.xml -vvv
70+
- >
71+
if [[ ${TRAVIS_PHP_VERSION} == "5.4" || ${TRAVIS_PHP_VERSION} == "7.2" ]] ; then
72+
php ~/.ocular/ocular.phar code-coverage:upload --format=php-clover coverage.xml -vvv ;
73+
fi

src/Endpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait Endpoint
1717
public static function endpointToURL($endpoint)
1818
{
1919
if (strpos($endpoint, '://') === false && strpos('//', $endpoint) !== 0) {
20-
$endpoint = '//'.$endpoint;
20+
$endpoint = 'https://'.$endpoint;
2121
}
2222

2323
$url = \arc\url::url($endpoint);

tests/Adapter/S3Test.php

+9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@
44

55
use PHPUnit\Framework\TestCase;
66

7+
/**
8+
* @requires PHP 5.6
9+
*/
710
class S3Test extends TestCase
811
{
912
protected $root = '';
1013

1114
public function setup()
1215
{
1316
$this->root = getenv('TEST_S3_LOCATION');
17+
if ( !class_exists('\League\Flysystem\AwsS3v3\AwsS3Adapter') ) {
18+
$this->markTestSkipped('AWSS3v3 not available, skipping test');
19+
}
1420
if ($this->root === false) {
1521
$this->markTestSkipped('no S3 endpoint available, test skipped');
1622
}
23+
if( strpos($this->root,'//') === 0) {
24+
$this->root = 's3:'.$this->root;
25+
}
1726
}
1827

1928
public function testS3()

tests/Adapter/S3v2Test.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace MJRider\FlysystemFactory\Adapter;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
/**
8+
* @requires PHP 5.4
9+
*/
10+
class S3v2Test extends TestCase
11+
{
12+
protected $root = '';
13+
14+
public function setup()
15+
{
16+
$this->root = getenv('TEST_S3_LOCATION');
17+
if ( !class_exists('\League\Flysystem\AwsS3v2\AwsS3Adapter') ) {
18+
$this->markTestSkipped('AWSS3v3 not available, skipping test');
19+
}
20+
if ($this->root === false) {
21+
$this->markTestSkipped('no S3 endpoint available, test skipped');
22+
}
23+
if( strpos($this->root,'//') === 0) {
24+
$this->root = 's3v2:'.$this->root;
25+
}
26+
}
27+
28+
public function testS3()
29+
{
30+
$filesystem = \MJRider\FlysystemFactory\create($this->root);
31+
$this->assertInstanceOf('\League\Flysystem\Filesystem', $filesystem);
32+
$this->assertInstanceOf('\League\Flysystem\AwsS3v2\AwsS3Adapter', $filesystem->getAdapter());
33+
}
34+
35+
public function testS3SubFolder()
36+
{
37+
$filesystem = \MJRider\FlysystemFactory\create($this->root);
38+
$this->assertInstanceOf('\League\Flysystem\Filesystem', $filesystem);
39+
$this->assertInstanceOf('\League\Flysystem\AwsS3v2\AwsS3Adapter', $filesystem->getAdapter());
40+
}
41+
}

0 commit comments

Comments
 (0)