Skip to content

Commit 2d8782f

Browse files
felixuref3l1x
authored andcommitted
Tests: Fix code style issues
- Fix class brace spacing in BuilderMan tests - Remove unused variable in MappingHelper test - Use sprintf instead of variable interpolation in console test - Use single quotes for regex patterns in error tests - Fix reference passing in ContainerEventManager test - Add phpcs:ignoreFile to Binder test
1 parent 2f48f2f commit 2d8782f

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

tests/Cases/DI/Helper/BuilderMan.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Toolkit::test(function (): void {
2727
public function beforeCompile(): void
2828
{
2929
$pass = new class ($this) extends AbstractPass {
30+
3031
};
3132

3233
$builderMan = BuilderMan::of($pass);
@@ -77,6 +78,7 @@ Toolkit::test(function (): void {
7778
public function beforeCompile(): void
7879
{
7980
$pass = new class ($this) extends AbstractPass {
81+
8082
};
8183

8284
$builderMan = BuilderMan::of($pass);
@@ -125,6 +127,7 @@ Toolkit::test(function (): void {
125127
public function beforeCompile(): void
126128
{
127129
$pass = new class ($this) extends AbstractPass {
130+
128131
};
129132

130133
$builderMan = BuilderMan::of($pass);
@@ -181,6 +184,7 @@ Toolkit::test(function (): void {
181184
public function beforeCompile(): void
182185
{
183186
$pass = new class ($this) extends AbstractPass {
187+
184188
};
185189

186190
$builderMan = BuilderMan::of($pass);
@@ -244,6 +248,7 @@ Toolkit::test(function (): void {
244248
public function beforeCompile(): void
245249
{
246250
$pass = new class ($this) extends AbstractPass {
251+
247252
};
248253

249254
$builderMan = BuilderMan::of($pass);
@@ -297,6 +302,7 @@ Toolkit::test(function (): void {
297302
public function beforeCompile(): void
298303
{
299304
$pass = new class ($this) extends AbstractPass {
305+
300306
};
301307

302308
$builderMan = BuilderMan::of($pass);

tests/Cases/DI/Helper/MappingHelper.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Toolkit::test(function (): void {
149149

150150
// Fluent interface - chaining
151151
Toolkit::test(function (): void {
152-
$container = ContainerBuilder::of()
152+
ContainerBuilder::of()
153153
->withCompiler(function (Compiler $compiler): void {
154154
$compiler->addExtension('nettrine.dbal', new DbalExtension());
155155
$compiler->addExtension('nettrine.orm', new OrmExtension());

tests/Cases/DI/OrmExtension.console.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Toolkit::test(function (): void {
125125
$taggedServices = $container->findByTag('console.command');
126126

127127
foreach ($expectedCommands as $commandName) {
128-
Assert::true(in_array($commandName, $taggedServices, true), "Command '$commandName' should be tagged");
128+
Assert::true(in_array($commandName, $taggedServices, true), sprintf('Command %s should be tagged', $commandName));
129129
}
130130
});
131131

tests/Cases/DI/OrmExtension.errors.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Toolkit::test(function (): void {
4848
));
4949
})
5050
->build();
51-
}, InvalidConfigurationException::class, "~EntityManager decorator class must be subclass~");
51+
}, InvalidConfigurationException::class, '~EntityManager decorator class must be subclass~');
5252
});
5353

5454
// Error: Second level cache enabled without cache
@@ -161,7 +161,7 @@ Toolkit::test(function (): void {
161161
));
162162
})
163163
->build();
164-
}, InvalidConfigurationException::class, "~mapping.*App.*type~");
164+
}, InvalidConfigurationException::class, '~mapping.*App.*type~');
165165
});
166166

167167
// Error: Invalid service reference for cache
@@ -199,7 +199,7 @@ Toolkit::test(function (): void {
199199
));
200200
})
201201
->build();
202-
}, InvalidConfigurationException::class, "~defaultCache~");
202+
}, InvalidConfigurationException::class, '~defaultCache~');
203203
});
204204

205205
// Error: Empty proxyDir
@@ -237,7 +237,7 @@ Toolkit::test(function (): void {
237237
));
238238
})
239239
->build();
240-
}, InvalidConfigurationException::class, "~proxyDir~");
240+
}, InvalidConfigurationException::class, '~proxyDir~');
241241
});
242242

243243
// Error: Missing connection in manager
@@ -273,5 +273,5 @@ Toolkit::test(function (): void {
273273
));
274274
})
275275
->build();
276-
}, InvalidConfigurationException::class, "~connection~");
276+
}, InvalidConfigurationException::class, '~connection~');
277277
});

tests/Cases/Events/ContainerEventManager.phpt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Tests\Cases\Events;
44

55
use Contributte\Tester\Toolkit;
6+
use Doctrine\Common\EventArgs;
67
use Doctrine\ORM\EntityManager;
78
use Doctrine\ORM\Event\OnClearEventArgs;
89
use Doctrine\ORM\Events;
@@ -142,16 +143,17 @@ Toolkit::test(function (): void {
142143
$eventManager = new ContainerEventManager($container);
143144

144145
// Add a generic listener that accepts EventArgs
145-
$called = false;
146-
$listener = new class ($called) {
146+
$state = new \stdClass();
147+
$state->called = false;
148+
$listener = new class ($state) {
147149

148-
public function __construct(private bool &$called)
150+
public function __construct(private \stdClass $state)
149151
{
150152
}
151153

152-
public function onClear(\Doctrine\Common\EventArgs $args): void
154+
public function onClear(EventArgs $args): void
153155
{
154-
$this->called = true;
156+
$this->state->called = true;
155157
}
156158

157159
};
@@ -161,7 +163,7 @@ Toolkit::test(function (): void {
161163
// This should not throw - null args should be handled
162164
$eventManager->dispatchEvent(Events::onClear, null);
163165

164-
Assert::true($called);
166+
Assert::true($state->called);
165167
});
166168

167169
// addEventListener with multiple events

tests/Cases/Utils/Binder.phpt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php declare(strict_types = 1);
22

3+
// phpcs:ignoreFile
4+
35
namespace Tests\Cases\Utils;
46

57
use Contributte\Tester\Toolkit;
@@ -16,9 +18,7 @@ Toolkit::test(function (): void {
1618

1719
};
1820

19-
$result = Binder::use($obj, function (): string {
20-
return $this->secret; // @phpstan-ignore-line
21-
});
21+
$result = Binder::use($obj, fn (): string => $this->secret);
2222

2323
Assert::equal('hidden', $result);
2424
});
@@ -45,9 +45,7 @@ Toolkit::test(function (): void {
4545

4646
// Bind to class string - access static property
4747
Toolkit::test(function (): void {
48-
$result = Binder::use(TestClassWithStatic::class, function (): string {
49-
return self::$staticValue; // @phpstan-ignore-line
50-
});
48+
$result = Binder::use(TestClassWithStatic::class, fn (): string => self::$staticValue);
5149

5250
Assert::equal('static_secret', $result);
5351
});
@@ -60,21 +58,18 @@ Toolkit::test(function (): void {
6058

6159
};
6260

63-
$result = Binder::use($obj, function (): int {
64-
return $this->value * 2; // @phpstan-ignore-line
65-
});
61+
$result = Binder::use($obj, fn (): int => $this->value * 2);
6662

6763
Assert::equal(84, $result);
6864
});
6965

7066
// Return null from closure
7167
Toolkit::test(function (): void {
7268
$obj = new class {
69+
7370
};
7471

75-
$result = Binder::use($obj, function (): mixed {
76-
return null;
77-
});
72+
$result = Binder::use($obj, fn (): mixed => null);
7873

7974
Assert::null($result);
8075
});

0 commit comments

Comments
 (0)