Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Make tests more complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kramer committed Feb 1, 2013
1 parent cd4446c commit 950b33c
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions tests/Deft/MrzParser/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ public function testParse_passportString()
$mrzString = "P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<L898902C<3UTO6908061F9406236ZE184226B<<<<<14";

$document = $this->parser->parseString($mrzString);

$this->assertEquals(TravelDocumentType::PASSPORT, $document->getType());
$this->assertEquals('UTO', $document->getIssuingCountry());
$this->assertEquals('ERIKSSON', $document->getPrimaryIdentifier());
$this->assertEquals('ANNA MARIA', $document->getSecondaryIdentifier());
$this->assertEquals('UTO', $document->getNationality());
$this->assertInstanceOf('DateTime', $document->getDateOfBirth());
$this->assertEquals('06-08-1969', $document->getDateOfBirth()->format('d-m-Y'));
$this->assertEquals('L898902C', $document->getDocumentNumber());
$this->assertEquals(Sex::FEMALE, $document->getSex());
$this->assertEquals('ZE184226B', $document->getPersonalNumber());
$fields = [
'type' => TravelDocumentType::PASSPORT,
'number' => 'L898902C',
'issuingCountry' => 'UTO',
'dateOfExpiry' => '23-06-1994',
'primaryIdentifier' => 'ERIKSSON',
'secondaryIdentifier' => 'ANNA MARIA',
'sex' => Sex::FEMALE,
'dateOfBirth' => '06-08-1969',
'nationality' => 'UTO',
'personalNumber' => 'ZE184226B'
];
$this->assertValidDocument($document, $fields);
}

public function testParse_idcardArray()
Expand All @@ -46,11 +48,34 @@ public function testParse_idcardArray()
];

$document = $this->parser->parseLines($mrzString);
$fields = [
'type' => TravelDocumentType::ID_CARD,
'number' => 'IU4FC08Q1',
'issuingCountry' => 'UTO',
'dateOfExpiry' => '16-03-2016',
'primaryIdentifier' => 'DOE',
'secondaryIdentifier' => 'JOHN',
'sex' => Sex::MALE,
'dateOfBirth' => '03-06-1993',
'nationality' => 'UTO',
'personalNumber' => '219340341'
];
$this->assertValidDocument($document, $fields);
}

$this->assertEquals(TravelDocumentType::ID_CARD, $document->getType());
$this->assertEquals('UTO', $document->getIssuingCountry());
$this->assertEquals('DOE', $document->getPrimaryIdentifier());
$this->assertEquals('JOHN', $document->getSecondaryIdentifier());
$this->assertEquals('219340341', $document->getPersonalNumber());
protected function assertValidDocument($document, $fields)
{
$this->assertEquals($fields['type'], $document->getType(), "Incorrect document type");
$this->assertEquals($fields['number'], $document->getDocumentNumber(), "Incorrect document number");
$this->assertEquals($fields['issuingCountry'], $document->getIssuingCountry(), "Incorrect issuing country");
$this->assertInstanceOf('DateTime', $document->getDateOfExpiry(), "Date of expiry is not a DateTime");
$this->assertEquals($fields['dateOfExpiry'], $document->getDateOfExpiry()->format('d-m-Y'), "Invalid date of expiry");
$this->assertEquals($fields['primaryIdentifier'], $document->getPrimaryIdentifier(), "Invalid primary identifier");
$this->assertEquals($fields['secondaryIdentifier'], $document->getSecondaryIdentifier(), "Invalid secondary identifier");
$this->assertEquals($fields['sex'], $document->getSex(), "Invalid sex");
$this->assertInstanceOf('DateTime', $document->getDateOfBirth(), "Date of birth is not a DateTime");
$this->assertEquals($fields['dateOfBirth'], $document->getDateOfBirth()->format('d-m-Y'), "Invalid date of birth");
$this->assertEquals($fields['nationality'], $document->getNationality(), "Invalid nationality");
$this->assertEquals($fields['personalNumber'], $document->getPersonalNumber(), "Invalid personal number");
}
}

0 comments on commit 950b33c

Please sign in to comment.