diff --git a/tests/Utils/Image.alpha2.phpt b/tests/Utils/Image.alpha2.phpt index c041017dc..93ed353f5 100644 --- a/tests/Utils/Image.alpha2.phpt +++ b/tests/Utils/Image.alpha2.phpt @@ -14,36 +14,36 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 100); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 100); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 99); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 99); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 50); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 50); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 1); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 1); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 0); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 0); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha3.gif'), 0, 0, 100); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 100); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.png'), $image->toString(Image::PNG, 0)); -$image = Image::fromFile(__DIR__ . '/images/alpha1.png'); -$image->place(Image::fromFile(__DIR__ . '/images/alpha3.gif'), 0, 0, 50); +$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); +$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 50); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.png'), $image->toString(Image::PNG, 0)); diff --git a/tests/Utils/Image.clone.phpt b/tests/Utils/Image.clone.phpt index 7a611ee83..cd1236c3d 100644 --- a/tests/Utils/Image.clone.phpt +++ b/tests/Utils/Image.clone.phpt @@ -14,7 +14,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$original = Image::fromFile(__DIR__ . '/images/logo.gif'); +$original = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif'); $dolly = clone $original; Assert::notSame($dolly->getImageResource(), $original->getImageResource()); diff --git a/tests/Utils/Image.drawing.phpt b/tests/Utils/Image.drawing.phpt index 346bddf53..fc4df619e 100644 --- a/tests/Utils/Image.drawing.phpt +++ b/tests/Utils/Image.drawing.phpt @@ -32,7 +32,7 @@ Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.1.png'), $imag // palette-based image -$image = Image::fromFile(__DIR__ . '/images/logo.gif'); +$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif'); $image->filledEllipse(100, 50, 50, 50, Image::rgb(255, 255, 0, 75)); $image->filledEllipse(100, 150, 50, 50, Image::rgb(255, 255, 0, 75)); Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.png'), $image->toString(Image::PNG, 0)); diff --git a/tests/Utils/Image.factories.phpt b/tests/Utils/Image.factories.phpt index 26c600aa3..7cb76d0f2 100644 --- a/tests/Utils/Image.factories.phpt +++ b/tests/Utils/Image.factories.phpt @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php'; test(function () { - $image = Image::fromFile(__DIR__ . '/images/logo.gif', $format); + $image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif', $format); Assert::same(176, $image->getWidth()); Assert::same(104, $image->getHeight()); Assert::same(Image::GIF, $format); @@ -26,7 +26,7 @@ test(function () { if (!function_exists('imagecreatefromwebp')) { return; } - $image = Image::fromFile(__DIR__ . '/images/logo.webp', $format); + $image = Image::fromFile(__DIR__ . '/fixtures.images/logo.webp', $format); Assert::same(176, $image->getWidth()); Assert::same(104, $image->getHeight()); Assert::same(Image::WEBP, $format); @@ -34,17 +34,17 @@ test(function () { Assert::exception(function () { - Image::fromFile('images/missing.png'); -}, Nette\Utils\UnknownImageFileException::class, "File 'images/missing.png' not found."); + Image::fromFile('fixtures.images/missing.png'); +}, Nette\Utils\UnknownImageFileException::class, "File 'fixtures.images/missing.png' not found."); Assert::exception(function () { - Image::fromFile(__DIR__ . '/images/logo.tiff'); -}, Nette\Utils\UnknownImageFileException::class, "Unknown type of file '%a%images/logo.tiff'."); + Image::fromFile(__DIR__ . '/fixtures.images/logo.tiff'); +}, Nette\Utils\UnknownImageFileException::class, "Unknown type of file '%a%fixtures.images/logo.tiff'."); Assert::exception(function () { - Image::fromFile(__DIR__ . '/images/bad.gif'); + Image::fromFile(__DIR__ . '/fixtures.images/bad.gif'); }, Nette\Utils\ImageException::class, '%a% not a valid GIF file'); diff --git a/tests/Utils/Image.resize.phpt b/tests/Utils/Image.resize.phpt index 003d73bc5..6d11d4402 100644 --- a/tests/Utils/Image.resize.phpt +++ b/tests/Utils/Image.resize.phpt @@ -14,7 +14,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$main = Image::fromFile(__DIR__ . '/images/logo.gif'); +$main = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif'); test(function () use ($main) { // cropping... @@ -133,21 +133,21 @@ test(function () use ($main) { // rotate test(function () use ($main) { // alpha resize - $image = Image::fromFile(__DIR__ . '/images/alpha1.png'); + $image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); $image->resize(20, 20); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.png'), $image->toString(Image::PNG, 0)); }); test(function () use ($main) { // alpha flip - $image = Image::fromFile(__DIR__ . '/images/alpha1.png'); + $image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); $image->resize(-10, -10); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.png'), $image->toString(Image::PNG, 0)); }); test(function () use ($main) { // palette alpha resize - $image = Image::fromFile(__DIR__ . '/images/alpha3.gif'); + $image = Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'); $image->resize(20, 20); Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.png'), $image->toString(Image::PNG, 0)); }); diff --git a/tests/Utils/Image.save.phpt b/tests/Utils/Image.save.phpt index ecbcf4704..e6cf71027 100644 --- a/tests/Utils/Image.save.phpt +++ b/tests/Utils/Image.save.phpt @@ -14,7 +14,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$main = Image::fromFile(__DIR__ . '/images/alpha1.png'); +$main = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); test(function () use ($main) { diff --git a/tests/Utils/Image.send.phpt b/tests/Utils/Image.send.phpt index 509d8bb99..7db114c4e 100644 --- a/tests/Utils/Image.send.phpt +++ b/tests/Utils/Image.send.phpt @@ -14,7 +14,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -$main = Image::fromFile(__DIR__ . '/images/alpha1.png'); +$main = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png'); test(function () use ($main) { diff --git a/tests/Utils/Json.decode().phpt b/tests/Utils/Json.decode().phpt index 5b654311f..e5b48af6a 100644 --- a/tests/Utils/Json.decode().phpt +++ b/tests/Utils/Json.decode().phpt @@ -65,11 +65,11 @@ Assert::exception(function () { // default JSON_BIGINT_AS_STRING if (defined('JSON_C_VERSION')) { if (PHP_INT_SIZE > 4) { - # 64-bit - Assert::same([9223372036854775807], Json::decode('[12345678901234567890]')); # trimmed to max 64-bit integer + // 64-bit + Assert::same([9223372036854775807], Json::decode('[12345678901234567890]')); // trimmed to max 64-bit integer } else { - # 32-bit - Assert::same(['9223372036854775807'], Json::decode('[12345678901234567890]')); # trimmed to max 64-bit integer + // 32-bit + Assert::same(['9223372036854775807'], Json::decode('[12345678901234567890]')); // trimmed to max 64-bit integer } } else { diff --git a/tests/Utils/Reflection.expandClassName.phpt b/tests/Utils/Reflection.expandClassName.phpt index 3de371383..aeafd45b8 100644 --- a/tests/Utils/Reflection.expandClassName.phpt +++ b/tests/Utils/Reflection.expandClassName.phpt @@ -12,9 +12,9 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -require __DIR__ . '/files/expandClass.noNamespace.php'; -require __DIR__ . '/files/expandClass.inBracketedNamespace.php'; -require __DIR__ . '/files/expandClass.inNamespace.php'; +require __DIR__ . '/fixtures.reflection/expandClass.noNamespace.php'; +require __DIR__ . '/fixtures.reflection/expandClass.inBracketedNamespace.php'; +require __DIR__ . '/fixtures.reflection/expandClass.inNamespace.php'; $rcTest = new \ReflectionClass(Test::class); $rcBTest = new \ReflectionClass(BTest::class); diff --git a/tests/Utils/Reflection.getParameterDefaultValue.phpt b/tests/Utils/Reflection.getParameterDefaultValue.phpt index f18bbb07d..5afcb690e 100644 --- a/tests/Utils/Reflection.getParameterDefaultValue.phpt +++ b/tests/Utils/Reflection.getParameterDefaultValue.phpt @@ -6,69 +6,37 @@ declare(strict_types=1); -namespace NS { - define('DEFINED', 123); - define('NS_DEFINED', 'xxx'); - const NS_DEFINED = 456; +use Nette\Utils\Reflection; +use Tester\Assert; - interface Bar - { - const DEFINED = 'xyz'; - } +require __DIR__ . '/../bootstrap.php'; +require __DIR__ . '/fixtures.reflection/defaultValue.php'; - class Foo - { - const DEFINED = 'abc'; +Assert::exception(function () { + Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'a')); +}, ReflectionException::class); - public function method( - $a, - $b = self::DEFINED, - $c = Foo::DEFINED, - $d = SELF::DEFINED, - $e = bar::DEFINED, - $f = self::UNDEFINED, - $g = Undefined::ANY, - $h = DEFINED, - $i = UNDEFINED, - $j = NS_DEFINED - ) { - } - } -} +Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b'))); -namespace { - use Nette\Utils\Reflection; - use Tester\Assert; +Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c'))); - require __DIR__ . '/../bootstrap.php'; +Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd'))); +Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e'))); - Assert::exception(function () { - Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'a')); - }, ReflectionException::class); +Assert::exception(function () { + Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f')); +}, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $f in NS\Foo::method().'); - Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b'))); +Assert::exception(function () { + Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g')); +}, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $g in NS\Foo::method().'); - Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c'))); +Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h'))); - Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd'))); +Assert::exception(function () { + Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i')); +}, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $i in NS\Foo::method().'); - Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e'))); - - Assert::exception(function () { - Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f')); - }, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $f in NS\Foo::method().'); - - Assert::exception(function () { - Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g')); - }, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $g in NS\Foo::method().'); - - Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h'))); - - Assert::exception(function () { - Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i')); - }, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $i in NS\Foo::method().'); - - Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j'))); -} +Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j'))); diff --git a/tests/Utils/Reflection.getParameterType.php71.phpt b/tests/Utils/Reflection.getParameterType.php71.phpt index 941ffc083..f29521fa4 100644 --- a/tests/Utils/Reflection.getParameterType.php71.phpt +++ b/tests/Utils/Reflection.getParameterType.php71.phpt @@ -8,14 +8,13 @@ declare(strict_types=1); use Nette\Utils\Reflection; +use Test\B; // for testing purposes use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -use Test\B; // for testing purposes - class A { public function method(Undeclared $undeclared, B $b, array $array, callable $callable, $none, ?B $nullable) diff --git a/tests/Utils/Reflection.getParameterType.phpt b/tests/Utils/Reflection.getParameterType.phpt index 484e7f468..362b34343 100644 --- a/tests/Utils/Reflection.getParameterType.phpt +++ b/tests/Utils/Reflection.getParameterType.phpt @@ -7,14 +7,13 @@ declare(strict_types=1); use Nette\Utils\Reflection; +use Test\B; // for testing purposes use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -use Test\B; // for testing purposes - class A { public function method(Undeclared $undeclared, B $b, array $array, callable $callable, self $self, $none) diff --git a/tests/Utils/Reflection.groupUseStatements.phpt b/tests/Utils/Reflection.groupUseStatements.phpt index 5d616c6ad..7332b69bd 100644 --- a/tests/Utils/Reflection.groupUseStatements.phpt +++ b/tests/Utils/Reflection.groupUseStatements.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -require __DIR__ . '/files/expandClass.groupUse.php'; +require __DIR__ . '/fixtures.reflection/expandClass.groupUse.php'; Assert::same( ['A' => 'A\B\A', 'C' => 'A\B\B\C', 'D' => 'A\B\C', 'E' => 'D\E'], diff --git a/tests/Utils/Reflection.nonClassUseStatements.phpt b/tests/Utils/Reflection.nonClassUseStatements.phpt index 7a3fe2164..c6ce04430 100644 --- a/tests/Utils/Reflection.nonClassUseStatements.phpt +++ b/tests/Utils/Reflection.nonClassUseStatements.phpt @@ -12,7 +12,7 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -require __DIR__ . '/files/expandClass.nonClassUse.php'; +require __DIR__ . '/fixtures.reflection/expandClass.nonClassUse.php'; Assert::same( [], diff --git a/tests/Utils/images/alpha1.png b/tests/Utils/fixtures.images/alpha1.png similarity index 100% rename from tests/Utils/images/alpha1.png rename to tests/Utils/fixtures.images/alpha1.png diff --git a/tests/Utils/images/alpha2.png b/tests/Utils/fixtures.images/alpha2.png similarity index 100% rename from tests/Utils/images/alpha2.png rename to tests/Utils/fixtures.images/alpha2.png diff --git a/tests/Utils/images/alpha3.gif b/tests/Utils/fixtures.images/alpha3.gif similarity index 100% rename from tests/Utils/images/alpha3.gif rename to tests/Utils/fixtures.images/alpha3.gif diff --git a/tests/Utils/images/bad.gif b/tests/Utils/fixtures.images/bad.gif similarity index 100% rename from tests/Utils/images/bad.gif rename to tests/Utils/fixtures.images/bad.gif diff --git a/tests/Utils/images/logo.gif b/tests/Utils/fixtures.images/logo.gif similarity index 100% rename from tests/Utils/images/logo.gif rename to tests/Utils/fixtures.images/logo.gif diff --git a/tests/Utils/images/logo.tiff b/tests/Utils/fixtures.images/logo.tiff similarity index 100% rename from tests/Utils/images/logo.tiff rename to tests/Utils/fixtures.images/logo.tiff diff --git a/tests/Utils/images/logo.webp b/tests/Utils/fixtures.images/logo.webp similarity index 100% rename from tests/Utils/images/logo.webp rename to tests/Utils/fixtures.images/logo.webp diff --git a/tests/Utils/fixtures.reflection/defaultValue.php b/tests/Utils/fixtures.reflection/defaultValue.php new file mode 100644 index 000000000..61d6d2053 --- /dev/null +++ b/tests/Utils/fixtures.reflection/defaultValue.php @@ -0,0 +1,33 @@ +