Skip to content

Commit

Permalink
deploymentMode for Message
Browse files Browse the repository at this point in the history
  • Loading branch information
mathielen committed Apr 7, 2024
1 parent 3caf0a5 commit ce272d4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/CXml/Model/CXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
*/
class CXml
{

public const DEPLOYMENT_TEST = 'test';
public const DEPLOYMENT_PROD = 'production';

/**
* @Ser\XmlAttribute(namespace="http://www.w3.org/XML/1998/namespace")
*/
Expand Down
10 changes: 8 additions & 2 deletions src/CXml/Model/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace CXml\Model\Message;

use Assert\Assertion;
use CXml\Model\CXml;
use CXml\Model\Status;
use JMS\Serializer\Annotation as Ser;

Expand Down Expand Up @@ -40,9 +42,13 @@ public function __construct(
MessagePayloadInterface $message,
Status $status = null,
string $id = null,
string $deploymentMode = null,
string $inReplyTo = null
string $inReplyTo = null,
string $deploymentMode = null
) {
if (null !== $deploymentMode) {
Assertion::inArray($deploymentMode, [CXml::DEPLOYMENT_PROD, CXml::DEPLOYMENT_TEST]);
}

$this->status = $status;
$this->payload = $message;
$this->deploymentMode = $deploymentMode;
Expand Down
5 changes: 2 additions & 3 deletions src/CXml/Model/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace CXml\Model\Request;

use Assert\Assertion;
use CXml\Model\CXml;
use CXml\Model\Status;
use JMS\Serializer\Annotation as Ser;

class Request
{
public const DEPLOYMENT_TEST = 'test';
public const DEPLOYMENT_PROD = 'production';

/**
* @Ser\SerializedName("Status")
Expand Down Expand Up @@ -41,7 +40,7 @@ public function __construct(
string $deploymentMode = null
) {
if (null !== $deploymentMode) {
Assertion::inArray($deploymentMode, [self::DEPLOYMENT_PROD, self::DEPLOYMENT_TEST]);
Assertion::inArray($deploymentMode, [CXml::DEPLOYMENT_PROD, CXml::DEPLOYMENT_TEST]);
}

$this->status = $status;
Expand Down
4 changes: 2 additions & 2 deletions tests/CXmlTest/Model/OrderRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use CXml\Model\Country;
use CXml\Model\CountryCode;
use CXml\Model\Credential;
use CXml\Model\CXml;
use CXml\Model\Description;
use CXml\Model\ItemDetail;
use CXml\Model\ItemId;
Expand All @@ -21,7 +22,6 @@
use CXml\Model\PostalAddress;
use CXml\Model\Request\OrderRequest;
use CXml\Model\Request\OrderRequestHeader;
use CXml\Model\Request\Request;
use CXml\Model\ShipTo;
use CXml\Model\TelephoneNumber;
use CXml\Payload\PayloadIdentityFactoryInterface;
Expand Down Expand Up @@ -174,7 +174,7 @@ public function testMinimumExample(): void
->to($to)
->sender($sender)
->payload($orderRequest)
->build(Request::DEPLOYMENT_TEST)
->build(CXml::DEPLOYMENT_TEST)
;

$this->assertEquals('OrderRequest_1625586002.193314.7293@dev', (string) $cxml);
Expand Down

0 comments on commit ce272d4

Please sign in to comment.