diff --git a/.travis.yml b/.travis.yml
index 122f12c..45e7b43 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,19 +4,13 @@ matrix:
include:
- php: 7.2
dist: bionic
- env: COMPOSER_OPTS=""
- php: 7.3
dist: bionic
- env: COMPOSER_OPTS=""
- php: 7.4
dist: bionic
- env: COMPOSER_OPTS=""
- php: nightly
dist: bionic
- env: COMPOSER_OPTS="--ignore-platform-reqs"
- allow_failures:
- - php: nightly
- env: COMPOSER_OPTS="--ignore-platform-reqs"
+ env: COMPOSER_OPTS="--ignore-platform-req=php"
cache:
directories:
@@ -25,10 +19,28 @@ cache:
install:
- travis_retry composer install $COMPOSER_OPTS
+ # Where PHPUnit v8 is used, we need to replace the config.
+ - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]
+ && [ ${TRAVIS_PHP_VERSION:2:1} -lt 4 ]; then
+ cp -v tests/phpunit.legacy.xml tests/phpunit.xml
+ ; fi
+
+ # PHPUnit 9 supports 7.3, but Infection PHP 18 can't read
+ # its config so instead we downgrade to PHPUnit 8.5 here.
+ - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.3" ]]; then
+ travis_retry composer require -W phpunit/phpunit:^8.5
+ ; fi
+
script:
- vendor/bin/grumphp run
- composer test
- - composer infection
+
+ - if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then composer infection; else
+ vendor/bin/infection --ansi --threads=4
+ --initial-tests-php-options="-d xdebug.mode=coverage"
+ --only-covered --min-msi=100 --min-covered-msi=100
+ ; fi
+
- composer psalm
after_success: bash <(curl -s https://codecov.io/bash)
diff --git a/composer.json b/composer.json
index 861d967..323af8e 100644
--- a/composer.json
+++ b/composer.json
@@ -7,12 +7,12 @@
"process-timeout": 0
},
"require-dev": {
- "phpunit/phpunit": "^8.5",
- "vimeo/psalm": "^3.11",
- "infection/infection": "^0.15.3",
- "spatie/phpunit-watcher": "^1.22",
- "phpunit/php-invoker": "^2.0",
- "pluswerk/grumphp-config": "^3.0"
+ "phpunit/phpunit": "^8.5 || ^9.4",
+ "vimeo/psalm": "^4.1",
+ "infection/infection": "^0.15.3 || ^0.18.2 || ^0.20.1",
+ "spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf",
+ "phpunit/php-invoker": "^2.0 || ^3.1",
+ "pluswerk/grumphp-config": "^4.0.1"
},
"license": "MIT",
"authors": [
diff --git a/src/Conditional/BasicExpression.php b/src/Conditional/BasicExpression.php
index 5f70512..a211958 100644
--- a/src/Conditional/BasicExpression.php
+++ b/src/Conditional/BasicExpression.php
@@ -17,7 +17,7 @@ abstract class BasicExpression implements ShellInterface
* This is not POSIX-compatible (only eg. Korn and Bash), beware before using it
* @var bool
*/
- protected $bashEnhancedBrackets;
+ protected $bashEnhancedBrackets = false;
/** @var bool this is always double quoted */
protected $escapedValue = false;
/** @var bool */
diff --git a/src/Literal/ShellWord.php b/src/Literal/ShellWord.php
index 1dc11c3..1c08b49 100644
--- a/src/Literal/ShellWord.php
+++ b/src/Literal/ShellWord.php
@@ -64,9 +64,9 @@ class ShellWord implements ShellInterface
/** @var string */
protected $delimiter = ' ';
/** @var string */
- protected $argument;
+ protected $argument = '';
/** @var string|ShellInterface */
- protected $value;
+ protected $value = '';
/**
* The constructor is protected, you must choose one of the children
diff --git a/tests/Collection/CollectionTupleTest.php b/tests/Collection/CollectionTupleTest.php
index 00a4c15..8b85211 100644
--- a/tests/Collection/CollectionTupleTest.php
+++ b/tests/Collection/CollectionTupleTest.php
@@ -45,6 +45,13 @@ public function testTupleToArray(): void
$this->assertEquals(['||', 'a'], $tuple->__toArray());
}
+ public function testToArrayWithBuilder(): void
+ {
+ $builder = ShellBuilder::command('echo')->addArgument('hunter1');
+ $tuple = CollectionTuple::create($builder, ControlOperator::AND_OPERATOR);
+ $this->assertEquals(['&&', $builder->__toArray()], $tuple->__toArray());
+ }
+
public function testWithoutCreatingTuple(): void
{
$tuple = new Pipeline();
diff --git a/tests/ShellBuilderTest.php b/tests/ShellBuilderTest.php
index 489ff8f..26a9fe6 100644
--- a/tests/ShellBuilderTest.php
+++ b/tests/ShellBuilderTest.php
@@ -756,7 +756,7 @@ static function (ShellBuilder $builder) {
public function testComplexCondiditionalArgumentsWithWrongArguments(): void
{
- self::expectException(\ErrorException::class);
+ self::expectException(\AssertionError::class);
ShellBuilder::new()
->ifThis(static function (ShellBuilder $builder) {
return 'world';
@@ -769,7 +769,7 @@ public function testComplexCondiditionalArgumentsWithWrongArguments(): void
public function testCondiditionalArgumentsWithWrongArguments(): void
{
- self::expectException(\ErrorException::class);
+ self::expectException(\AssertionError::class);
ShellBuilder::new()
->if(
true,
diff --git a/tests/phpunit-bootstrap.php b/tests/phpunit-bootstrap.php
index 6ae37fa..de1f40d 100644
--- a/tests/phpunit-bootstrap.php
+++ b/tests/phpunit-bootstrap.php
@@ -3,6 +3,7 @@
declare(strict_types=1);
error_reporting(E_ALL);
+ini_set('assert.exception', '1');
ini_set('display_errors', '1');
// Currently phpunit's default error handling doesn't properly catch warnings / errors from data providers
diff --git a/tests/phpunit.legacy.xml b/tests/phpunit.legacy.xml
new file mode 100644
index 0000000..79941c1
--- /dev/null
+++ b/tests/phpunit.legacy.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ ../tests/
+
+
+
+
+ ../src/
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 79941c1..45ea586 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -1,5 +1,5 @@
-
+ colors="true"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
+
+
+ ../src/
+
+
+
+
+
+
+
../tests/
-
-
- ../src/
-
-
-
-
-
-
-
-
+
+
+