Skip to content

Commit 74e1fbc

Browse files
committed
Merge pull request Potherca#12 from Potherca/feature/integration-tests
Adds integration test and preparations for upcoming release.
2 parents 6374601 + d583b77 commit 74e1fbc

File tree

9 files changed

+265
-21
lines changed

9 files changed

+265
-21
lines changed

.gitignore

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
build
2-
vendor
1+
/* Directories to ignore */
2+
/build
3+
/vendor
4+
/tests/fixtures/integration-test-repository
35

4-
composer.lock
5-
phpunit.xml
6+
/* Files to ignore */
7+
.env
8+
/composer.lock
9+
/phpunit.xml

CHANGELOG.md

+27
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,56 @@ and [Semantic Versioning](http://semver.org/) conventions.
1313
### Security
1414
-->
1515

16+
## [Unreleased][unreleased]
17+
18+
### Added
19+
20+
- Adds various @throws annotations
21+
- Adds timestamps for files and folders
22+
- Adds integration tests to validate output against comparable output from LocalAdapter
23+
24+
### Changed
25+
26+
- Changes the default for file visibility to visible
27+
- Changes guessing MIME type for files to always use the file's content instead of extension to guarantee results are the same across different filesystem adapters
28+
- Changes method name of ApiInterface::getRecursiveMetadata() to ApiInterface::getTreeMetadata()
29+
30+
### Fixed
31+
32+
- Fixes bug that caused invalid repository names to be accepted (issue #4)
33+
- Fixes bug that caused incorrect Metadata for directories to be returned (issue #6)
34+
- Fixes bug that didn't validate paths ended in a trailing slash (issue #8)
35+
- Fixes bug in permission comparison
36+
- Fixes various links in the README file
37+
1638
## [v0.2.0] - 2015-07-21 - Improvements and UnitTests
1739

1840
### Added
41+
1942
- Adds automated checks (a.k.a. unit-tests) for the Adapter, Client and Settings classes.
2043
- Adds various utility files for Travis builds, Coveralls and Composer
2144

2245
### Changed
46+
2347
- Makes the PHPUnit configuration more strict
2448
- Renames the Client class to "Api"
2549

2650
## [v0.1.0] - 2015-07-18 - Read functionality
2751

2852
### Added
53+
2954
- Read functionality and Github API authentication have been implemented.
3055

3156
## v0.0.0 - 2015-05-11 - Project Setup
3257

3358
### Added
59+
3460
- Set up project basics like .gitignore file, PHPUnit Configuration file,
3561
Contributing guidelines, Composer file stating dependencies, MIT License, README
3662
file and this CHANGELOG file.
3763

3864
[unreleased]: https://github.com/potherca/flysystem-github/compare/v0.2.0...HEAD
65+
[v0.3.0]: https://github.com/potherca/flysystem-github/compare/v0.2.0...v0.3.0
3966
[v0.2.0]: https://github.com/potherca/flysystem-github/compare/v0.1.0...v0.2.0
4067
[v0.1.0]: https://github.com/potherca/flysystem-github/compare/v0.0.0...v0.1.0
4168
[keep-a-changelog]: http://keepachangelog.com/

CONTRIBUTING.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ Contributions are **welcome** and will be fully **credited**.
44

55
We accept contributions via Pull Requests on [Github](https://github.com/potherca/flysystem-github).
66

7-
87
## Pull Requests
98

109
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
1110

1211
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
1312

14-
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
13+
- **Document any change in behaviour** - Make sure the `README.md`, `CHANGELOG.md` and any other relevant documentation are kept up-to-date.
1514

1615
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
1716

@@ -21,7 +20,6 @@ We accept contributions via Pull Requests on [Github](https://github.com/potherc
2120

2221
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
2322

24-
2523
## Running Tests
2624

2725
``` bash

README.md

+34-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Flysystem Adapter for Github
22

3-
[![Latest Version](https://img.shields.io/github/release/potherca/flysystem-github.svg?style=flat-square)](https://github.com/potherca/flysystem-github/releases)
4-
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5-
[![Build Status](https://img.shields.io/travis/potherca/flysystem-github.svg?style=flat-square)](https://travis-ci.org/potherca/flysystem-github)
6-
[![Coverage Status](https://coveralls.io/repos/potherca/flysystem-github/badge.svg)](https://coveralls.io/github/potherca/flysystem-github)
7-
[![Quality Score](https://img.shields.io/scrutinizer/g/potherca/flysystem-github.svg?style=flat-square)](https://scrutinizer-ci.com/g/potherca/flysystem-github)
8-
[![Total Downloads](https://img.shields.io/packagist/dt/potherca/flysystem-github.svg?style=flat-square)](https://packagist.org/packages/potherca/flysystem-github)
3+
[![Latest Version][Latest Version Badge]][Release Page]
4+
[![Software License][Software License Badge]][License file]
5+
[![Build Status][Build Status Badge]][Travis Page]
6+
[![Coverage Status][Coverage Status Badge]][Coveralls Page]
7+
[![Quality Score][Quality Score Badge]][Scrutinizer Page]
8+
[![Total Downloads][Total Downloads Badge]][Packagist Page]
99

1010
## Install
1111

@@ -89,10 +89,23 @@ $filesystem = new Filesystem($adapter);
8989

9090
## Testing
9191

92+
The unit-tests can be run with the following command:
93+
9294
``` bash
9395
$ composer test
9496
```
9597

98+
To run integration tests, which use the Github API, a [Github API token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) might be needed (to stop the tests hitting the API Limit).
99+
An API key can be added by setting in the environment as `GITHUB_API_KEY` or by vreating an `.env` file in the integration tests directory and setting it there.
100+
See `tests/integration-tests/.env.example` for an example.
101+
102+
To run the integration test, run the following command (this will also run the unit-tests):
103+
104+
``` bash
105+
$ composer test-all
106+
```
107+
108+
96109
## Security
97110

98111
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
@@ -111,4 +124,18 @@ Please see [CHANGELOG](CHANGELOG.md) for details.
111124

112125
## License
113126

114-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
127+
The MIT License (MIT). Please see [License File] for more information.
128+
129+
[Release Page]: https://github.com/potherca/flysystem-github/releases
130+
[License File]: LICENSE.md
131+
[Travis Page]: https://travis-ci.org/Potherca/flysystem-github
132+
[Coveralls Page]: https://coveralls.io/github/potherca/flysystem-github
133+
[Scrutinizer Page]: https://scrutinizer-ci.com/g/potherca/flysystem-github
134+
[Packagist Page]: https://packagist.org/packages/potherca/flysystem-github
135+
136+
[Latest Version Badge]: https://img.shields.io/github/release/potherca/flysystem-github.svg
137+
[Software License Badge]: https://img.shields.io/badge/license-MIT-brightgreen.svg
138+
[Build Status Badge]: https://img.shields.io/travis/Potherca/flysystem-github.svg
139+
[Coverage Status Badge]: https://coveralls.io/repos/potherca/flysystem-github/badge.svg
140+
[Quality Score Badge]: https://img.shields.io/scrutinizer/g/potherca/flysystem-github.svg
141+
[Total Downloads Badge]: https://img.shields.io/packagist/dt/potherca/flysystem-github.svg

build/phpunit.xml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
55

66
backupGlobals="false"
77

@@ -22,15 +22,20 @@
2222
verbose="true"
2323
>
2424
<testsuites>
25-
<testsuite name="Flysystem Github Adapter Test Suite">
26-
<directory>../tests</directory>
25+
<testsuite name="Flysystem Github Adapter - Unit Tests">
26+
<directory>../tests/unit-tests</directory>
27+
</testsuite>
28+
<testsuite name="Flysystem Github Adapter - Integration Tests">
29+
<directory suffix=".php">../tests/integration-tests</directory>
2730
</testsuite>
2831
</testsuites>
32+
2933
<filter>
3034
<whitelist>
3135
<directory suffix=".php">src/</directory>
3236
</whitelist>
3337
</filter>
38+
3439
<logging>
3540
<log type="testdox-text" target="testdox.txt"/>
3641
<log type="tap" target="report.tap"/>

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
},
2727
"require-dev": {
2828
"php" : ">=5.5",
29+
"josegonzalez/dotenv": "~2.0",
2930
"phpunit/phpunit" : "~4.8",
3031
"satooshi/php-coveralls": "~0.6",
3132
"scrutinizer/ocular": "~1.1",
@@ -47,6 +48,7 @@
4748
}
4849
},
4950
"scripts": {
50-
"test" : "phpunit"
51+
"test" : "phpunit",
52+
"test-all" : "phpunit --configuration build/phpunit.xml"
5153
}
5254
}

src/Settings.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ final public function __construct(
101101
private function isValidRepositoryName($repository)
102102
{
103103
if (is_string($repository) === false
104-
|| substr_count($repository, '/') !== 1
105-
|| substr($repository, 0, 1) === '/'
106-
|| substr($repository, -1, 1) === '/'
104+
|| preg_match('#^[^/]+/[^/]+$#', $repository) !== 1
107105
) {
108106
$message = sprintf(
109107
self::ERROR_INVALID_REPOSITORY_NAME,

tests/integration-tests/.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Github API key used by integration tests
2+
GITHUB_API_KEY='abcdef0123456789abcdef0123456789abcdef01'

0 commit comments

Comments
 (0)