Skip to content

Commit 91ecc68

Browse files
committed
Merge pull request #91 from alchemy-fr/yosmanyga-patch-2
Added empty folder to test
2 parents 729cdc1 + 5fbd3bf commit 91ecc68

File tree

7 files changed

+49
-29
lines changed

7 files changed

+49
-29
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
composer.phar
66
composer.lock
77
/tests/node_server.pid
8+
node_modules/
9+
tests/Tests/Resource/Teleporter/plop-badge/

.travis.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,27 @@ language: php
22

33
sudo: required
44

5-
env:
6-
- ZIPPY_ADAPTER=ZipAdapter
7-
- ZIPPY_ADAPTER=ZipExtensionAdapter
8-
- ZIPPY_ADAPTER=GNUTar\\TarGNUTarAdapter
9-
- ZIPPY_ADAPTER=GNUTar\\TarGzGNUTarAdapter
10-
- ZIPPY_ADAPTER=GNUTar\\TarBz2GNUTarAdapter
11-
- ZIPPY_ADAPTER=BSDTar\\TarBSDTarAdapter
12-
- ZIPPY_ADAPTER=BSDTar\\TarGzBSDTarAdapter
13-
- ZIPPY_ADAPTER=BSDTar\\TarBz2BSDTarAdapter
14-
155
php:
166
- 5.3.3
177
- 5.4
188
- 5.5
199
- 5.6
2010
- 7.0
2111

12+
env:
13+
PREFER_LOWEST=""
14+
15+
matrix:
16+
fast_finish: true
17+
include:
18+
- php: 5.3.3
19+
env: PREFER_LOWEST="--prefer-lowest"
20+
2221
before_script:
2322
- sudo apt-get install bsdtar zip
2423
- npm install connect serve-static
25-
- ./tests/bootstrap.sh start
26-
- composer update --prefer-source --no-interaction
27-
- composer require phpunit/phpunit --update-with-dependencies --prefer-source --no-interaction
24+
- composer update --prefer-source --no-interaction $PREFER_LOWEST
25+
- if [ -n "$PREFER_LOWEST" ];then composer update phpunit/phpunit --prefer-source --no-interaction --with-dependencies;fi
2826

2927
script:
30-
- ./vendor/bin/phpunit -v
31-
- ./vendor/bin/phpunit -v -c phpunit-functional.xml.dist
32-
33-
after_script:
34-
- ./tests/bootstrap.sh stop
28+
- make test

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
adapters:="ZipAdapter" "ZipExtensionAdapter" "GNUTar\\TarGNUTarAdapter" "GNUTar\\TarGzGNUTarAdapter" "GNUTar\\TarBz2GNUTarAdapter" "BSDTar\\TarBSDTarAdapter" "BSDTar\\TarGzBSDTarAdapter" "BSDTar\\TarBz2BSDTarAdapter"
2+
3+
.PHONY: test clean
4+
5+
test: node_modules
6+
-./tests/bootstrap.sh stop
7+
./tests/bootstrap.sh start
8+
sleep 1
9+
./vendor/bin/phpunit
10+
FAILURES="";$(foreach adapter,$(adapters),ZIPPY_ADAPTER=$(adapter) ./vendor/bin/phpunit -c phpunit-functional.xml.dist || FAILURES=1;)test -z "$$FAILURES"
11+
-./tests/bootstrap.sh stop
12+
13+
node_modules:
14+
npm install connect serve-static
15+
16+
clean:
17+
rm -rf node_modules

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"php": ">=5.3.3",
1616
"doctrine/collections": "~1.0",
1717
"pimple/pimple": "~1.0",
18-
"symfony/filesystem": "~2.0|^3.0",
19-
"symfony/process": "~2.0|^3.0"
18+
"symfony/filesystem": "^2.0.5|^3.0",
19+
"symfony/process": "^2.1|^3.0"
2020
},
2121
"require-dev": {
2222
"ext-zip": "*",
2323
"guzzle/guzzle": "~3.0",
24-
"sami/sami": "~1.0",
25-
"symfony/finder": "~2.0|^3.0"
24+
"phpunit/phpunit": "^4.0|^5.0",
25+
"symfony/finder": "^2.0.5|^3.0"
2626
},
2727
"suggest": {
2828
"ext-zip": "To use the ZipExtensionAdapter",

phpunit-functional.xml.dist

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
</testsuite>
2222
</testsuites>
2323
<filter>
24-
<blacklist>
25-
<directory>vendor</directory>
26-
<directory>tests</directory>
27-
</blacklist>
24+
<whitelist>
25+
<directory>src</directory>
26+
</whitelist>
2827
</filter>
2928

3029
</phpunit>

tests/Functional/Add2ArchiveTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ public static function tearDownAfterClass()
2323
*/
2424
private function create()
2525
{
26+
$directory = __DIR__ . '/samples/directory';
27+
$emptyDirectory = __DIR__ . '/samples/directory/empty';
2628
$adapter = $this->getAdapter();
2729
$extension = $this->getArchiveExtensionForAdapter($adapter);
2830

2931
self::$file = __DIR__ . '/samples/create-archive.' . $extension;
3032

33+
if (! file_exists($emptyDirectory)) {
34+
mkdir($emptyDirectory);
35+
}
3136
$archive = $adapter->create(self::$file, array(
32-
'directory' => __DIR__ . '/samples/directory',
37+
'directory' => $directory,
3338
), true);
3439

3540
return $archive;
@@ -58,19 +63,21 @@ public function testAdd()
5863

5964
$finder = new Finder();
6065
$finder
61-
->files()
6266
->in($target);
6367

6468
$files2find = array(
69+
'/directory',
70+
'/directory/empty',
6571
'/directory/README.md',
6672
'/directory/photo.jpg',
73+
'/somemorefiles',
6774
'/somemorefiles/nicephoto.jpg',
6875
);
6976

7077
foreach ($finder as $file) {
7178
$this->assertEquals(0, strpos($file->getPathname(), $target));
7279
$member = substr($file->getPathname(), strlen($target));
73-
$this->assertTrue(in_array($member, $files2find), "looking for $member in files2find");
80+
$this->assertContains($member, $files2find, "looking for $member in files2find");
7481
unset($files2find[array_search($member, $files2find)]);
7582
}
7683

tests/bootstrap.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ case $1 in
1111
test -r $NODE_SERVER_PIDFILE && echo "Previously registered pid: $(cat $NODE_SERVER_PIDFILE)"
1212
$NODE "$DIR/static-file-server.js" &
1313
echo $! > "${NODE_SERVER_PIDFILE}"
14+
echo "Server new pid: $(cat $NODE_SERVER_PIDFILE)"
1415
;;
1516
stop)
1617
test -r $NODE_SERVER_PIDFILE && kill $(cat $NODE_SERVER_PIDFILE)

0 commit comments

Comments
 (0)