-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-29 Allow all sex-values as per standard (#30)
- Loading branch information
Showing
6 changed files
with
110 additions
and
41 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
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
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,51 @@ | ||
<?php | ||
|
||
namespace Aranyasen\HL7\Tests\Segments; | ||
|
||
use Aranyasen\HL7\Segments\PID; | ||
use Aranyasen\HL7\Tests\TestCase; | ||
use InvalidArgumentException; | ||
|
||
class PIDTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider validSexValues | ||
* @test | ||
*/ | ||
public function PID_8_should_accept_value_for_sex_as_per_hl7_standard(string $validSexValue): void | ||
{ | ||
$pidSegment = (new PID()); | ||
$pidSegment->setSex($validSexValue); | ||
self::assertSame($validSexValue, $pidSegment->getSex(), "Sex should have been set with '$validSexValue'"); | ||
self::assertSame($validSexValue, $pidSegment->getField(8), "Sex should have been set with '$validSexValue'"); | ||
} | ||
|
||
/** | ||
* @dataProvider invalidSexValues | ||
* @test | ||
* @param $invalidSexValue | ||
*/ | ||
public function PID_8_should_not_accept_non_standard_values_for_sex(string $invalidSexValue): void | ||
{ | ||
$pidSegment = (new PID()); | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage("Sex should one of 'A', 'F', 'M', 'N', 'O' or 'U'. Given: '$invalidSexValue'"); | ||
$pidSegment->setSex($invalidSexValue); | ||
self::assertEmpty($pidSegment->getSex(), "Sex should not have been set with value: $invalidSexValue"); | ||
self::assertEmpty($pidSegment->getField(8), "Sex should not have been set with value: $invalidSexValue"); | ||
} | ||
|
||
public function validSexValues(): array | ||
{ | ||
return [ | ||
['A'], ['F'], ['M'], ['N'], ['O'], ['U'] | ||
]; | ||
} | ||
|
||
public function invalidSexValues(): array | ||
{ | ||
return [ | ||
['B'], ['Z'], ['z'], ['a'] | ||
]; | ||
} | ||
} |