Skip to content

Commit 55df8dd

Browse files
chore: Install rector to upgrade tests
1 parent b952dcb commit 55df8dd

7 files changed

Lines changed: 309 additions & 167 deletions

File tree

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@
6868
],
6969
"fix": "php-cs-fixer fix",
7070
"test": "phpunit --stderr --coverage-html=tests/coverage"
71+
},
72+
"require-dev": {
73+
"rector/rector": "^2.1"
7174
}
7275
}

composer.lock

Lines changed: 245 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector;
7+
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
8+
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
9+
10+
return RectorConfig::configure()
11+
->withPaths([
12+
__DIR__ . '/tests/Kql',
13+
])
14+
->withRules([
15+
CoversAnnotationWithValueToAttributeRector::class,
16+
DataProviderAnnotationToAttributeRector::class,
17+
AddVoidReturnTypeWhereNoReturnRector::class
18+
])
19+
->withImportNames();

tests/Kql/HelpTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class HelpTest extends TestCase
1212
/**
1313
* @covers ::for
1414
*/
15-
public function testFor()
15+
public function testFor(): void
1616
{
1717
$result = Help::for('foo');
1818
$this->assertSame(['type' => 'string', 'value' => 'foo'], $result);
@@ -31,7 +31,7 @@ public function testFor()
3131
* @covers ::for
3232
* @covers ::forArray
3333
*/
34-
public function testForArray()
34+
public function testForArray(): void
3535
{
3636
$result = Help::for(['foo' => 'bar', 'kirby' => 'cms']);
3737
$this->assertSame(['type' => 'array', 'keys' => ['foo', 'kirby']], $result);
@@ -40,7 +40,7 @@ public function testForArray()
4040
/**
4141
* @covers ::forMethod
4242
*/
43-
public function testForMethod()
43+
public function testForMethod(): void
4444
{
4545
$object = new TestObject();
4646
$result = Help::forMethod($object, 'foo');
@@ -63,7 +63,7 @@ public function testForMethod()
6363
/**
6464
* @covers ::forMethods
6565
*/
66-
public function testForMethods()
66+
public function testForMethods(): void
6767
{
6868
$object = new TestObject();
6969
$result = Help::forMethods($object, ['more', 'foo', 'more', '404']);
@@ -95,7 +95,7 @@ public function testForMethods()
9595
* @covers ::for
9696
* @covers ::forObject
9797
*/
98-
public function testForObjectWithInterceptedObject()
98+
public function testForObjectWithInterceptedObject(): void
9999
{
100100
$object = new Page(['slug' => 'test']);
101101
$result = Help::for($object);
@@ -109,7 +109,7 @@ public function testForObjectWithInterceptedObject()
109109
* @covers ::for
110110
* @covers ::forObject
111111
*/
112-
public function testForObjectWithOriginalObject()
112+
public function testForObjectWithOriginalObject(): void
113113
{
114114
$this->app->clone([
115115
'options' => [

tests/Kql/InterceptorTest.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Kirby\Kql;
44

5+
use stdClass;
56
use Kirby\Cms\App;
67
use Kirby\Cms\Blueprint;
78
use Kirby\Cms\Content;
@@ -63,7 +64,7 @@ class InterceptorTest extends TestCase
6364
* @covers ::__call
6465
* @covers ::forbiddenMethod
6566
*/
66-
public function testCall()
67+
public function testCall(): void
6768
{
6869
$object = new TestObject();
6970
$interceptor = new TestInterceptor($object);
@@ -77,7 +78,7 @@ public function testCall()
7778
/**
7879
* @covers ::__debugInfo
7980
*/
80-
public function testDebugInfo()
81+
public function testDebugInfo(): void
8182
{
8283
$object = new TestObject();
8384
$interceptor = new TestInterceptor($object);
@@ -91,7 +92,7 @@ public function testDebugInfo()
9192
/**
9293
* @covers ::allowedMethods
9394
*/
94-
public function testAllowedMethods()
95+
public function testAllowedMethods(): void
9596
{
9697
$object = new TestObject();
9798
$interceptor = new TestInterceptor($object);
@@ -101,15 +102,15 @@ public function testAllowedMethods()
101102
/**
102103
* @covers ::class
103104
*/
104-
public function testClass()
105+
public function testClass(): void
105106
{
106107
$this->assertSame('Kirby\Kql\Interceptors\Kql\Test', Interceptor::class('Kirby\Kql\Test'));
107108
}
108109

109110
/**
110111
* @covers ::isAllowedMethod
111112
*/
112-
public function testIsAllowedMethod()
113+
public function testIsAllowedMethod(): void
113114
{
114115
$object = new TestObject();
115116
$interceptor = new TestInterceptor($object);
@@ -120,7 +121,7 @@ public function testIsAllowedMethod()
120121
/**
121122
* @covers ::isAllowedMethod
122123
*/
123-
public function testIsAllowedMethodWithBlockedConfig()
124+
public function testIsAllowedMethodWithBlockedConfig(): void
124125
{
125126
$this->app->clone([
126127
'options' => [
@@ -136,7 +137,7 @@ public function testIsAllowedMethodWithBlockedConfig()
136137
/**
137138
* @covers ::isAllowedMethod
138139
*/
139-
public function testIsAllowedMethodWithAllowedConfig()
140+
public function testIsAllowedMethodWithAllowedConfig(): void
140141
{
141142
$this->app->clone([
142143
'options' => [
@@ -153,7 +154,7 @@ public function testIsAllowedMethodWithAllowedConfig()
153154
* @covers ::isAllowedMethod
154155
* @covers ::isAllowedCallable
155156
*/
156-
public function testIsAllowedCallable()
157+
public function testIsAllowedCallable(): void
157158
{
158159
$object = new TestObject();
159160
$interceptor = new TestInterceptor($object);
@@ -166,7 +167,7 @@ public function testIsAllowedCallable()
166167
* @covers ::isAllowedCallable
167168
* @covers ::method
168169
*/
169-
public function testIsAllowedCustomMethod()
170+
public function testIsAllowedCustomMethod(): void
170171
{
171172
$object = new TestObject();
172173
$interceptor = new TestInterceptor($object);
@@ -307,7 +308,7 @@ public function objectProvider()
307308
* @covers ::replace
308309
* @dataProvider objectProvider
309310
*/
310-
public function testReplace($object, $interceptor)
311+
public function testReplace($object, $interceptor): void
311312
{
312313
$result = Interceptor::replace($object);
313314
$this->assertInstanceOf($interceptor, $result);
@@ -316,7 +317,7 @@ public function testReplace($object, $interceptor)
316317
/**
317318
* @covers ::replace
318319
*/
319-
public function testReplaceNonObject()
320+
public function testReplaceNonObject(): void
320321
{
321322
$this->expectException(InvalidArgumentException::class);
322323
$this->expectExceptionMessage('Unsupported value: string');
@@ -326,7 +327,7 @@ public function testReplaceNonObject()
326327
/**
327328
* @covers ::replace
328329
*/
329-
public function testReplaceBlockedOptions()
330+
public function testReplaceBlockedOptions(): void
330331
{
331332
$this->app->clone([
332333
'options' => [
@@ -342,7 +343,7 @@ public function testReplaceBlockedOptions()
342343
/**
343344
* @covers ::replace
344345
*/
345-
public function testReplaceObjectIsInterceptor()
346+
public function testReplaceObjectIsInterceptor(): void
346347
{
347348
$object = new TestObject();
348349
$interceptor = new TestInterceptor($object);
@@ -352,34 +353,34 @@ public function testReplaceObjectIsInterceptor()
352353
/**
353354
* @covers ::replace
354355
*/
355-
public function testReplaceAllowedOptions()
356+
public function testReplaceAllowedOptions(): void
356357
{
357358
$this->app->clone([
358359
'options' => [
359360
'kql' => ['classes' => ['allowed' => ['stdClass']]]
360361
]
361362
]);
362363

363-
$object = new \stdClass();
364+
$object = new stdClass();
364365
$this->assertSame($object, Interceptor::replace($object));
365366
}
366367

367368
/**
368369
* @covers ::replace
369370
*/
370-
public function testReplaceUnknownObject()
371+
public function testReplaceUnknownObject(): void
371372
{
372373
$this->expectException(PermissionException::class);
373374
$this->expectExceptionMessage('Access to the class "stdClass" is not supported');
374-
$object = new \stdClass();
375+
$object = new stdClass();
375376
Interceptor::replace($object);
376377
}
377378

378379
/**
379380
* @covers ::toArray
380381
* @covers ::toResponse
381382
*/
382-
public function testToArray()
383+
public function testToArray(): void
383384
{
384385
$object = new TestObject();
385386
$interceptor = new TestInterceptor($object);

tests/Kql/KqlTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class KqlTest extends TestCase
1414
/**
1515
* @covers ::fetch
1616
*/
17-
public function testFetch()
17+
public function testFetch(): void
1818
{
1919
$object = new TestObject();
2020
$result = Kql::fetch($object, 'more', true);
@@ -32,7 +32,7 @@ public function testFetch()
3232
/**
3333
* @covers ::help
3434
*/
35-
public function testHelp()
35+
public function testHelp(): void
3636
{
3737
$result = Kql::help('foo');
3838
$this->assertSame(['type' => 'string', 'value' => 'foo'], $result);
@@ -41,7 +41,7 @@ public function testHelp()
4141
/**
4242
* @covers ::query
4343
*/
44-
public function testQuery()
44+
public function testQuery(): void
4545
{
4646
$result = Kql::run([
4747
'query' => 'site.children',
@@ -60,7 +60,7 @@ public function testQuery()
6060
/**
6161
* @covers ::render
6262
*/
63-
public function testRender()
63+
public function testRender(): void
6464
{
6565
// non-object: returns value directly
6666
$result = Kql::render('foo');
@@ -75,7 +75,7 @@ public function testRender()
7575
/**
7676
* @covers ::render
7777
*/
78-
public function testRenderOriginalObject()
78+
public function testRenderOriginalObject(): void
7979
{
8080
$this->app->clone([
8181
'options' => [
@@ -99,7 +99,7 @@ public function testRenderOriginalObject()
9999
/**
100100
* @covers ::run
101101
*/
102-
public function testRun()
102+
public function testRun(): void
103103
{
104104
$result = Kql::run('site.title');
105105
$expected = 'Test Site';
@@ -115,7 +115,7 @@ public function testRun()
115115
/**
116116
* @covers ::run
117117
*/
118-
public function testRunInvalidQuery()
118+
public function testRunInvalidQuery(): void
119119
{
120120
$this->expectException(Exception::class);
121121
$this->expectExceptionMessage('The query must be a string');
@@ -125,7 +125,7 @@ public function testRunInvalidQuery()
125125
/**
126126
* @covers ::run
127127
*/
128-
public function testRunForbiddenMethod()
128+
public function testRunForbiddenMethod(): void
129129
{
130130
$this->expectException(PermissionException::class);
131131
$this->expectExceptionMessage('The method "Kirby\Cms\Page::delete()" is not allowed in the API context');
@@ -135,7 +135,7 @@ public function testRunForbiddenMethod()
135135
/**
136136
* @covers ::select
137137
*/
138-
public function testSelect()
138+
public function testSelect(): void
139139
{
140140
// no select, returns data via ::render
141141
$result = Kql::select('foo');
@@ -149,7 +149,7 @@ public function testSelect()
149149
/**
150150
* @covers ::select
151151
*/
152-
public function testSelectWithAlias()
152+
public function testSelectWithAlias(): void
153153
{
154154
$result = Kql::run([
155155
'select' => [
@@ -164,7 +164,7 @@ public function testSelectWithAlias()
164164
* @covers ::select
165165
* @covers ::selectFromArray
166166
*/
167-
public function testSelectFromArray()
167+
public function testSelectFromArray(): void
168168
{
169169
$data = [
170170
'title' => 'Test Site',
@@ -182,7 +182,7 @@ public function testSelectFromArray()
182182
* @covers ::select
183183
* @covers ::selectFromCollection
184184
*/
185-
public function testSelectFromCollection()
185+
public function testSelectFromCollection(): void
186186
{
187187
$result = Kql::run([
188188
'select' => [
@@ -202,7 +202,7 @@ public function testSelectFromCollection()
202202
* @covers ::select
203203
* @covers ::selectFromObject
204204
*/
205-
public function testSelectFromObject()
205+
public function testSelectFromObject(): void
206206
{
207207
$result = Kql::run([
208208
'select' => [
@@ -219,7 +219,7 @@ public function testSelectFromObject()
219219
/**
220220
* @covers ::select
221221
*/
222-
public function testSelectWithBoolean()
222+
public function testSelectWithBoolean(): void
223223
{
224224
$result = Kql::run([
225225
'select' => [
@@ -239,7 +239,7 @@ public function testSelectWithBoolean()
239239
* @covers ::selectFromCollection
240240
* @covers ::selectFromObject
241241
*/
242-
public function testSelectWithQuery()
242+
public function testSelectWithQuery(): void
243243
{
244244
$result = Kql::run([
245245
'select' => [
@@ -270,7 +270,7 @@ public function testSelectWithQuery()
270270
/**
271271
* @covers ::select
272272
*/
273-
public function testSelectWithString()
273+
public function testSelectWithString(): void
274274
{
275275
$result = Kql::run([
276276
'select' => [

0 commit comments

Comments
 (0)