Skip to content

Commit 0611c35

Browse files
authored
refactor: call getPrivateMethodInvoker() statically (#9490)
1 parent 0e0a5ad commit 0611c35

27 files changed

+83
-83
lines changed

tests/system/API/ResponseTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public function testXMLResponseFormat(): void
661661

662662
private function invoke(object $controller, string $method, array $args = [])
663663
{
664-
$method = $this->getPrivateMethodInvoker($controller, $method);
664+
$method = self::getPrivateMethodInvoker($controller, $method);
665665

666666
return $method(...$args);
667667
}

tests/system/Autoloader/AutoloaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function setUp(): void
6464
$this->loader = new Autoloader();
6565
$this->loader->initialize($config, $modules)->register();
6666

67-
$this->classLoader = $this->getPrivateMethodInvoker($this->loader, 'loadInNamespace');
67+
$this->classLoader = self::getPrivateMethodInvoker($this->loader, 'loadInNamespace');
6868
}
6969

7070
protected function tearDown(): void
@@ -111,7 +111,7 @@ public function testInitializeTwice(): void
111111

112112
public function testServiceAutoLoaderFromShareInstances(): void
113113
{
114-
$classLoader = $this->getPrivateMethodInvoker(service('autoloader'), 'loadInNamespace');
114+
$classLoader = self::getPrivateMethodInvoker(service('autoloader'), 'loadInNamespace');
115115

116116
// look for Home controller, as that should be in base repo
117117
$actual = $classLoader(Home::class);
@@ -129,7 +129,7 @@ public function testServiceAutoLoader(): void
129129
$autoloader->initialize(new Autoload(), new Modules());
130130
$autoloader->register();
131131

132-
$classLoader = $this->getPrivateMethodInvoker($autoloader, 'loadInNamespace');
132+
$classLoader = self::getPrivateMethodInvoker($autoloader, 'loadInNamespace');
133133

134134
// look for Home controller, as that should be in base repo
135135
$actual = $classLoader(Home::class);

tests/system/CodeIgniterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ public function testRunForceSecure(): void
460460
$codeigniter = new MockCodeIgniter($config);
461461
$codeigniter->setContext('web');
462462

463-
$this->getPrivateMethodInvoker($codeigniter, 'getRequestObject')();
464-
$this->getPrivateMethodInvoker($codeigniter, 'getResponseObject')();
463+
self::getPrivateMethodInvoker($codeigniter, 'getRequestObject')();
464+
self::getPrivateMethodInvoker($codeigniter, 'getResponseObject')();
465465

466466
$response = $this->getPrivateProperty($codeigniter, 'response');
467467
$this->assertNull($response->header('Location'));
@@ -949,7 +949,7 @@ public function testStartControllerPermitsInvoke(): void
949949
{
950950
$this->setPrivateProperty($this->codeigniter, 'benchmark', new Timer());
951951
$this->setPrivateProperty($this->codeigniter, 'controller', '\\' . Home::class);
952-
$startController = $this->getPrivateMethodInvoker($this->codeigniter, 'startController');
952+
$startController = self::getPrivateMethodInvoker($this->codeigniter, 'startController');
953953

954954
$this->setPrivateProperty($this->codeigniter, 'method', '__invoke');
955955
$startController();

tests/system/Commands/Translation/LocalizationSyncTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function testProcessWithInvalidOption(): void
212212
$langPath = SUPPORTPATH . 'Language';
213213
$command = new LocalizationSync(service('logger'), service('commands'));
214214
$this->setPrivateProperty($command, 'languagePath', $langPath);
215-
$runner = $this->getPrivateMethodInvoker($command, 'process');
215+
$runner = self::getPrivateMethodInvoker($command, 'process');
216216

217217
$status = $runner('de', 'jp');
218218

tests/system/Commands/Utilities/ConfigCheckTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testConfigCheckWithKintEnabledUsesKintD(): void
9292
/**
9393
* @var Closure(mixed...): string
9494
*/
95-
$command = $this->getPrivateMethodInvoker(
95+
$command = self::getPrivateMethodInvoker(
9696
new ConfigCheck(service('logger'), service('commands')),
9797
'getKintD',
9898
);
@@ -110,7 +110,7 @@ public function testConfigCheckWithKintDisabledUsesVarDump(): void
110110
/**
111111
* @var Closure(mixed...): string
112112
*/
113-
$command = $this->getPrivateMethodInvoker(
113+
$command = self::getPrivateMethodInvoker(
114114
new ConfigCheck(service('logger'), service('commands')),
115115
'getVarDump',
116116
);

tests/system/Commands/Utilities/NamespacesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testNamespacesCommandAllNamespaces(): void
9090
public function testTruncateNamespaces(): void
9191
{
9292
$commandObject = new Namespaces(service('logger'), service('commands'));
93-
$truncateRunner = $this->getPrivateMethodInvoker($commandObject, 'truncate');
93+
$truncateRunner = self::getPrivateMethodInvoker($commandObject, 'truncate');
9494

9595
$this->assertSame('App\Controllers\...', $truncateRunner('App\Controllers\Admin', 19));
9696
// multibyte namespace

tests/system/Config/BaseConfigTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function testRegistrars(): void
257257
$config = new RegistrarConfig();
258258
$config::$registrars = [TestRegistrar::class];
259259
$this->setPrivateProperty($config, 'didDiscovery', true);
260-
$method = $this->getPrivateMethodInvoker($config, 'registerProperties');
260+
$method = self::getPrivateMethodInvoker($config, 'registerProperties');
261261
$method();
262262

263263
// no change to unmodified property
@@ -274,7 +274,7 @@ public function testBadRegistrar(): void
274274
$this->setPrivateProperty($config, 'didDiscovery', true);
275275

276276
$this->expectException(RuntimeException::class);
277-
$method = $this->getPrivateMethodInvoker($config, 'registerProperties');
277+
$method = self::getPrivateMethodInvoker($config, 'registerProperties');
278278
$method();
279279

280280
$this->assertSame('bar', $config->foo);

tests/system/ControllerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testCachePage(): void
9494
$this->controller = new Controller();
9595
$this->controller->initController($this->request, $this->response, $this->logger);
9696

97-
$method = $this->getPrivateMethodInvoker($this->controller, 'cachePage');
97+
$method = self::getPrivateMethodInvoker($this->controller, 'cachePage');
9898
$this->assertNull($method(10));
9999
}
100100

@@ -105,7 +105,7 @@ public function testValidate(): void
105105
$this->controller->initController($this->request, $this->response, $this->logger);
106106

107107
// and that we can attempt validation, with no rules
108-
$method = $this->getPrivateMethodInvoker($this->controller, 'validate');
108+
$method = self::getPrivateMethodInvoker($this->controller, 'validate');
109109
$this->assertFalse($method([]));
110110
}
111111

@@ -117,7 +117,7 @@ public function testValidateWithStringRulesNotFound(): void
117117
$this->controller = new Controller();
118118
$this->controller->initController($this->request, $this->response, $this->logger);
119119

120-
$method = $this->getPrivateMethodInvoker($this->controller, 'validate');
120+
$method = self::getPrivateMethodInvoker($this->controller, 'validate');
121121
$this->assertFalse($method('signup'));
122122
}
123123

@@ -146,7 +146,7 @@ public function testValidateWithStringRulesFoundReadMessagesFromValidationConfig
146146
$this->controller = new Controller();
147147
$this->controller->initController($this->request, $this->response, $this->logger);
148148

149-
$method = $this->getPrivateMethodInvoker($this->controller, 'validate');
149+
$method = self::getPrivateMethodInvoker($this->controller, 'validate');
150150
$this->assertFalse($method('signup'));
151151
$this->assertSame('You must choose a username.', service('validation')->getError('username'));
152152
}
@@ -167,7 +167,7 @@ public function testValidateWithStringRulesFoundUseMessagesParameter(): void
167167
$this->controller = new Controller();
168168
$this->controller->initController($this->request, $this->response, $this->logger);
169169

170-
$method = $this->getPrivateMethodInvoker($this->controller, 'validate');
170+
$method = self::getPrivateMethodInvoker($this->controller, 'validate');
171171
$this->assertFalse($method('signup', [
172172
'username' => [
173173
'required' => 'You must choose a username.',
@@ -182,7 +182,7 @@ public function testValidateData(): void
182182
$this->controller = new Controller();
183183
$this->controller->initController($this->request, $this->response, $this->logger);
184184

185-
$method = $this->getPrivateMethodInvoker($this->controller, 'validateData');
185+
$method = self::getPrivateMethodInvoker($this->controller, 'validateData');
186186

187187
$data = [
188188
'username' => 'mike',
@@ -205,7 +205,7 @@ public function testValidateDataWithCustomErrorMessage(): void
205205
$this->controller = new Controller();
206206
$this->controller->initController($this->request, $this->response, $this->logger);
207207

208-
$method = $this->getPrivateMethodInvoker($this->controller, 'validateData');
208+
$method = self::getPrivateMethodInvoker($this->controller, 'validateData');
209209

210210
$data = [
211211
'username' => 'a',
@@ -238,7 +238,7 @@ public function testValidateDataWithCustomErrorMessageLabeledStyle(): void
238238
$this->controller = new Controller();
239239
$this->controller->initController($this->request, $this->response, $this->logger);
240240

241-
$method = $this->getPrivateMethodInvoker($this->controller, 'validateData');
241+
$method = self::getPrivateMethodInvoker($this->controller, 'validateData');
242242

243243
$data = [
244244
'username' => 'a',

tests/system/Database/ConfigTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function testConnectionGroupWithDSNPostgre(): void
167167
$this->assertSame('5', $this->getPrivateProperty($conn, 'connect_timeout'));
168168
$this->assertSame('1', $this->getPrivateProperty($conn, 'sslmode'));
169169

170-
$method = $this->getPrivateMethodInvoker($conn, 'buildDSN');
170+
$method = self::getPrivateMethodInvoker($conn, 'buildDSN');
171171
$method();
172172

173173
$expected = "host=localhost port=5432 user=user password='pass' dbname=dbname connect_timeout='5' sslmode='1'";
@@ -207,7 +207,7 @@ public function testConvertDSN(string $input, string $expected): void
207207
$conn = Config::connect($this->dsnGroupPostgreNative, false);
208208
$this->assertInstanceOf(BaseConnection::class, $conn);
209209

210-
$method = $this->getPrivateMethodInvoker($conn, 'convertDSN');
210+
$method = self::getPrivateMethodInvoker($conn, 'convertDSN');
211211
$method();
212212

213213
$this->assertSame($expected, $this->getPrivateProperty($conn, 'DSN'));

tests/system/Database/Live/ForgeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public function testCreateTableWithNullableFieldsGivesNullDataType(): void
371371
],
372372
]);
373373

374-
$createTable = $this->getPrivateMethodInvoker($this->forge, '_createTable');
374+
$createTable = self::getPrivateMethodInvoker($this->forge, '_createTable');
375375

376376
$sql = $createTable('forge_nullable_table', false, []);
377377

0 commit comments

Comments
 (0)