Skip to content

Commit eeb07dd

Browse files
authored
Add e2e test (#55)
1 parent b6e499c commit eeb07dd

File tree

10 files changed

+84
-7
lines changed

10 files changed

+84
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/dist/
44
/build/
55
/composer.lock
6+
/fixtures/*/vendor
67
/vendor/
78
/vendor-bin/box/vendor/
89
/vendor-bin/box/composer.lock

.travis.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cache:
1313
matrix:
1414
include:
1515
- php: '7.0'
16+
env: COVERAGE='true'
1617
- php: '7.1'
1718
- php: '7.1'
1819
env: COMPOSER_FLAGS='--prefer-lowest'
@@ -23,6 +24,22 @@ matrix:
2324

2425
before_script: phpenv config-rm xdebug.ini || true
2526

26-
install: composer update --no-interaction --no-progress --no-suggest --prefer-dist $COMPOSER_FLAGS
27+
install:
28+
- set -eo pipefail
29+
- composer update --no-interaction --no-progress --no-suggest --prefer-dist $COMPOSER_FLAGS
30+
- |
31+
if [ "$COVERAGE" == "true" ]; then
32+
composer bin box update --no-interaction --no-progress --no-suggest --prefer-dist $COMPOSER_FLAGS
33+
fi
2734
28-
script: phpdbg -qrr vendor/bin/phpunit --verbose --coverage-text
35+
script:
36+
- |
37+
if [ "$COVERAGE" == "true" ]; then
38+
make tc
39+
make e2e
40+
else
41+
make tu
42+
fi
43+
44+
notifications:
45+
email: false

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BOX=vendor-bin/box/vendor/bin/box
22
PHPUNIT=vendor/bin/phpunit
33

44
.DEFAULT_GOAL := help
5-
.PHONY: build test tc
5+
.PHONY: build test tu tc e2e
66

77

88
help:
@@ -29,14 +29,25 @@ build: bin/php-scoper
2929
## Tests
3030
##---------------------------------------------------------------------------
3131

32-
test: ## Run PHPUnit tests
33-
test: vendor
32+
test: ## Run all the tests
33+
test: tu e2e
34+
35+
tu: ## Run PHPUnit tests
36+
tu: vendor
3437
php -d zend.enable_gc=0 $(PHPUNIT)
3538

3639
tc: ## Run PHPUnit tests with test coverage
3740
tc: vendor
3841
phpdbg -qrr -d zend.enable_gc=0 $(PHPUNIT) --coverage-html=dist/coverage --coverage-text
3942

43+
e2e: ## Run end-to-end tests
44+
e2e: vendor
45+
php -d zend.enable_gc=0 bin/php-scoper add-prefix fixtures/set004 -o build/set004 -f
46+
composer -d=build/set004 dump-autoload
47+
php -d zend.enable_gc=0 $(BOX) build -c build/set004/box.json.dist
48+
php build/set004/bin/greet.phar > build/output
49+
diff fixtures/set004/expected-output build/output
50+
4051

4152
##
4253
## Rules from files

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ install:
5454

5555
test_script:
5656
- cd c:\projects\webmozart\php-scoper
57-
- vendor\bin\phpunit -c phpunit.xml.dist
57+
- make tu

bin/php-scoper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
use function Humbug\PhpScoper\create_application;
13+
namespace Humbug\PhpScoper;
1414

1515
if (file_exists($autoload = __DIR__.'/../../../autoload.php')) {
1616
require_once $autoload;

fixtures/set004/bin/greet.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once __DIR__.'/../vendor/autoload.php';
6+
7+
use Set004\Greeter;
8+
9+
echo (new Greeter())->greet().PHP_EOL;

fixtures/set004/box.json.dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"output": "build/set004/bin/greet.phar",
3+
"main": "bin/greet.php",
4+
"base-path": "build/set004",
5+
"directories": [
6+
"src",
7+
"vendor"
8+
],
9+
"compression": "GZ",
10+
"compactors": [
11+
"Herrera\\Box\\Compactor\\Json",
12+
"Herrera\\Box\\Compactor\\Php"
13+
],
14+
"stub": true
15+
}

fixtures/set004/composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"bin": [
3+
"bin/greet"
4+
],
5+
"autoload": {
6+
"psr-4": {
7+
"Set004\\": "src/"
8+
}
9+
}
10+
}

fixtures/set004/expected-output

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

fixtures/set004/src/Greeter.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Set004;
6+
7+
class Greeter
8+
{
9+
public function greet(): string
10+
{
11+
return 'Hello world!';
12+
}
13+
}

0 commit comments

Comments
 (0)