Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posibility to change indent character of rendering HTML attribute #137

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/Utils/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Utils/ArrayHash.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
8 changes: 8 additions & 0 deletions tests/Utils/Html.children.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ test(function () { // add
<li>two</li>
</ul>
', $el->render(2), 'indentation');

Assert::match('
<ul class="hello">
<li>one</li>

<li>two</li>
</ul>
', $el->render(2, ' '), 'indentation');
});


Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.alpha1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image alpha channel.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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));

Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.alpha2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image alpha channel.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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));
Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.clone.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image cloning.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.drawing.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image drawing.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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);

Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.factories.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image factories.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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());
Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.place.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image place image.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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));
Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.resize.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image crop, resize & flip.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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');


Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.save.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image save method exceptions.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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');


Expand Down
6 changes: 1 addition & 5 deletions tests/Utils/Image.send.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Utils\Image send method exceptions.
* @phpExtension gd
*/

declare(strict_types=1);
Expand All @@ -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');


Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.arrayProperty.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object array property.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.closureProperty.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object closure properties.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.events.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object event handlers.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.extensionMethod.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object extension method.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.extensionMethodViaInterface.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object extension method via interface.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.magicMethod.errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object magic @methods errors.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.magicMethod.inheritance.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object magic @methods inheritance.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.magicMethod.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object magic @methods.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.magicMethod.types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object magic @methods and types.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.methodGetter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object closure properties.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.property.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object properties.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.referenceProperty.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object reference to property.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
1 change: 1 addition & 0 deletions tests/Utils/Object.reflection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/**
* Test: Nette\Object reflection.
* @phpVersion < 7.2
*/

declare(strict_types=1);
Expand Down
Loading