Skip to content

Commit

Permalink
#68 exclude test for older Symfony versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mike4git committed Apr 2, 2024
1 parent f011b8b commit 27887e3
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions tests/Populator/PropertyMappingPopulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,26 @@ public function test_populate_with_dot_operator(): void
self::assertSame('Bremen', $person->getPlaceOfResidence());
}

// This functionality will be automatically possible with Symfony 6.2 or higher.
// public function test_populate_with_dot_operator_and_null_safety(): void
// {
// $populator = new PropertyMappingPopulator(
// 'placeOfResidence',
// 'address?.city',
// null,
// null,
// null,
// true
// );
// $user = (new User())->setAddress(null);
//
// $person = new Person();
// $person->setPlaceOfResidence('Old City');
//
// $populator->populate($person, $user);
//
// self::assertSame('Old City', $person->getPlaceOfResidence());
// }
/**
* @requires function \Symfony\Component\PropertyAccess\PropertyPath::isNullSafe
*/
public function test_populate_with_dot_operator_and_null_safety(): void
{
$populator = new PropertyMappingPopulator(
'placeOfResidence',
'address?.city',
null,
null,
null,
true
);
$user = (new User())->setAddress(null);

$person = new Person();
$person->setPlaceOfResidence('Old City');

$populator->populate($person, $user);

self::assertSame('Old City', $person->getPlaceOfResidence());
}
}

0 comments on commit 27887e3

Please sign in to comment.