Skip to content

Commit

Permalink
tests: multiple asterisk for fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ddevsr committed Oct 11, 2024
1 parent b82ca3a commit e7ed5e4
Showing 1 changed file with 59 additions and 33 deletions.
92 changes: 59 additions & 33 deletions tests/system/Validation/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1827,49 +1827,75 @@ public function testRuleWithAsteriskToMultiDimensionalArray(): void
);
}

public function testRuleWithMultipleAsterisk(): void
/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/9219
*/
#[DataProvider('provideMultipleAsterisk')]

Check failure on line 1833 in tests/system/Validation/ValidationTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Validation\ValidationTest::testRuleWithMultipleAsterisk() has parameter $data with no value type specified in iterable type array.

Check failure on line 1833 in tests/system/Validation/ValidationTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Validation\ValidationTest::testRuleWithMultipleAsterisk() has parameter $expectedData with no value type specified in iterable type array.

Check failure on line 1833 in tests/system/Validation/ValidationTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Validation\ValidationTest::testRuleWithMultipleAsterisk() has parameter $rules with no value type specified in iterable type array.
public function testRuleWithMultipleAsterisk(array $data = [], array $rules = [], bool $expectedCheck = false, array $expectedData = []): void
{
$data = [
'id' => 1,
'dates' => [
23 => [
45 => 'Its Mee!',
$this->validation->setRules($rules);

$this->assertSame($expectedCheck, $this->validation->run($data));
$this->assertSame($expectedData, $this->validation->getValidated());
}

public static function provideMultipleAsterisk(): iterable

Check failure on line 1842 in tests/system/Validation/ValidationTest.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis

Method CodeIgniter\Validation\ValidationTest::provideMultipleAsterisk() return type has no value type specified in iterable type iterable.
{
yield 'success' => [
[
'dates' => [
23 => [
45 => 'Its Mee!',
],
],
'foo' => [
'bar' => [
'data' => [
'name' => 'John Doe',
'age' => 29,
'location' => 'Indonesia',
],
],
],
],
'foo' => [
'bar' => [
'data' => [
'name' => 'John Doe',
'age' => 29,
'location' => 'Indonesia',
[
'dates.*.*' => 'required',
'foo.*.*.*' => 'required',
],
true,
[
'dates' => [
23 => [
45 => 'Its Mee!',
],
],
'foo' => [
'bar' => [
'data' => [
'name' => 'John Doe',
'age' => 29,
'location' => 'Indonesia',
],
],
],
],
];

$this->validation->setRules([
'id' => 'required|numeric',
'dates.*.*' => 'required',
'foo.*.*.*' => 'required',
]);

$this->assertTrue($this->validation->run($data));
$this->assertSame([
'id' => 1,
'dates' => [
23 => [
45 => 'Its Mee!',
],
],
'foo' => [
'bar' => [
'data' => [
'name' => 'John Doe',
'age' => 29,
'location' => 'Indonesia',
yield 'failed' => [
[
'foo' => [
'bar' => [
'data' => [
'name' => '',
'age' => 29,
'location' => 'Indonesia',
],
],
],
],
], $this->validation->getValidated());
['foo.*.*.*' => 'required'],
false,
[],
];
}
}

0 comments on commit e7ed5e4

Please sign in to comment.