Skip to content

Commit 42a1259

Browse files
authored
IBX-9810: Fixed inner validateProperty*() calls of StructWrapperValidator (#521)
1 parent b8f0ca2 commit 42a1259

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

.github/workflows/ci.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
cs-fix:
1212
name: Run code style check
13-
runs-on: "ubuntu-20.04"
13+
runs-on: "ubuntu-24.04"
1414
strategy:
1515
matrix:
1616
php:
@@ -35,7 +35,7 @@ jobs:
3535

3636
tests:
3737
name: Unit tests & SQLite integration tests
38-
runs-on: "ubuntu-20.04"
38+
runs-on: "ubuntu-24.04"
3939
timeout-minutes: 15
4040

4141
strategy:
@@ -90,7 +90,7 @@ jobs:
9090
--health-timeout 5s
9191
--health-retries 5
9292
--tmpfs /var/lib/postgres
93-
runs-on: "ubuntu-20.04"
93+
runs-on: "ubuntu-24.04"
9494
timeout-minutes: 60
9595

9696
strategy:
@@ -145,7 +145,7 @@ jobs:
145145
--health-timeout=5s
146146
--health-retries=5
147147
--tmpfs=/var/lib/mysql
148-
runs-on: "ubuntu-20.04"
148+
runs-on: "ubuntu-24.04"
149149
timeout-minutes: 60
150150

151151
strategy:
@@ -182,7 +182,7 @@ jobs:
182182

183183
solr-integration:
184184
name: "Solr integration tests"
185-
runs-on: "ubuntu-20.04"
185+
runs-on: "ubuntu-24.04"
186186
timeout-minutes: 30
187187
permissions:
188188
packages: read

src/contracts/Validation/StructWrapperValidator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public function validate($value, $constraints = null, $groups = null): Constrain
7474

7575
public function validateProperty(object $object, string $propertyName, $groups = null): ConstraintViolationListInterface
7676
{
77-
return $this->inner->validatePropertyValue($object, $propertyName, $groups);
77+
return $this->inner->validateProperty($object, $propertyName, $groups);
7878
}
7979

8080
public function validatePropertyValue($objectOrClass, string $propertyName, $value, $groups = null): ConstraintViolationListInterface
8181
{
82-
return $this->inner->validatePropertyValue($objectOrClass, $propertyName, $groups);
82+
return $this->inner->validatePropertyValue($objectOrClass, $propertyName, $value, $groups);
8383
}
8484

8585
public function startContext(): ContextualValidatorInterface

tests/lib/Validation/StructWrapperValidatorTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,39 @@ public function testAssertValidStructWithInvalidWrapperStruct(): void
108108
self::assertSame('property', $error->getPropertyPath());
109109
}
110110

111+
public function testValidateProperty(): void
112+
{
113+
$initialError = $this->createExampleConstraintViolation();
114+
$initialErrors = $this->createExampleConstraintViolationList($initialError);
115+
116+
$object = new stdClass();
117+
$propertyName = 'foobar';
118+
$group = ['Default', 'group'];
119+
$this->validator->expects(self::once())
120+
->method('validateProperty')
121+
->with($object, $propertyName, $group)
122+
->willReturn($initialErrors);
123+
124+
$this->structValidator->validateProperty($object, $propertyName, $group);
125+
}
126+
127+
public function testValidatePropertyValue(): void
128+
{
129+
$initialError = $this->createExampleConstraintViolation();
130+
$initialErrors = $this->createExampleConstraintViolationList($initialError);
131+
132+
$object = new stdClass();
133+
$propertyName = 'foobar';
134+
$value = 'someValue';
135+
$group = ['Default', 'group'];
136+
$this->validator->expects(self::once())
137+
->method('validatePropertyValue')
138+
->with($object, $propertyName, $value, $group)
139+
->willReturn($initialErrors);
140+
141+
$this->structValidator->validatePropertyValue($object, $propertyName, $value, $group);
142+
}
143+
111144
private function createExampleConstraintViolation(): ConstraintViolationInterface
112145
{
113146
return new ConstraintViolation(

0 commit comments

Comments
 (0)