Skip to content

Commit 6268076

Browse files
committed
renamed some tests
1 parent b8375ac commit 6268076

14 files changed

+100
-92
lines changed

tests/PhpGenerator/Extractor.extractAll.phpt

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

1111
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/classes.php')))->extractAll();
1212
Assert::type(Nette\PhpGenerator\PhpFile::class, $file);
13-
sameFile(__DIR__ . '/expected/Factory.fromCode.expect', (string) $file);
13+
sameFile(__DIR__ . '/expected/Extractor.classes.expect', (string) $file);
1414

1515
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/classes.74.php')))->extractAll();
16-
sameFile(__DIR__ . '/expected/Factory.fromCode.74.expect', (string) $file);
16+
sameFile(__DIR__ . '/expected/Extractor.classes.74.expect', (string) $file);
1717

1818
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/classes.80.php')))->extractAll();
19-
sameFile(__DIR__ . '/expected/Factory.fromCode.80.expect', (string) $file);
19+
sameFile(__DIR__ . '/expected/Extractor.classes.80.expect', (string) $file);
2020

2121
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/classes.81.php')))->extractAll();
22-
sameFile(__DIR__ . '/expected/Factory.fromCode.81.expect', (string) $file);
22+
sameFile(__DIR__ . '/expected/Extractor.classes.81.expect', (string) $file);
2323

2424
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/enum.php')))->extractAll();
25-
sameFile(__DIR__ . '/expected/Factory.fromCode.enum.expect', (string) $file);
25+
sameFile(__DIR__ . '/expected/Extractor.enum.expect', (string) $file);
2626

2727
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/traits.php')))->extractAll();
28-
sameFile(__DIR__ . '/expected/Factory.fromCode.traits.expect', (string) $file);
28+
sameFile(__DIR__ . '/expected/Extractor.traits.expect', (string) $file);
2929

3030
$file = (new Extractor(file_get_contents(__DIR__ . '/fixtures/bodies.php')))->extractAll();
31-
sameFile(__DIR__ . '/expected/Factory.fromCode.bodies.expect', (string) $file);
31+
sameFile(__DIR__ . '/expected/Extractor.bodies.expect', (string) $file);
3232

3333
$file = (new Extractor(
3434
<<<'XX'

tests/PhpGenerator/Extractor.extractAll.resolving.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $namespace->addUse('Abc\a\func'); // must not be confused with func
1818
$namespace->add(reset($classes));
1919

2020
$printer = new Printer;
21-
sameFile(__DIR__ . '/expected/Factory.fromCode.bodies.resolving.expect', $printer->printNamespace($namespace));
21+
sameFile(__DIR__ . '/expected/Extractor.bodies.resolving.expect', $printer->printNamespace($namespace));
2222

2323
$printer->setTypeResolving(false);
24-
sameFile(__DIR__ . '/expected/Factory.fromCode.bodies.unresolving.expect', $printer->printNamespace($namespace));
24+
sameFile(__DIR__ . '/expected/Extractor.bodies.unresolving.expect', $printer->printNamespace($namespace));

tests/PhpGenerator/PhpFile.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,4 @@ sameFile(__DIR__ . '/expected/PhpFile.strictTypes.expect', (string) $file);
133133

134134
$file = PhpFile::fromCode(file_get_contents(__DIR__ . '/fixtures/classes.php'));
135135
Assert::type(PhpFile::class, $file);
136-
sameFile(__DIR__ . '/expected/Factory.fromCode.expect', (string) $file);
136+
sameFile(__DIR__ . '/expected/Extractor.classes.expect', (string) $file);

tests/PhpGenerator/PhpNamespace.aliases.phpt

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,6 @@ use Tester\Assert;
88
require __DIR__ . '/../bootstrap.php';
99

1010

11-
// global namespace
12-
$namespace = new PhpNamespace('');
13-
14-
Assert::same('', $namespace->getName());
15-
Assert::same('A', $namespace->simplifyName('A'));
16-
Assert::same('foo\A', $namespace->simplifyName('foo\A'));
17-
18-
$namespace->addUse('Bar\C');
19-
20-
Assert::same('Bar', $namespace->simplifyName('Bar'));
21-
Assert::same('C', $namespace->simplifyName('bar\C'));
22-
Assert::same('C\D', $namespace->simplifyName('Bar\C\D'));
23-
24-
foreach (['String', 'string', 'int', 'float', 'bool', 'array', 'callable', 'self', 'parent', ''] as $type) {
25-
Assert::same($type, $namespace->simplifyName($type));
26-
}
27-
28-
$namespace->addUseFunction('Foo\a');
29-
30-
Assert::same('bar\c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
31-
Assert::same('a', $namespace->simplifyName('foo\A', $namespace::NAME_FUNCTION));
32-
Assert::same('foo\a\b', $namespace->simplifyName('foo\a\b', $namespace::NAME_FUNCTION));
33-
34-
foreach (['String', 'string', 'int', 'float', 'bool', 'array', 'callable', 'self', 'parent', ''] as $type) {
35-
Assert::same($type, $namespace->simplifyName($type, $namespace::NAME_FUNCTION));
36-
}
37-
38-
$namespace->addUseFunction('Bar\c');
39-
40-
Assert::same('Bar', $namespace->simplifyName('Bar', $namespace::NAME_FUNCTION));
41-
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
42-
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_FUNCTION));
43-
44-
$namespace->addUseConstant('Bar\c');
45-
46-
Assert::same('Bar', $namespace->simplifyName('Bar', $namespace::NAME_CONSTANT));
47-
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_CONSTANT));
48-
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_CONSTANT));
49-
50-
51-
52-
// namespace
53-
$namespace = new PhpNamespace('Foo');
54-
55-
Assert::same('Foo', $namespace->getName());
56-
Assert::same('\A', $namespace->simplifyName('\A'));
57-
Assert::same('\A', $namespace->simplifyName('A'));
58-
Assert::same('A', $namespace->simplifyName('foo\A'));
59-
60-
Assert::same('A', $namespace->simplifyType('foo\A'));
61-
Assert::same('null|A', $namespace->simplifyType('null|foo\A'));
62-
Assert::same('?A', $namespace->simplifyType('?foo\A'));
63-
Assert::same('A&\Countable', $namespace->simplifyType('foo\A&Countable'));
64-
Assert::same('', $namespace->simplifyType(''));
65-
66-
$namespace->addUse('Foo');
67-
Assert::same('B', $namespace->simplifyName('Foo\B'));
68-
69-
$namespace->addUse('Bar\C');
70-
Assert::same('Foo\C', $namespace->simplifyName('Foo\C'));
71-
72-
Assert::same('\Bar', $namespace->simplifyName('Bar'));
73-
Assert::same('C', $namespace->simplifyName('\bar\C'));
74-
Assert::same('C', $namespace->simplifyName('bar\C'));
75-
Assert::same('C\D', $namespace->simplifyName('Bar\C\D'));
76-
Assert::same('A<C, C\D>', $namespace->simplifyType('foo\A<\bar\C, Bar\C\D>'));
77-
Assert::same('žluťoučký', $namespace->simplifyType('foo\žluťoučký'));
78-
79-
$namespace->addUseFunction('Foo\a');
80-
81-
Assert::same('\bar\c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
82-
Assert::same('a', $namespace->simplifyName('foo\A', $namespace::NAME_FUNCTION));
83-
Assert::same('Foo\C\b', $namespace->simplifyName('foo\C\b', $namespace::NAME_FUNCTION));
84-
Assert::same('a\b', $namespace->simplifyName('foo\a\b', $namespace::NAME_FUNCTION));
85-
86-
$namespace->addUseFunction('Bar\c');
87-
88-
Assert::same('\Bar', $namespace->simplifyName('Bar', $namespace::NAME_FUNCTION));
89-
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
90-
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_FUNCTION));
91-
92-
9311
// duplicity
9412
$namespace = new PhpNamespace('Foo');
9513
$namespace->addUse('Bar\C');
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Nette\PhpGenerator\PhpNamespace;
6+
use Tester\Assert;
7+
8+
require __DIR__ . '/../bootstrap.php';
9+
10+
11+
// global namespace
12+
$namespace = new PhpNamespace('');
13+
14+
Assert::same('', $namespace->getName());
15+
Assert::same('A', $namespace->simplifyName('A'));
16+
Assert::same('foo\A', $namespace->simplifyName('foo\A'));
17+
18+
$namespace->addUse('Bar\C');
19+
20+
Assert::same('Bar', $namespace->simplifyName('Bar'));
21+
Assert::same('C', $namespace->simplifyName('bar\C'));
22+
Assert::same('C\D', $namespace->simplifyName('Bar\C\D'));
23+
24+
$namespace->addUseFunction('Foo\a');
25+
26+
Assert::same('bar\c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
27+
Assert::same('a', $namespace->simplifyName('foo\A', $namespace::NAME_FUNCTION));
28+
Assert::same('foo\a\b', $namespace->simplifyName('foo\a\b', $namespace::NAME_FUNCTION));
29+
30+
$namespace->addUseFunction('Bar\c');
31+
32+
Assert::same('Bar', $namespace->simplifyName('Bar', $namespace::NAME_FUNCTION));
33+
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
34+
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_FUNCTION));
35+
36+
$namespace->addUseConstant('Bar\c');
37+
38+
Assert::same('Bar', $namespace->simplifyName('Bar', $namespace::NAME_CONSTANT));
39+
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_CONSTANT));
40+
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_CONSTANT));
41+
42+
43+
44+
// namespace
45+
$namespace = new PhpNamespace('Foo');
46+
47+
foreach (['String', 'string', 'int', 'float', 'bool', 'array', 'callable', 'self', 'parent', ''] as $type) {
48+
Assert::same($type, $namespace->simplifyName($type));
49+
}
50+
51+
Assert::same('Foo', $namespace->getName());
52+
Assert::same('\A', $namespace->simplifyName('\A'));
53+
Assert::same('\A', $namespace->simplifyName('A'));
54+
Assert::same('A', $namespace->simplifyName('foo\A'));
55+
56+
Assert::same('A', $namespace->simplifyType('foo\A'));
57+
Assert::same('null|A', $namespace->simplifyType('null|foo\A'));
58+
Assert::same('?A', $namespace->simplifyType('?foo\A'));
59+
Assert::same('A&\Countable', $namespace->simplifyType('foo\A&Countable'));
60+
Assert::same('', $namespace->simplifyType(''));
61+
62+
$namespace->addUse('Foo');
63+
Assert::same('B', $namespace->simplifyName('Foo\B'));
64+
65+
$namespace->addUse('Bar\C');
66+
Assert::same('Foo\C', $namespace->simplifyName('Foo\C'));
67+
68+
Assert::same('\Bar', $namespace->simplifyName('Bar'));
69+
Assert::same('C', $namespace->simplifyName('\bar\C'));
70+
Assert::same('C', $namespace->simplifyName('bar\C'));
71+
Assert::same('C\D', $namespace->simplifyName('Bar\C\D'));
72+
Assert::same('A<C, C\D>', $namespace->simplifyType('foo\A<\bar\C, Bar\C\D>'));
73+
Assert::same('žluťoučký', $namespace->simplifyType('foo\žluťoučký'));
74+
75+
$namespace->addUseFunction('Foo\a');
76+
77+
foreach (['String', 'string', 'int', 'float', 'bool', 'array', 'callable', 'self', 'parent', ''] as $type) {
78+
Assert::same($type, $namespace->simplifyName($type, $namespace::NAME_FUNCTION));
79+
}
80+
81+
Assert::same('\bar\c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
82+
Assert::same('a', $namespace->simplifyName('foo\A', $namespace::NAME_FUNCTION));
83+
Assert::same('Foo\C\b', $namespace->simplifyName('foo\C\b', $namespace::NAME_FUNCTION));
84+
Assert::same('a\b', $namespace->simplifyName('foo\a\b', $namespace::NAME_FUNCTION));
85+
86+
$namespace->addUseFunction('Bar\c');
87+
88+
Assert::same('\Bar', $namespace->simplifyName('Bar', $namespace::NAME_FUNCTION));
89+
Assert::same('c', $namespace->simplifyName('bar\c', $namespace::NAME_FUNCTION));
90+
Assert::same('C\d', $namespace->simplifyName('Bar\C\d', $namespace::NAME_FUNCTION));

tests/PhpGenerator/expected/Factory.fromCode.bodies.expect renamed to tests/PhpGenerator/expected/Extractor.bodies.expect

File renamed without changes.

tests/PhpGenerator/expected/Factory.fromCode.bodies.resolving.expect renamed to tests/PhpGenerator/expected/Extractor.bodies.resolving.expect

File renamed without changes.

tests/PhpGenerator/expected/Factory.fromCode.bodies.unresolving.expect renamed to tests/PhpGenerator/expected/Extractor.bodies.unresolving.expect

File renamed without changes.

tests/PhpGenerator/expected/Factory.fromCode.74.expect renamed to tests/PhpGenerator/expected/Extractor.classes.74.expect

File renamed without changes.

tests/PhpGenerator/expected/Factory.fromCode.80.expect renamed to tests/PhpGenerator/expected/Extractor.classes.80.expect

File renamed without changes.

0 commit comments

Comments
 (0)