File tree Expand file tree Collapse file tree 6 files changed +108
-2
lines changed
Expand file tree Collapse file tree 6 files changed +108
-2
lines changed Original file line number Diff line number Diff line change 1919 run : composer install --prefer-dist --no-progress
2020 - name : Run tests
2121 run : php vendor/bin/phpspec run
22+ phpunit :
23+ runs-on : ubuntu-latest
24+ strategy :
25+ matrix :
26+ php : [8.1, 8.2]
27+ steps :
28+ - uses : actions/checkout@v1
29+ - uses : shivammathur/setup-php@v2
30+ with :
31+ php-version : ${{ matrix.php }}
32+ - name : Validate Composer files
33+ run : composer validate --no-check-all --strict
34+ - name : Install Composer dependencies
35+ run : composer install --prefer-dist --no-progress
36+ - name : Run tests
37+ run : php vendor/bin/phpunit
2238
Original file line number Diff line number Diff line change 1+ .phpunit.result.cache
12studio.json
23composer.phar
34composer.lock
4- vendor /
5+ vendor /
Original file line number Diff line number Diff line change 99 "Studio\\ " : " src"
1010 }
1111 },
12+ "autoload-dev" : {
13+ "psr-4" : {
14+ "StudioTests\\ " : " tests"
15+ }
16+ },
1217 "require" : {
1318 "php" : " >=8.1" ,
1419 "composer-plugin-api" : " ^2.3" ,
1823 },
1924 "require-dev" : {
2025 "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"
2229 },
2330 "replace" : {
2431 "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