Skip to content

Commit 6dedf4e

Browse files
authored
Merge pull request #6 from jakzal/phar-tests
Verify the built phar package is usable
2 parents 78bae27 + 42b45e5 commit 6dedf4e

File tree

8 files changed

+66
-3
lines changed

8 files changed

+66
-3
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install:
1212
- if [[ $deps = low ]]; then make update-min; else make install; fi
1313
script:
1414
- if [[ $deps = low ]]; then make test-min; else make test; fi
15-
- make package
15+
- make package test-package
1616
deploy:
1717
provider: releases
1818
api_key:

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ test: vendor cs phpunit
2525
test-min: update-min cs phpunit
2626
.PHONY: test-min
2727

28+
test-package: package test-package-tools
29+
cd tests/phar && ./tools/phpunit
30+
.PHONY: test-package
31+
2832
cs: tools/php-cs-fixer
2933
tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix
3034
.PHONY: cs
@@ -39,6 +43,9 @@ phpunit: tools/phpunit
3943

4044
clean:
4145
rm -rf build
46+
rm -rf vendor
47+
find tools -not -path '*/\.*' -type f -delete
48+
find tests/phar/tools -not -path '*/\.*' -type f -delete
4249
.PHONY: clean
4350

4451
package: tools/box
@@ -72,4 +79,15 @@ tools/php-cs-fixer:
7279
curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer
7380

7481
tools/box:
75-
curl -Ls https://github.com/humbug/box/releases/download/3.0.0-beta.0/box.phar -o tools/box && chmod +x tools/box
82+
curl -Ls https://github.com/humbug/box/releases/download/3.0.0-beta.4/box.phar -o tools/box && chmod +x tools/box
83+
84+
test-package-tools: tests/phar/tools/phpunit tests/phar/tools/phpunit.d/zalas-phpunit-globals-extension.phar
85+
.PHONY: test-package-tools
86+
87+
tests/phar/tools/phpunit:
88+
curl -Ls https://phar.phpunit.de/phpunit-7.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit
89+
90+
tests/phar/tools/phpunit.d/zalas-phpunit-globals-extension.phar: build/zalas-phpunit-globals-extension.phar
91+
cp build/zalas-phpunit-globals-extension.phar tests/phar/tools/phpunit.d/zalas-phpunit-globals-extension.phar
92+
93+
build/zalas-phpunit-globals-extension.phar: package

box.json.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"",
1313
"(c) Jakub Zalas <[email protected]>"
1414
]
15-
}
15+
}

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
verbose="true">
99
<testsuite name="default">
1010
<directory suffix="Test.php">tests</directory>
11+
<exclude>tests/phar</exclude>
1112
</testsuite>
1213

1314
<filter>

tests/phar/phpunit.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
4+
beStrictAboutOutputDuringTests="true"
5+
beStrictAboutTodoAnnotatedTests="true"
6+
verbose="true"
7+
extensionsDirectory="tools/phpunit.d">
8+
<testsuites>
9+
<testsuite name="default">
10+
<directory suffix="Test.php">tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
14+
<listeners>
15+
<listener class="Zalas\PHPUnit\Globals\AnnotationListener" />
16+
</listeners>
17+
18+
<filter>
19+
<whitelist processUncoveredFilesFromWhitelist="true">
20+
<directory suffix=".php">src</directory>
21+
</whitelist>
22+
</filter>
23+
</phpunit>

tests/phar/tests/PharTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use PHPUnit\Framework\TestCase;
5+
6+
class PharTest extends TestCase
7+
{
8+
/**
9+
* @env APP_ENV=test_foo
10+
* @server APP_DEBUG=1
11+
*/
12+
public function test_it_reads_global_variables_from_method_annotations()
13+
{
14+
$this->assertArraySubset(['APP_ENV' => 'test_foo'], $_ENV);
15+
$this->assertArraySubset(['APP_DEBUG' => '1'], $_SERVER);
16+
}
17+
}

tests/phar/tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.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)