Skip to content

Commit 0757a42

Browse files
committed
tests: cs fixes, some classes moved to /fixtures.* (doesn't suit CS)
1 parent 62bbd4f commit 0757a42

27 files changed

+95
-96
lines changed

tests/Utils/Image.alpha2.phpt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@ use Tester\Assert;
1414
require __DIR__ . '/../bootstrap.php';
1515

1616

17-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
18-
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 100);
17+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
18+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 100);
1919
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.png'), $image->toString(Image::PNG, 0));
2020

2121

22-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
23-
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 99);
22+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
23+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 99);
2424
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.png'), $image->toString(Image::PNG, 0));
2525

2626

27-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
28-
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 50);
27+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
28+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 50);
2929
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.png'), $image->toString(Image::PNG, 0));
3030

3131

32-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
33-
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 1);
32+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
33+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 1);
3434
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.png'), $image->toString(Image::PNG, 0));
3535

3636

37-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
38-
$image->place(Image::fromFile(__DIR__ . '/images/alpha2.png'), 0, 0, 0);
37+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
38+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 0);
3939
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.png'), $image->toString(Image::PNG, 0));
4040

4141

42-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
43-
$image->place(Image::fromFile(__DIR__ . '/images/alpha3.gif'), 0, 0, 100);
42+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
43+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 100);
4444
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.png'), $image->toString(Image::PNG, 0));
4545

4646

47-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
48-
$image->place(Image::fromFile(__DIR__ . '/images/alpha3.gif'), 0, 0, 50);
47+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
48+
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 50);
4949
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.png'), $image->toString(Image::PNG, 0));

tests/Utils/Image.clone.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use Tester\Assert;
1414
require __DIR__ . '/../bootstrap.php';
1515

1616

17-
$original = Image::fromFile(__DIR__ . '/images/logo.gif');
17+
$original = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');
1818

1919
$dolly = clone $original;
2020
Assert::notSame($dolly->getImageResource(), $original->getImageResource());

tests/Utils/Image.drawing.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.1.png'), $imag
3232

3333

3434
// palette-based image
35-
$image = Image::fromFile(__DIR__ . '/images/logo.gif');
35+
$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');
3636
$image->filledEllipse(100, 50, 50, 50, Image::rgb(255, 255, 0, 75));
3737
$image->filledEllipse(100, 150, 50, 50, Image::rgb(255, 255, 0, 75));
3838
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.png'), $image->toString(Image::PNG, 0));

tests/Utils/Image.factories.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php';
1515

1616

1717
test(function () {
18-
$image = Image::fromFile(__DIR__ . '/images/logo.gif', $format);
18+
$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif', $format);
1919
Assert::same(176, $image->getWidth());
2020
Assert::same(104, $image->getHeight());
2121
Assert::same(Image::GIF, $format);
@@ -26,25 +26,25 @@ test(function () {
2626
if (!function_exists('imagecreatefromwebp')) {
2727
return;
2828
}
29-
$image = Image::fromFile(__DIR__ . '/images/logo.webp', $format);
29+
$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.webp', $format);
3030
Assert::same(176, $image->getWidth());
3131
Assert::same(104, $image->getHeight());
3232
Assert::same(Image::WEBP, $format);
3333
});
3434

3535

3636
Assert::exception(function () {
37-
Image::fromFile('images/missing.png');
38-
}, Nette\Utils\UnknownImageFileException::class, "File 'images/missing.png' not found.");
37+
Image::fromFile('fixtures.images/missing.png');
38+
}, Nette\Utils\UnknownImageFileException::class, "File 'fixtures.images/missing.png' not found.");
3939

4040

4141
Assert::exception(function () {
42-
Image::fromFile(__DIR__ . '/images/logo.tiff');
43-
}, Nette\Utils\UnknownImageFileException::class, "Unknown type of file '%a%images/logo.tiff'.");
42+
Image::fromFile(__DIR__ . '/fixtures.images/logo.tiff');
43+
}, Nette\Utils\UnknownImageFileException::class, "Unknown type of file '%a%fixtures.images/logo.tiff'.");
4444

4545

4646
Assert::exception(function () {
47-
Image::fromFile(__DIR__ . '/images/bad.gif');
47+
Image::fromFile(__DIR__ . '/fixtures.images/bad.gif');
4848
}, Nette\Utils\ImageException::class, '%a% not a valid GIF file');
4949

5050

tests/Utils/Image.resize.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use Tester\Assert;
1414
require __DIR__ . '/../bootstrap.php';
1515

1616

17-
$main = Image::fromFile(__DIR__ . '/images/logo.gif');
17+
$main = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');
1818

1919

2020
test(function () use ($main) { // cropping...
@@ -133,21 +133,21 @@ test(function () use ($main) { // rotate
133133

134134

135135
test(function () use ($main) { // alpha resize
136-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
136+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
137137
$image->resize(20, 20);
138138
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.png'), $image->toString(Image::PNG, 0));
139139
});
140140

141141

142142
test(function () use ($main) { // alpha flip
143-
$image = Image::fromFile(__DIR__ . '/images/alpha1.png');
143+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
144144
$image->resize(-10, -10);
145145
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.png'), $image->toString(Image::PNG, 0));
146146
});
147147

148148

149149
test(function () use ($main) { // palette alpha resize
150-
$image = Image::fromFile(__DIR__ . '/images/alpha3.gif');
150+
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif');
151151
$image->resize(20, 20);
152152
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.png'), $image->toString(Image::PNG, 0));
153153
});

tests/Utils/Image.save.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use Tester\Assert;
1414
require __DIR__ . '/../bootstrap.php';
1515

1616

17-
$main = Image::fromFile(__DIR__ . '/images/alpha1.png');
17+
$main = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
1818

1919

2020
test(function () use ($main) {

tests/Utils/Image.send.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use Tester\Assert;
1414
require __DIR__ . '/../bootstrap.php';
1515

1616

17-
$main = Image::fromFile(__DIR__ . '/images/alpha1.png');
17+
$main = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
1818

1919

2020
test(function () use ($main) {

tests/Utils/Json.decode().phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ Assert::exception(function () {
6565
// default JSON_BIGINT_AS_STRING
6666
if (defined('JSON_C_VERSION')) {
6767
if (PHP_INT_SIZE > 4) {
68-
# 64-bit
69-
Assert::same([9223372036854775807], Json::decode('[12345678901234567890]')); # trimmed to max 64-bit integer
68+
// 64-bit
69+
Assert::same([9223372036854775807], Json::decode('[12345678901234567890]')); // trimmed to max 64-bit integer
7070
} else {
71-
# 32-bit
72-
Assert::same(['9223372036854775807'], Json::decode('[12345678901234567890]')); # trimmed to max 64-bit integer
71+
// 32-bit
72+
Assert::same(['9223372036854775807'], Json::decode('[12345678901234567890]')); // trimmed to max 64-bit integer
7373
}
7474

7575
} else {

tests/Utils/Reflection.expandClassName.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use Tester\Assert;
1212
require __DIR__ . '/../bootstrap.php';
1313

1414

15-
require __DIR__ . '/files/expandClass.noNamespace.php';
16-
require __DIR__ . '/files/expandClass.inBracketedNamespace.php';
17-
require __DIR__ . '/files/expandClass.inNamespace.php';
15+
require __DIR__ . '/fixtures.reflection/expandClass.noNamespace.php';
16+
require __DIR__ . '/fixtures.reflection/expandClass.inBracketedNamespace.php';
17+
require __DIR__ . '/fixtures.reflection/expandClass.inNamespace.php';
1818

1919
$rcTest = new \ReflectionClass(Test::class);
2020
$rcBTest = new \ReflectionClass(BTest::class);

tests/Utils/Reflection.getParameterDefaultValue.phpt

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,37 @@
66

77
declare(strict_types=1);
88

9-
namespace NS {
10-
define('DEFINED', 123);
11-
define('NS_DEFINED', 'xxx');
12-
const NS_DEFINED = 456;
9+
use Nette\Utils\Reflection;
10+
use Tester\Assert;
1311

14-
interface Bar
15-
{
16-
const DEFINED = 'xyz';
17-
}
12+
require __DIR__ . '/../bootstrap.php';
13+
require __DIR__ . '/fixtures.reflection/defaultValue.php';
1814

19-
class Foo
20-
{
21-
const DEFINED = 'abc';
2215

16+
Assert::exception(function () {
17+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'a'));
18+
}, ReflectionException::class);
2319

24-
public function method(
25-
$a,
26-
$b = self::DEFINED,
27-
$c = Foo::DEFINED,
28-
$d = SELF::DEFINED,
29-
$e = bar::DEFINED,
30-
$f = self::UNDEFINED,
31-
$g = Undefined::ANY,
32-
$h = DEFINED,
33-
$i = UNDEFINED,
34-
$j = NS_DEFINED
35-
) {
36-
}
37-
}
38-
}
20+
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b')));
3921

40-
namespace {
41-
use Nette\Utils\Reflection;
42-
use Tester\Assert;
22+
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c')));
4323

44-
require __DIR__ . '/../bootstrap.php';
24+
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd')));
4525

26+
Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e')));
4627

47-
Assert::exception(function () {
48-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'a'));
49-
}, ReflectionException::class);
28+
Assert::exception(function () {
29+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f'));
30+
}, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $f in NS\Foo::method().');
5031

51-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'b')));
32+
Assert::exception(function () {
33+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g'));
34+
}, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $g in NS\Foo::method().');
5235

53-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'c')));
36+
Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h')));
5437

55-
Assert::same(NS\Foo::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'd')));
38+
Assert::exception(function () {
39+
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i'));
40+
}, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $i in NS\Foo::method().');
5641

57-
Assert::same(NS\Bar::DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'e')));
58-
59-
Assert::exception(function () {
60-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'f'));
61-
}, ReflectionException::class, 'Unable to resolve constant self::UNDEFINED used as default value of $f in NS\Foo::method().');
62-
63-
Assert::exception(function () {
64-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'g'));
65-
}, ReflectionException::class, 'Unable to resolve constant NS\Undefined::ANY used as default value of $g in NS\Foo::method().');
66-
67-
Assert::same(DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'h')));
68-
69-
Assert::exception(function () {
70-
Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'i'));
71-
}, ReflectionException::class, 'Unable to resolve constant NS\UNDEFINED used as default value of $i in NS\Foo::method().');
72-
73-
Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j')));
74-
}
42+
Assert::same(NS\NS_DEFINED, Reflection::getParameterDefaultValue(new ReflectionParameter(['NS\Foo', 'method'], 'j')));

0 commit comments

Comments
 (0)