Skip to content

Commit

Permalink
Issue #62: Port component tests to expression language.
Browse files Browse the repository at this point in the history
  • Loading branch information
ademarco committed Nov 7, 2017
1 parent 87e0fd3 commit 66527c8
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 79 deletions.
19 changes: 7 additions & 12 deletions tests/src/Messages/Components/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,18 @@ public function testValidation()
}

/**
* Test parsing.
*
* @param string $xml
* @param string $type
* @param string $nickname
* @param string $email
* @param array $expressions
*
* @dataProvider parserProvider
*/
public function testParsing($xml, $type, $nickname, $email)
public function testWithXml($xml, $expressions)
{
/** @var \EC\Poetry\Messages\Components\Contact $component */
$component = $this->getContainer()->get('component.contact')->withXml($xml);

expect($component->getType())->to->equal($type);
expect($component->getNickname())->to->equal($nickname);
expect($component->getEmail())->to->equal($email);
/** @var \EC\Poetry\Messages\Responses\Status $message */
$message = $this->getContainer()
->get('component.contact')
->withXml($xml);
$this->assertExpressions($expressions, ['message' => $message]);
}

/**
Expand Down
17 changes: 7 additions & 10 deletions tests/src/Messages/Components/DetailsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,18 @@ public function testValidation()
}

/**
* Test parsing.
*
* @param string $xml
* @param array $fixtures
* @param array $expressions
*
* @dataProvider parserProvider
*/
public function testParsing($xml, $fixtures)
public function testWithXml($xml, $expressions)
{
/** @var \EC\Poetry\Messages\Components\Details $component */
$component = $this->getContainer()->get('component.details')->withXml($xml);

foreach ($fixtures as $method => $value) {
expect($component->$method())->to->equal($value);
}
/** @var \EC\Poetry\Messages\Responses\Status $message */
$message = $this->getContainer()
->get('component.details')
->withXml($xml);
$this->assertExpressions($expressions, ['message' => $message]);
}

/**
Expand Down
25 changes: 7 additions & 18 deletions tests/src/Messages/Components/IdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,18 @@ public function testValidation()
}

/**
* Test parsing.
*
* @param string $xml
* @param string $code
* @param string $year
* @param string $number
* @param string $version
* @param string $part
* @param string $product
* @param array $expressions
*
* @dataProvider parserProvider
*/
public function testParsing($xml, $code, $year, $number, $version, $part, $product)
public function testWithXml($xml, $expressions)
{
/** @var \EC\Poetry\Messages\Components\Identifier $component */
$component = $this->getContainer()->get('component.identifier')->withXml($xml);

expect($component->getCode())->to->equal($code);
expect($component->getYear())->to->equal($year);
expect($component->getNumber())->to->equal($number);
expect($component->getVersion())->to->equal($version);
expect($component->getPart())->to->equal($part);
expect($component->getProduct())->to->equal($product);
/** @var \EC\Poetry\Messages\Responses\Status $message */
$message = $this->getContainer()
->get('component.identifier')
->withXml($xml);
$this->assertExpressions($expressions, ['message' => $message]);
}

/**
Expand Down
20 changes: 12 additions & 8 deletions tests/src/fixtures/factories/with-xml/components/contact.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
-
-
xml:
<contacts type="Secretaire">
<contactNickname>Username</contactNickname>
<contactEmail>[email protected]</contactEmail>
</contacts>
- "Secretaire"
- "Username"
- "[email protected]"

expressions:
- message.getType() == "Secretaire"
- message.getNickname() == "Username"
- message.getEmail() == "[email protected]"

-
-
xml:
<contacts type="Secretaire">
<contactNickname>Username</contactNickname>
</contacts>
- "Secretaire"
- "Username"
- null

expressions:
- message.getType() == "Secretaire"
- message.getNickname() == "Username"
- message.getEmail() == null

35 changes: 18 additions & 17 deletions tests/src/fixtures/factories/with-xml/components/details.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-
-
xml:
<demande>
<userReference>clientId</userReference>
<applicationReference>applicationId</applicationReference>
Expand All @@ -18,20 +18,21 @@
<reference_files_note>Note</reference_files_note>
<workflowCode>STS</workflowCode>
</demande>
- getClientId : "clientId"
getApplicationId : "applicationId"
getAuthor : "DIGIT"
getRequester : "DGCOMM"
getTitle : "Title"
getRemark : "Remark"
getType : "INTER"
getDestination : "AUTRE"
getProcedure : "NEANT"
getDelay : "11/12/2007"
getRequestDate : "11/12/2007"
getStatus : "Ready"
getInterServices : "Yes"
getInterInstitution : "Yes"
getReferenceFilesRemark : "Note"
getWorkflowCode : "STS"

expressions:
- message.getClientId() == "clientId"
- message.getApplicationId() == "applicationId"
- message.getAuthor() == "DIGIT"
- message.getRequester() == "DGCOMM"
- message.getTitle() == "Title"
- message.getRemark() == "Remark"
- message.getType() == "INTER"
- message.getDestination() == "AUTRE"
- message.getProcedure() == "NEANT"
- message.getDelay() == "11/12/2007"
- message.getRequestDate() == "11/12/2007"
- message.getStatus() == "Ready"
- message.getInterServices() == "Yes"
- message.getInterInstitution() == "Yes"
- message.getReferenceFilesRemark() == "Note"
- message.getWorkflowCode() == "STS"
32 changes: 18 additions & 14 deletions tests/src/fixtures/factories/with-xml/components/identifier.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-
-
xml:
<demandeId>
<codeDemandeur>DGT</codeDemandeur>
<annee>2017</annee>
Expand All @@ -8,25 +8,29 @@
<partie>00</partie>
<produit>ABC</produit>
</demandeId>
- "DGT"
- "2017"
- "0001"
- "01"
- "00"
- "ABC"

expressions:
- message.getCode() == "DGT"
- message.getYear() == "2017"
- message.getNumber() == "0001"
- message.getVersion() == "01"
- message.getPart() == "00"
- message.getProduct() == "ABC"
- message.getFormattedIdentifier() == "DGT/2017/0001/01/00/ABC"

-
-
xml:
<demandeId>
<codeDemandeur>DGT</codeDemandeur>
<version>01</version>
<partie>00</partie>
<produit>ABC</produit>
</demandeId>
- "DGT"
- null
- null
- "01"
- "00"
- "ABC"

expressions:
- message.getCode() == "DGT"
- message.getYear() == null
- message.getNumber() == null
- message.getVersion() == "01"
- message.getPart() == "00"
- message.getProduct() == "ABC"

0 comments on commit 66527c8

Please sign in to comment.