File tree Expand file tree Collapse file tree 8 files changed +89
-1
lines changed Expand file tree Collapse file tree 8 files changed +89
-1
lines changed Original file line number Diff line number Diff line change 14
14
/phpunit.xml.dist export-ignore
15
15
/tests export-ignore
16
16
/tools export-ignore
17
+ /scoper.inc.php export-ignore
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ install:
12
12
- if [[ $deps = low ]]; then make update-min; else make install; fi
13
13
script :
14
14
- if [[ $deps = low ]]; then make test-min; else make test; fi
15
- - make package
15
+ - make package test-package
16
16
deploy :
17
17
provider : releases
18
18
api_key :
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ test: vendor cs deptrac phpunit infection
25
25
test-min : update-min cs deptrac phpunit infection
26
26
.PHONY : test-min
27
27
28
+ test-package : package test-package-tools
29
+ cd tests/phar && ./tools/phpunit
30
+ .PHONY : test-package
31
+
28
32
cs : tools/php-cs-fixer
29
33
tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix
30
34
.PHONY : cs
@@ -48,8 +52,14 @@ phpunit: tools/phpunit
48
52
tools : tools/php-cs-fixer tools/deptrac tools/infection tools/box
49
53
.PHONY : tools
50
54
55
+ test-package-tools : tests/phar/tools/phpunit tests/phar/tools/phpunit.d/zalas-phpunit-injector-extension.phar
56
+ .PHONY : test-package-tools
57
+
51
58
clean :
52
59
rm -rf build
60
+ rm -rf vendor
61
+ find tools -not -path ' */\.*' -type f -delete
62
+ find tests/phar/tools -not -path ' */\.*' -type f -delete
53
63
.PHONY : clean
54
64
55
65
package : tools/box
@@ -90,3 +100,11 @@ tools/infection.pubkey:
90
100
91
101
tools/box :
92
102
curl -Ls https://github.com/humbug/box/releases/download/3.0.0-beta.4/box.phar -o tools/box && chmod +x tools/box
103
+
104
+ tests/phar/tools/phpunit :
105
+ curl -Ls https://phar.phpunit.de/phpunit-7.phar -o tests/phar/tools/phpunit && chmod +x tests/phar/tools/phpunit
106
+
107
+ tests/phar/tools/phpunit.d/zalas-phpunit-injector-extension.phar : build/zalas-phpunit-injector-extension.phar
108
+ cp build/zalas-phpunit-injector-extension.phar tests/phar/tools/phpunit.d/zalas-phpunit-injector-extension.phar
109
+
110
+ build/zalas-phpunit-injector-extension.phar : package
Original file line number Diff line number Diff line change 10
10
<testsuites >
11
11
<testsuite name =" default" >
12
12
<directory suffix =" Test.php" >tests</directory >
13
+ <exclude >tests/phar</exclude >
13
14
</testsuite >
14
15
</testsuites >
15
16
Original file line number Diff line number Diff line change
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\Injector\PHPUnit\TestListener\ServiceInjectorListener" />
16
+ </listeners >
17
+
18
+ <filter >
19
+ <whitelist processUncoveredFilesFromWhitelist =" true" >
20
+ <directory suffix =" .php" >src</directory >
21
+ </whitelist >
22
+ </filter >
23
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ declare (strict_types=1 );
3
+
4
+ use PHPUnit \Framework \TestCase ;
5
+ use Psr \Container \ContainerInterface ;
6
+ use Psr \Container \NotFoundExceptionInterface ;
7
+ use Zalas \Injector \PHPUnit \TestCase \ServiceContainerTestCase ;
8
+
9
+ class PharTest extends TestCase implements ServiceContainerTestCase
10
+ {
11
+ /**
12
+ * @var stdClass
13
+ * @inject foo.service
14
+ */
15
+ private $ service ;
16
+
17
+ public function test_it_injects_services_into_test_cases ()
18
+ {
19
+ $ this ->assertInstanceOf (stdClass::class, $ this ->service );
20
+ }
21
+
22
+ public function createContainer (): ContainerInterface
23
+ {
24
+ return new class implements ContainerInterface {
25
+ public function get ($ id )
26
+ {
27
+ if ('foo.service ' === $ id ) {
28
+ return new stdClass ();
29
+ }
30
+
31
+ throw new class extends \Exception implements NotFoundExceptionInterface {
32
+ };
33
+ }
34
+
35
+ public function has ($ id )
36
+ {
37
+ return \in_array ($ id , ['foo.service ' ], true );
38
+ }
39
+ };
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ *
2
+ ! .gitignore
Original file line number Diff line number Diff line change
1
+ *
2
+ ! .gitignore
You can’t perform that action at this time.
0 commit comments