File tree Expand file tree Collapse file tree 6 files changed +95
-3
lines changed Expand file tree Collapse file tree 6 files changed +95
-3
lines changed Original file line number Diff line number Diff line change 17
17
run : composer validate --no-check-all --strict
18
18
- name : Install Composer dependencies
19
19
run : composer install --prefer-dist --no-progress
20
- - name : Run tests
20
+ - name : Run spec tests
21
21
run : php vendor/bin/phpspec run
22
+ - name : Run unit tests
23
+ run : php vendor/bin/phpunit
22
24
Original file line number Diff line number Diff line change
1
+ .phpunit.result.cache
1
2
studio.json
2
3
composer.phar
3
4
composer.lock
4
- vendor /
5
+ vendor /
Original file line number Diff line number Diff line change 9
9
"Studio\\ " : " src"
10
10
}
11
11
},
12
+ "autoload-dev" : {
13
+ "psr-4" : {
14
+ "StudioTests\\ " : " tests"
15
+ }
16
+ },
12
17
"require" : {
13
18
"php" : " >=8.1" ,
14
19
"composer-plugin-api" : " ^2.3" ,
18
23
},
19
24
"require-dev" : {
20
25
"composer/composer" : " ^2.5" ,
21
- "phpspec/phpspec" : " ^7.4"
26
+ "phpspec/phpspec" : " ^7.4" ,
27
+ "phpunit/phpunit" : " ^9.6 | ^10" ,
28
+ "mikey179/vfsstream" : " ^1.6.11"
22
29
},
23
30
"replace" : {
24
31
"franzliedke/studio" : " self.version"
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+
3
+ <phpunit bootstrap = " vendor/autoload.php" colors = " true" >
4
+
5
+ <testsuites >
6
+ <testsuite name =" Project Test Suite" >
7
+ <directory >tests</directory >
8
+ </testsuite >
9
+ </testsuites >
10
+
11
+ <php >
12
+ <env name =" APP_ENV" value =" testing" />
13
+ <env name =" APP_VERSION" value =" 0.15.0" />
14
+ </php >
15
+
16
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace StudioTests \Console ;
4
+
5
+ use PHPUnit \Framework \TestCase ;
6
+ use Studio \Console \CreateCommand ;
7
+ use Symfony \Component \Console \Application ;
8
+ use Symfony \Component \Console \Command \Command ;
9
+ use Symfony \Component \Console \Tester \CommandTester ;
10
+
11
+ abstract class AbstractConsoleTest extends TestCase
12
+ {
13
+ protected function executeCommand (array $ arguments , array $ inputs = []): CommandTester
14
+ {
15
+ $ application = new Application ('studio ' , getenv ('APP_VERSION ' ));
16
+ $ application ->add (new CreateCommand );
17
+
18
+ // this uses a special testing container that allows you to fetch private services
19
+ /** @var Command $command */
20
+ $ command = $ application ->get ($ this ->getCommandFqcn ());
21
+
22
+ $ commandTester = new CommandTester ($ command );
23
+ $ commandTester ->setInputs ($ inputs );
24
+ $ commandTester ->execute ($ arguments );
25
+
26
+ return $ commandTester ;
27
+ }
28
+
29
+ abstract protected function getCommandFqcn (): string ;
30
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace StudioTests \Console ;
4
+
5
+ use org \bovigo \vfs \vfsStream ;
6
+ use Symfony \Component \Console \Tester \CommandTester ;
7
+
8
+ class CreateTest extends AbstractConsoleTest
9
+ {
10
+ private $ root ;
11
+
12
+ public function setUp (): void
13
+ {
14
+ $ this ->root = vfsStream::setup ();
15
+ }
16
+
17
+ function testExecute (): void
18
+ {
19
+ $ commandTester = $ this ->executeCommand (
20
+ ['path ' => $ this ->root ->url () . '/company/my-package ' ],
21
+ [
22
+ // package name
23
+ 'company/my-package ' ,
24
+ // default namespace (psr-4)
25
+ 'Company/MyPackage ' ,
26
+ ]
27
+ );
28
+
29
+ $ this ->assertTrue ($ this ->root ->hasChild ('company/my-package ' ));
30
+ }
31
+
32
+ protected function getCommandFqcn (): string
33
+ {
34
+ return 'create ' ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments