-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some cleanup & improvements in the tests
- Loading branch information
Showing
8 changed files
with
91 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,24 +12,25 @@ | |
use Neusta\ConverterBundle\Tests\Support\Attribute\ConfigureContainer; | ||
|
||
#[ConfigureContainer(__DIR__ . '/../Fixtures/Config/person.yaml')] | ||
#[ConfigureContainer(__DIR__ . '/../Fixtures/Config/address.yaml')] | ||
#[ConfigureContainer(__DIR__ . '/../Fixtures/Config/contact_numbers.yaml')] | ||
class GenericExtendedConverterIntegrationTest extends ConfigurableKernelTestCase | ||
{ | ||
public function testConvert_with_null_safety_property(): void | ||
public function test_convert_with_skip_null(): void | ||
{ | ||
/** @var Converter<User, Person, GenericContext> $converter */ | ||
$converter = self::getContainer()->get('test.person.converter.extended'); | ||
|
||
// Test Fixture | ||
$source = (new User()) | ||
->setFullName(null) | ||
->setAgeInYears(null); | ||
->setAgeInYears(null) | ||
->setEmail(null); | ||
|
||
// Test Execution | ||
$target = $converter->convert($source); | ||
|
||
// Test Assertion | ||
self::assertEquals('Hans Herrmann', $target->getFullName()); | ||
self::assertSame('Hans Herrmann', $target->getFullName()); | ||
self::assertSame('[email protected]', $target->getMail()); | ||
self::assertSame(39, $target->getAge()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/Fixtures/Model/Target/Factory/PersonWithDefaultsFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Tests\Fixtures\Model\Target\Factory; | ||
|
||
use Neusta\ConverterBundle\Converter\Context\GenericContext; | ||
use Neusta\ConverterBundle\TargetFactory; | ||
use Neusta\ConverterBundle\Tests\Fixtures\Model\Target\Person; | ||
|
||
/** | ||
* @implements TargetFactory<Person, GenericContext> | ||
*/ | ||
class PersonWithDefaultsFactory implements TargetFactory | ||
{ | ||
public function create(?object $ctx = null): Person | ||
{ | ||
return (new Person()) | ||
->setMail('[email protected]') | ||
->setAge(39); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters