diff --git a/.travis.yml b/.travis.yml
index bea304ca9..95ea141b7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,38 +2,51 @@ language: php
php:
- 7.0
- 7.1
+ - 7.2
env:
matrix:
include:
- php: 7.0
env: coverage=on
+ - php: 7.1
+ env: codingStandard=on
allow_failures:
- php: 7.0
env: coverage=on
+ - php: 7.2
script:
- vendor/bin/tester tests -s -c tests/php-unix.ini $coverageArgs
- - php temp/code-checker/src/code-checker.php --short-arrays --strict-types -i tests/Utils/files
+ - >
+ if [ "$codingStandard" ]; then
+ php temp/code-checker/src/code-checker.php --short-arrays --strict-types -i tests/Utils/files
+ && php temp/coding-standard/ecs check src tests --config temp/coding-standard/coding-standard-php70.neon;
+ fi
after_failure:
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
before_script:
- # Install Nette Tester & Code Checker
+ # Install Nette Tester
- travis_retry composer install --no-interaction --prefer-dist
- - travis_retry composer create-project nette/code-checker temp/code-checker ~2.8 --no-interaction
- - if [ "$coverage" == "on" ]; then coverageArgs="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi
+ # Install Code Checkers
+ - >
+ if [ "$codingStandard" ]; then
+ travis_retry composer create-project nette/code-checker temp/code-checker ~2 --no-interaction;
+ travis_retry composer create-project nette/coding-standard temp/coding-standard --no-interaction;
+ fi
+ - if [ "$coverage" ]; then coverageArgs="-p phpdbg --coverage ./coverage.xml --coverage-src ./src"; fi
after_script:
# Report Code Coverage
- >
- if [ "$coverage" == "on" ]; then
+ if [ "$coverage" ]; then
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar
- && php coveralls.phar --verbose --config tests/.coveralls.yml
- || true; fi
+ && php coveralls.phar --verbose --config tests/.coveralls.yml;
+ fi
sudo: false
diff --git a/src/Utils/Html.php b/src/Utils/Html.php
index cc4631c5b..9dd928293 100644
--- a/src/Utils/Html.php
+++ b/src/Utils/Html.php
@@ -478,7 +478,7 @@ final public function getChildren(): array
/**
* Renders element's start tag, content and end tag.
*/
- final public function render(int $indent = null): string
+ final public function render(int $indent = null, string $indentChar = "\t"): string
{
$s = $this->startTag();
@@ -489,7 +489,7 @@ final public function render(int $indent = null): string
}
foreach ($this->children as $child) {
if (is_object($child)) {
- $s .= $child->render($indent);
+ $s .= $child->render($indent, $indentChar);
} else {
$s .= $child;
}
@@ -500,7 +500,7 @@ final public function render(int $indent = null): string
}
if ($indent !== null) {
- return "\n" . str_repeat("\t", $indent - 1) . $s . "\n" . str_repeat("\t", max(0, $indent - 2));
+ return "\n" . str_repeat($indentChar, $indent - 1) . $s . "\n" . str_repeat($indentChar, max(0, $indent - 2));
}
return $s;
}
diff --git a/tests/Utils/ArrayHash.phpt b/tests/Utils/ArrayHash.phpt
index 6a998bd7e..0545fd630 100644
--- a/tests/Utils/ArrayHash.phpt
+++ b/tests/Utils/ArrayHash.phpt
@@ -126,7 +126,11 @@ test(function () { // numeric fields
foreach ($row as $key => $value) {
$keys[] = $key;
}
- Assert::same(['0', '1'], $keys);
+ if (PHP_VERSION_ID < 70200) {
+ Assert::same(['0', '1'], $keys);
+ } else {
+ Assert::same([0, 1], $keys);
+ }
Assert::same(1, $row->{0});
Assert::same(1, $row->{'0'});
diff --git a/tests/Utils/Html.children.phpt b/tests/Utils/Html.children.phpt
index 7b982f993..134b4d9e3 100644
--- a/tests/Utils/Html.children.phpt
+++ b/tests/Utils/Html.children.phpt
@@ -28,6 +28,14 @@ test(function () { // add
two
', $el->render(2), 'indentation');
+
+ Assert::match('
+
+', $el->render(2, ' '), 'indentation');
});
diff --git a/tests/Utils/Image.alpha1.phpt b/tests/Utils/Image.alpha1.phpt
index 9a7094b48..410526b88 100644
--- a/tests/Utils/Image.alpha1.phpt
+++ b/tests/Utils/Image.alpha1.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image alpha channel.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$rectangle = Image::fromBlank(100, 100, Image::rgb(255, 255, 255, 127));
$rectangle->filledRectangle(25, 25, 74, 74, Image::rgb(255, 0, 0, 63));
diff --git a/tests/Utils/Image.alpha2.phpt b/tests/Utils/Image.alpha2.phpt
index 721b4ff86..c041017dc 100644
--- a/tests/Utils/Image.alpha2.phpt
+++ b/tests/Utils/Image.alpha2.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image alpha channel.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 100);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.png'), $image->toString(Image::PNG, 0));
diff --git a/tests/Utils/Image.clone.phpt b/tests/Utils/Image.clone.phpt
index a562c08c5..7a611ee83 100644
--- a/tests/Utils/Image.clone.phpt
+++ b/tests/Utils/Image.clone.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image cloning.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$original = Image::fromFile(__DIR__ . '/images/logo.gif');
$dolly = clone $original;
diff --git a/tests/Utils/Image.drawing.phpt b/tests/Utils/Image.drawing.phpt
index a74d44f86..346bddf53 100644
--- a/tests/Utils/Image.drawing.phpt
+++ b/tests/Utils/Image.drawing.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image drawing.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$size = 300;
$image = Image::fromBlank($size, $size);
diff --git a/tests/Utils/Image.factories.phpt b/tests/Utils/Image.factories.phpt
index b43aa2d49..26c600aa3 100644
--- a/tests/Utils/Image.factories.phpt
+++ b/tests/Utils/Image.factories.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image factories.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
test(function () {
$image = Image::fromFile(__DIR__ . '/images/logo.gif', $format);
Assert::same(176, $image->getWidth());
diff --git a/tests/Utils/Image.place.phpt b/tests/Utils/Image.place.phpt
index 9ea0389c2..4fec1a48a 100644
--- a/tests/Utils/Image.place.phpt
+++ b/tests/Utils/Image.place.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image place image.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$rectangle = Image::fromBlank(50, 50, Image::rgb(255, 255, 255));
$image = Image::fromBlank(100, 100, Image::rgb(0, 0, 0));
diff --git a/tests/Utils/Image.resize.phpt b/tests/Utils/Image.resize.phpt
index 94e570462..003d73bc5 100644
--- a/tests/Utils/Image.resize.phpt
+++ b/tests/Utils/Image.resize.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image crop, resize & flip.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$main = Image::fromFile(__DIR__ . '/images/logo.gif');
diff --git a/tests/Utils/Image.save.phpt b/tests/Utils/Image.save.phpt
index 929313b5f..ecbcf4704 100644
--- a/tests/Utils/Image.save.phpt
+++ b/tests/Utils/Image.save.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image save method exceptions.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$main = Image::fromFile(__DIR__ . '/images/alpha1.png');
diff --git a/tests/Utils/Image.send.phpt b/tests/Utils/Image.send.phpt
index c23cfe207..509d8bb99 100644
--- a/tests/Utils/Image.send.phpt
+++ b/tests/Utils/Image.send.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Image send method exceptions.
+ * @phpExtension gd
*/
declare(strict_types=1);
@@ -13,11 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
-if (!extension_loaded('gd')) {
- Tester\Environment::skip('Requires PHP extension GD.');
-}
-
-
$main = Image::fromFile(__DIR__ . '/images/alpha1.png');
diff --git a/tests/Utils/Object.arrayProperty.phpt b/tests/Utils/Object.arrayProperty.phpt
index ee643b451..5b2ca7eb9 100644
--- a/tests/Utils/Object.arrayProperty.phpt
+++ b/tests/Utils/Object.arrayProperty.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object array property.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.closureProperty.phpt b/tests/Utils/Object.closureProperty.phpt
index 4f4215812..ccb344e1a 100644
--- a/tests/Utils/Object.closureProperty.phpt
+++ b/tests/Utils/Object.closureProperty.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object closure properties.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.events.phpt b/tests/Utils/Object.events.phpt
index ee99d5cef..3879104f5 100644
--- a/tests/Utils/Object.events.phpt
+++ b/tests/Utils/Object.events.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object event handlers.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.extensionMethod.phpt b/tests/Utils/Object.extensionMethod.phpt
index 4e441ce10..045975684 100644
--- a/tests/Utils/Object.extensionMethod.phpt
+++ b/tests/Utils/Object.extensionMethod.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object extension method.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.extensionMethodViaInterface.phpt b/tests/Utils/Object.extensionMethodViaInterface.phpt
index bcc428e1f..8866c7018 100644
--- a/tests/Utils/Object.extensionMethodViaInterface.phpt
+++ b/tests/Utils/Object.extensionMethodViaInterface.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object extension method via interface.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.magicMethod.errors.phpt b/tests/Utils/Object.magicMethod.errors.phpt
index 8cb6901dc..5fe62d277 100644
--- a/tests/Utils/Object.magicMethod.errors.phpt
+++ b/tests/Utils/Object.magicMethod.errors.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object magic @methods errors.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.magicMethod.inheritance.phpt b/tests/Utils/Object.magicMethod.inheritance.phpt
index 3fea5bf71..0fe17fa10 100644
--- a/tests/Utils/Object.magicMethod.inheritance.phpt
+++ b/tests/Utils/Object.magicMethod.inheritance.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object magic @methods inheritance.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.magicMethod.phpt b/tests/Utils/Object.magicMethod.phpt
index 7844a2a1a..7ec4dc57b 100644
--- a/tests/Utils/Object.magicMethod.phpt
+++ b/tests/Utils/Object.magicMethod.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object magic @methods.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.magicMethod.types.phpt b/tests/Utils/Object.magicMethod.types.phpt
index 73b0250d8..a28503cad 100644
--- a/tests/Utils/Object.magicMethod.types.phpt
+++ b/tests/Utils/Object.magicMethod.types.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object magic @methods and types.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.methodGetter.phpt b/tests/Utils/Object.methodGetter.phpt
index 6cd3124b8..c0cbeb32b 100644
--- a/tests/Utils/Object.methodGetter.phpt
+++ b/tests/Utils/Object.methodGetter.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object closure properties.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.property.phpt b/tests/Utils/Object.property.phpt
index 8f6406dd8..11b7563fb 100644
--- a/tests/Utils/Object.property.phpt
+++ b/tests/Utils/Object.property.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object properties.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.referenceProperty.phpt b/tests/Utils/Object.referenceProperty.phpt
index c2950faf3..4bccbb7e9 100644
--- a/tests/Utils/Object.referenceProperty.phpt
+++ b/tests/Utils/Object.referenceProperty.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object reference to property.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.reflection.phpt b/tests/Utils/Object.reflection.phpt
index ae8d6ed87..d13329a0a 100644
--- a/tests/Utils/Object.reflection.phpt
+++ b/tests/Utils/Object.reflection.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object reflection.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.undeclaredMethod.phpt b/tests/Utils/Object.undeclaredMethod.phpt
index 8327497aa..efcf953c3 100644
--- a/tests/Utils/Object.undeclaredMethod.phpt
+++ b/tests/Utils/Object.undeclaredMethod.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object undeclared method.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Object.unsetProperty.phpt b/tests/Utils/Object.unsetProperty.phpt
index d507a0f36..289bdbf0b 100644
--- a/tests/Utils/Object.unsetProperty.phpt
+++ b/tests/Utils/Object.unsetProperty.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Object properties.
+ * @phpVersion < 7.2
*/
declare(strict_types=1);
diff --git a/tests/Utils/Reflection.getParameterType.php71.phpt b/tests/Utils/Reflection.getParameterType.php71.phpt
index 82385c166..941ffc083 100644
--- a/tests/Utils/Reflection.getParameterType.php71.phpt
+++ b/tests/Utils/Reflection.getParameterType.php71.phpt
@@ -2,7 +2,7 @@
/**
* Test: Nette\Utils\Reflection::getParameterType
- * @phpversion 7.1
+ * @phpVersion 7.1
*/
declare(strict_types=1);
diff --git a/tests/Utils/Reflection.getReturnType.php71.phpt b/tests/Utils/Reflection.getReturnType.php71.phpt
index 783a71f36..21c6d5ba9 100644
--- a/tests/Utils/Reflection.getReturnType.php71.phpt
+++ b/tests/Utils/Reflection.getReturnType.php71.phpt
@@ -2,7 +2,7 @@
/**
* Test: Nette\Utils\Reflection::getReturnType
- * @phpversion 7.1
+ * @phpVersion 7.1
*/
declare(strict_types=1);
diff --git a/tests/Utils/Strings.compare().phpt b/tests/Utils/Strings.compare().phpt
index 72f46d474..785f9077b 100644
--- a/tests/Utils/Strings.compare().phpt
+++ b/tests/Utils/Strings.compare().phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Strings::compare()
+ * @phpExtension mbstring
*/
declare(strict_types=1);
diff --git a/tests/Utils/Strings.convertCase.phpt b/tests/Utils/Strings.convertCase.phpt
index 34347b7c5..ae4159179 100644
--- a/tests/Utils/Strings.convertCase.phpt
+++ b/tests/Utils/Strings.convertCase.phpt
@@ -2,6 +2,7 @@
/**
* Test: Nette\Utils\Strings and lower, upper, firstLower, firstUpper, capitalize
+ * @phpExtension mbstring
*/
declare(strict_types=1);