Merge pull request #6669 from kenjis/fix-tests-dynamic-properties

test: fix dynamic properties
This commit is contained in:
kenjis 2022-10-13 08:07:07 +09:00 committed by GitHub
commit d356d3b477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 18 deletions

View File

@ -23,6 +23,8 @@ use Psr\Log\LoggerInterface;
*/
class SampleClassWithInitController
{
private ResponseInterface $response;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->response = $response;

View File

@ -71,10 +71,6 @@ final class GeneralModelTest extends CIUnitTestCase
$this->assertFalse(isset($this->model->foobar));
$this->assertNull($this->model->foobar);
$this->model->flavor = 'chocolate';
$this->assertTrue(isset($this->model->flavor));
$this->assertSame('chocolate', $this->model->flavor);
// from DB
$this->assertTrue(isset($this->model->DBPrefix));
$this->assertSame('utf8', $this->model->charset);

View File

@ -238,26 +238,25 @@ final class ValidationModelTest extends LiveModelTestCase
public function testValidationWithGroupName(): void
{
$config = new Validation();
$config = new class () extends Validation {
public $grouptest = [
'name' => [
'required',
'min_length[3]',
],
'token' => 'in_list[{id}]',
];
};
Factories::injectMock('config', 'Validation', $config);
$config->grouptest = [
'name' => [
'required',
'min_length[3]',
],
'token' => 'in_list[{id}]',
];
$this->createModel(ValidModel::class);
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
$data = [
'name' => 'abc',
'id' => 13,
'token' => 13,
];
Factories::injectMock('config', 'Validation', $config);
$this->createModel(ValidModel::class);
$this->setPrivateProperty($this->model, 'validationRules', 'grouptest');
$this->assertTrue($this->model->validate($data));
}

View File

@ -249,6 +249,9 @@ final class CellTest extends CIUnitTestCase
public function testCallInitControllerIfMethodExists()
{
$this->assertSame(Response::class, $this->cell->render('\Tests\Support\View\SampleClassWithInitController::index'));
$this->assertSame(
Response::class,
$this->cell->render('\Tests\Support\View\SampleClassWithInitController::index')
);
}
}