Skip to content

Commit

Permalink
Fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Sep 6, 2021
1 parent dbe1ca0 commit e8a8c89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/FieldDescription/BaseFieldDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,15 @@ final protected function getFieldValue(?object $object, string $fieldName)
));
}

$propertyAccesor = PropertyAccess::createPropertyAccessorBuilder()
$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
->enableMagicCall()
->getPropertyAccessor();

try {
return $propertyAccesor->getValue($object, $accessor);
return $propertyAccessor->getValue($object, $accessor);
} catch (ExceptionInterface $exception) {
throw new NoValueException(
sprintf('Cannot access property "%s" in class "%s".', $this->getName(), \get_class($object)),
sprintf('Cannot access property "%s" in class "%s".', $this->getName(), $this->getAdmin()->getClass()),
(int) $exception->getCode(),
$exception
);
Expand Down
5 changes: 3 additions & 2 deletions tests/FieldDescription/BaseFieldDescriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ public function testAdmin(): void

public function testGetFieldValueNoValueException(): void
{
$this->expectException(NoValueException::class);

$admin = $this->createStub(AdminInterface::class);
$description = new FieldDescription('name');
$description->setAdmin($admin);
$mock = $this->getMockBuilder(\stdClass::class)->addMethods(['getFoo'])->getMock();

$this->expectException(NoValueException::class);
$this->callMethod($description, 'getFieldValue', [$mock, 'fake']);
}

Expand Down

0 comments on commit e8a8c89

Please sign in to comment.