Skip to content

Commit cee6954

Browse files
committed
tests: improved descriptions
1 parent 257053d commit cee6954

28 files changed

+120
-121
lines changed

tests/Application/Application.run.phpt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ $httpResponse = Mockery::mock(Nette\Http\IResponse::class);
9696
$httpResponse->shouldIgnoreMissing();
9797

9898

99-
// no route without error presenter
100-
Assert::exception(function () use ($httpRequest, $httpResponse) {
99+
testException('no route handling without error presenter', function () use ($httpRequest, $httpResponse) {
101100
$presenterFactory = Mockery::mock(IPresenterFactory::class);
102101
$router = Mockery::mock(Router::class);
103102
$router->shouldReceive('match')->andReturn(null);
@@ -107,7 +106,7 @@ Assert::exception(function () use ($httpRequest, $httpResponse) {
107106
}, BadRequestException::class, 'No route for HTTP request.');
108107

109108

110-
test('no route with error presenter', function () use ($httpRequest, $httpResponse) {
109+
test('error presenter handling for route mismatch', function () use ($httpRequest, $httpResponse) {
111110
$errorPresenter = new ErrorPresenter;
112111

113112
$presenterFactory = Mockery::mock(IPresenterFactory::class);
@@ -133,7 +132,7 @@ test('no route with error presenter', function () use ($httpRequest, $httpRespon
133132
});
134133

135134

136-
test('route to error presenter', function () use ($httpRequest, $httpResponse) {
135+
test('error presenter invoked directly via router', function () use ($httpRequest, $httpResponse) {
137136
$errorPresenter = new ErrorPresenter;
138137

139138
$presenterFactory = Mockery::mock(IPresenterFactory::class);
@@ -161,8 +160,7 @@ test('route to error presenter', function () use ($httpRequest, $httpResponse) {
161160
});
162161

163162

164-
// missing presenter without error presenter
165-
Assert::exception(function () use ($httpRequest, $httpResponse) {
163+
testException('missing presenter exception without error presenter', function () use ($httpRequest, $httpResponse) {
166164
$presenterFactory = Mockery::mock(IPresenterFactory::class);
167165
$presenterFactory->shouldReceive('createPresenter')->with('Missing')->andThrow(Nette\Application\InvalidPresenterException::class);
168166

@@ -174,7 +172,7 @@ Assert::exception(function () use ($httpRequest, $httpResponse) {
174172
}, BadRequestException::class);
175173

176174

177-
test('missing presenter with error presenter', function () use ($httpRequest, $httpResponse) {
175+
test('missing presenter fallback to error presenter', function () use ($httpRequest, $httpResponse) {
178176
$errorPresenter = new ErrorPresenter;
179177

180178
$presenterFactory = Mockery::mock(IPresenterFactory::class);
@@ -203,8 +201,7 @@ test('missing presenter with error presenter', function () use ($httpRequest, $h
203201
});
204202

205203

206-
// presenter error without error presenter
207-
Assert::exception(function () use ($httpRequest, $httpResponse) {
204+
testException('presenter exception propagation without error handling', function () use ($httpRequest, $httpResponse) {
208205
$presenterFactory = Mockery::mock(IPresenterFactory::class);
209206
$presenterFactory->shouldReceive('createPresenter')->with('Bad')->andReturn(new BadPresenter);
210207

@@ -216,7 +213,7 @@ Assert::exception(function () use ($httpRequest, $httpResponse) {
216213
}, BadException::class);
217214

218215

219-
test('presenter error with error presenter', function () use ($httpRequest, $httpResponse) {
216+
test('presenter exception propagation to error presenter', function () use ($httpRequest, $httpResponse) {
220217
$badPresenter = new BadPresenter;
221218
$errorPresenter = new ErrorPresenter;
222219

tests/Application/MicroPresenter.invoke.phpt

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

1515

16-
test('', function () {
16+
test('callback invocation with parameters', function () {
1717
$presenter = $p = new NetteModule\MicroPresenter;
1818

1919
$presenter->run(new Request('Nette:Micro', 'GET', [
@@ -30,7 +30,7 @@ test('', function () {
3030
});
3131

3232

33-
test('', function () {
33+
test('dependency injection in callback', function () {
3434
$container = Mockery::mock(Nette\DI\Container::class)
3535
->shouldReceive('getByType')->with('stdClass', false)->once()->andReturn(new stdClass)
3636
->mock();

tests/Application/MicroPresenter.response.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function createContainer()
3737
}
3838

3939

40-
test('', function () {
40+
test('textResponse with direct output', function () {
4141
$presenter = new NetteModule\MicroPresenter(createContainer());
4242
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
4343
'callback' => fn() => 'test',
@@ -48,7 +48,7 @@ test('', function () {
4848
});
4949

5050

51-
test('', function () {
51+
test('parameter passing to callback', function () {
5252
$presenter = new NetteModule\MicroPresenter(createContainer());
5353
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
5454
'callback' => fn($param) => $param,
@@ -60,7 +60,7 @@ test('', function () {
6060
});
6161

6262

63-
test('', function () {
63+
test('latte template evaluation', function () {
6464
$presenter = new NetteModule\MicroPresenter(createContainer());
6565
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
6666
'callback' => fn() => '{=date(Y)}',
@@ -71,7 +71,7 @@ test('', function () {
7171
});
7272

7373

74-
test('', function () {
74+
test('template file with parameters', function () {
7575
$presenter = new NetteModule\MicroPresenter(createContainer());
7676
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
7777
'callback' => fn() => [new SplFileInfo(Tester\FileMock::create('{$param}')), []],
@@ -83,7 +83,7 @@ test('', function () {
8383
});
8484

8585

86-
test('', function () {
86+
test('manual template creation', function () {
8787
$presenter = new NetteModule\MicroPresenter;
8888

8989
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
@@ -101,7 +101,7 @@ test('', function () {
101101
});
102102

103103

104-
test('', function () {
104+
test('template file loader with parameters', function () {
105105
$presenter = new NetteModule\MicroPresenter;
106106

107107
$response = $presenter->run(new Request('Nette:Micro', 'GET', [
@@ -120,7 +120,7 @@ test('', function () {
120120
});
121121

122122

123-
test('', function () {
123+
test('missing template file handling', function () {
124124
$filename = 'notfound.latte';
125125
Assert::exception(function () use ($filename) {
126126
$presenter = new NetteModule\MicroPresenter;

tests/Application/PresenterFactory.formatPresenterClass.phpt

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

1515

16-
test('defined module', function () {
16+
test('complex mapping with multiple wildcards', function () {
1717
$factory = new PresenterFactory;
1818

1919
$factory->setMapping([
@@ -36,7 +36,7 @@ test('defined module', function () {
3636
});
3737

3838

39-
test('auto module', function () {
39+
test('simple wildcard mapping', function () {
4040
$factory = new PresenterFactory;
4141

4242
$factory->setMapping([
@@ -53,7 +53,7 @@ test('auto module', function () {
5353
});
5454

5555

56-
test('location ** & defined module', function () {
56+
test('multi-segment wildcard expansion', function () {
5757
$factory = new PresenterFactory;
5858

5959
$factory->setMapping([
@@ -76,7 +76,7 @@ test('location ** & defined module', function () {
7676
});
7777

7878

79-
test('location ** & auto module', function () {
79+
test('global wildcard mapping strategy', function () {
8080
$factory = new PresenterFactory;
8181

8282
$factory->setMapping([
@@ -94,7 +94,7 @@ test('location ** & auto module', function () {
9494
});
9595

9696

97-
test('', function () {
97+
test('array-based hierarchical mapping', function () {
9898
$factory = new PresenterFactory;
9999
$factory->setMapping([
100100
'*' => ['App', 'Module\*', 'Presenter\*'],
@@ -104,7 +104,7 @@ test('', function () {
104104
});
105105

106106

107-
test('', function () {
107+
test('empty namespace mapping structure', function () {
108108
$factory = new PresenterFactory;
109109
$factory->setMapping([
110110
'*' => ['', '*', '*'],
@@ -113,7 +113,8 @@ test('', function () {
113113
});
114114

115115

116-
Assert::exception(
116+
testException(
117+
'invalid mapping mask validation',
117118
function () {
118119
$factory = new PresenterFactory;
119120
$factory->setMapping([

tests/Application/Request.phpt

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

1515

16-
test('', function () {
16+
test('request parameters with null values', function () {
1717
$request = new Request('Homepage', 'GET', ['a' => 1, 'b' => null]);
1818

1919
Assert::same(1, $request->getParameter('a'));
2020
Assert::same(null, $request->getParameter('b'));
2121
});
2222

2323

24-
test('', function () {
24+
test('POST parameters retrieval', function () {
2525
$request = new Request('Homepage', 'GET', [], ['a' => 1, 'b' => null]);
2626

2727
Assert::same(['a' => 1, 'b' => null], $request->getPost());

tests/Bridges.DI/ApplicationExtension.invalidLink.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function createCompiler(string $config): DI\Compiler
2424
}
2525

2626

27-
test('', function () {
27+
test('silentLinks enabled with debugger', function () {
2828
$compiler = createCompiler('
2929
application:
3030
silentLinks: yes
@@ -44,7 +44,7 @@ test('', function () {
4444
});
4545

4646

47-
test('', function () {
47+
test('silentLinks disabled with debugger', function () {
4848
$compiler = createCompiler('
4949
application:
5050
silentLinks: no
@@ -64,7 +64,7 @@ test('', function () {
6464
});
6565

6666

67-
test('', function () {
67+
test('silentLinks enabled without debugger', function () {
6868
$compiler = createCompiler('
6969
application:
7070
silentLinks: yes
@@ -84,7 +84,7 @@ test('', function () {
8484
});
8585

8686

87-
test('', function () {
87+
test('silentLinks disabled without debugger', function () {
8888
$compiler = createCompiler('
8989
application:
9090
silentLinks: no

tests/Bridges.DI/ApplicationExtension.scan.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require __DIR__ . '/../bootstrap.php';
1212
require __DIR__ . '/files/MyPresenter.php';
1313

1414

15-
test('', function () {
15+
test('default presenter registration', function () {
1616
$compiler = new DI\Compiler;
1717
$compiler->addExtension('application', new ApplicationExtension);
1818

@@ -30,7 +30,7 @@ test('', function () {
3030
});
3131

3232

33-
test('', function () {
33+
test('scanDirs with filter', function () {
3434
$compiler = new DI\Compiler;
3535
$compiler->addExtension('application', new ApplicationExtension);
3636

@@ -53,7 +53,7 @@ test('', function () {
5353
});
5454

5555

56-
test('', function () {
56+
test('combined scanDirs and config setup', function () {
5757
$compiler = new DI\Compiler;
5858
$compiler->addExtension('application', new ApplicationExtension(false, [__DIR__ . '/files']));
5959

@@ -85,7 +85,7 @@ test('', function () {
8585
});
8686

8787

88-
test('', function () {
88+
test('robotLoader discovery', function () {
8989
$robot = new Nette\Loaders\RobotLoader;
9090
$robot->addDirectory(__DIR__ . '/files');
9191
$robot->setTempDirectory(getTempDir());

tests/Bridges.DI/RoutingExtension.cache.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MyRouter implements Nette\Routing\Router
3737
}
3838

3939

40-
test('', function () {
40+
test('router without cache', function () {
4141
$loader = new DI\Config\Loader;
4242
$config = $loader->load(Tester\FileMock::create('
4343
services:
@@ -55,7 +55,7 @@ test('', function () {
5555
});
5656

5757

58-
test('', function () {
58+
test('router with cache', function () {
5959
$loader = new DI\Config\Loader;
6060
$config = $loader->load(Tester\FileMock::create('
6161
routing:
@@ -82,7 +82,7 @@ function myRouterFactory(): Nette\Routing\Router
8282
}
8383

8484

85-
Assert::exception(function () {
85+
testException('non-cacheable router factory', function () {
8686
$loader = new DI\Config\Loader;
8787
$config = $loader->load(Tester\FileMock::create('
8888
routing:

tests/Bridges.Latte3/TemplateFactory.customTemplate.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,22 @@ class TemplateMock extends Template
4646
}
4747

4848

49-
test('', function () {
49+
test('default template creation', function () {
5050
$latteFactory = Mockery::mock(LatteFactory::class);
5151
$latteFactory->shouldReceive('create')->andReturn(new Latte\Engine);
5252
$factory = new TemplateFactory($latteFactory);
5353
Assert::type(Template::class, $factory->createTemplate());
5454
});
5555

56-
Assert::exception(
56+
testException(
57+
'13456',
5758
fn() => new TemplateFactory(Mockery::mock(LatteFactory::class), templateClass: stdClass::class),
5859
Nette\InvalidArgumentException::class,
5960
'Class stdClass does not implement Nette\Bridges\ApplicationLatte\Template or it does not exist.',
6061
);
6162

6263

63-
test('', function () {
64+
test('custom template behavior', function () {
6465
$latteFactory = Mockery::mock(LatteFactory::class);
6566
$latteFactory->shouldReceive('create')->andReturn(new Latte\Engine);
6667
$factory = new TemplateFactory($latteFactory, templateClass: TemplateMock::class);

tests/Responses/CallbackResponse.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-
test('', function () {
17+
test('callback execution on send', function () {
1818
$response = new CallbackResponse(function (Http\IRequest $request, Http\IResponse $response) use (&$ok) {
1919
$ok = true;
2020
});

0 commit comments

Comments
 (0)