Skip to content

Commit d356d3b

Browse files
authored
Merge pull request #6669 from kenjis/fix-tests-dynamic-properties
test: fix dynamic properties
2 parents 0aab056 + fec7122 commit d356d3b

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

tests/_support/View/SampleClassWithInitController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class SampleClassWithInitController
2525
{
26+
private ResponseInterface $response;
27+
2628
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
2729
{
2830
$this->response = $response;

tests/system/Models/GeneralModelTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ public function testMagicGetters(): void
7171
$this->assertFalse(isset($this->model->foobar));
7272
$this->assertNull($this->model->foobar);
7373

74-
$this->model->flavor = 'chocolate';
75-
$this->assertTrue(isset($this->model->flavor));
76-
$this->assertSame('chocolate', $this->model->flavor);
77-
7874
// from DB
7975
$this->assertTrue(isset($this->model->DBPrefix));
8076
$this->assertSame('utf8', $this->model->charset);

tests/system/Models/ValidationModelTest.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,26 +238,25 @@ public function testValidationPassesWithMissingFields(): void
238238

239239
public function testValidationWithGroupName(): void
240240
{
241-
$config = new Validation();
241+
$config = new class () extends Validation {
242+
public $grouptest = [
243+
'name' => [
244+
'required',
245+
'min_length[3]',
246+
],
247+
'token' => 'in_list[{id}]',
248+
];
249+
};
250+
Factories::injectMock('config', 'Validation', $config);
242251

243-
$config->grouptest = [
244-
'name' => [
245-
'required',
246-
'min_length[3]',
247-
],
248-
'token' => 'in_list[{id}]',
249-
];
252+
$this->createModel(ValidModel::class);
253+
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
250254

251255
$data = [
252256
'name' => 'abc',
253257
'id' => 13,
254258
'token' => 13,
255259
];
256-
257-
Factories::injectMock('config', 'Validation', $config);
258-
259-
$this->createModel(ValidModel::class);
260-
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
261260
$this->assertTrue($this->model->validate($data));
262261
}
263262

tests/system/View/CellTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ public function testParametersDontMatch()
249249

250250
public function testCallInitControllerIfMethodExists()
251251
{
252-
$this->assertSame(Response::class, $this->cell->render('\Tests\Support\View\SampleClassWithInitController::index'));
252+
$this->assertSame(
253+
Response::class,
254+
$this->cell->render('\Tests\Support\View\SampleClassWithInitController::index')
255+
);
253256
}
254257
}

0 commit comments

Comments
 (0)