Skip to content

Commit 87b1779

Browse files
authored
Unit tests
1 parent 372f86e commit 87b1779

20 files changed

+938
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor/
22
/composer.lock
3-
/.php_cs.cache
3+
/.php_cs.cache
4+
/tests/_support/_generated/

.scrutinizer.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
checks:
2+
php:
3+
code_rating: true
4+
duplication: true
5+
6+
build:
7+
environment:
8+
php:
9+
version: 7.1
10+
tests:
11+
override:
12+
- command: vendor/bin/codecept run unit --coverage-xml=build/clover.xml
13+
coverage:
14+
file: tests/_output/build/clover.xml
15+
format: clover
16+
17+
filter:
18+
excluded_paths:
19+
- "./tests"

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
- 7.2
6+
- nightly
7+
8+
sudo: false
9+
10+
matrix:
11+
fast_finish: true
12+
allow_failures:
13+
- php: nightly
14+
15+
before_install:
16+
- travis_retry composer self-update
17+
18+
install:
19+
- composer --prefer-dist --dev install
20+
21+
script: vendor/bin/codecept run unit

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ php-cs-check:
44
$(WORKING_DIR)/vendor/bin/php-cs-fixer fix --dry-run --format=junit --diff
55

66
php-cs-fix:
7-
$(WORKING_DIR)/vendor/bin/php-cs-fixer fix
7+
$(WORKING_DIR)/vendor/bin/php-cs-fixer fix
8+
9+
test-unit:
10+
./vendor/bin/codecept run unit

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Codeception FlySystem Extension
22

3+
[![Build Status](https://travis-ci.org/lamoda/codeception-flysystem.svg?branch=master)](https://travis-ci.org/lamoda/codeception-flysystem)
4+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/?branch=master)
5+
[![Code Coverage](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/?branch=master)
6+
[![Build Status](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/badges/build.png?b=master)](https://scrutinizer-ci.com/g/lamoda/codeception-flysystem/build-status/master)
7+
38
This extension supports working with [FlySystem](https://flysystem.thephpleague.com/) with several adapters.
49

510
Provides a set of methods for checking and modifying files on remote storage.
@@ -133,3 +138,11 @@ $fileSystem->dontSeeFileFoundMatches('/test$/', '/path/to/dir');
133138
make php-cs-check
134139
make php-cs-fix
135140
```
141+
142+
### Tests
143+
144+
Unit
145+
146+
```bash
147+
make test-unit
148+
```

codeception.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
paths:
2+
tests: tests
3+
output: tests/_output
4+
data: tests/_data
5+
support: tests/_support
6+
envs: tests/_envs
7+
actor_suffix: Tester
8+
extensions:
9+
enabled:
10+
- Codeception\Extension\RunFailed
11+
coverage:
12+
enabled: true
13+
include:
14+
- src/*

src/Extension/FileSystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function copyFile($path, $newPath)
6767
*
6868
* @return array
6969
*/
70-
public function grabFileList($path)
70+
public function grabFileList($path = '')
7171
{
7272
$list = [];
7373
$content = $this->flySystem->listContents($path);

src/Extension/FlySystemModule.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Codeception\Exception\TestRuntimeException;
77
use Codeception\Module as CodeceptionModule;
88
use Lamoda\Codeception\Extension\AdapterFactory\AdapterFactoryInterface;
9-
use Exception;
109
use League\Flysystem\Filesystem as FlySystem;
1110

1211
class FlySystemModule extends CodeceptionModule
@@ -88,13 +87,13 @@ private function validateAdapterConfig(array $config, $name)
8887
*/
8988
private function createAdapterFactory($className)
9089
{
91-
try {
92-
$adapterFactory = new $className();
93-
} catch (Exception $exception) {
94-
$message = sprintf('Unexpected error happened on creation adapter factory, %s', $className);
95-
throw new ModuleConfigException(__CLASS__, $message, $exception);
90+
if (!class_exists($className)) {
91+
$message = sprintf('Adapter %s does not exist, please use another one', $className);
92+
throw new ModuleConfigException(__CLASS__, $message);
9693
}
9794

95+
$adapterFactory = new $className();
96+
9897
if (!$adapterFactory instanceof AdapterFactoryInterface) {
9998
$message = sprintf('Adapter factory class must implement %s, %s adapter factory given', AdapterFactoryInterface::class, $className);
10099
throw new ModuleConfigException(__CLASS__, $message);

tests/_data/.gitkeep

Whitespace-only changes.

tests/_output/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)